Skip to content

Moonwell 0.16.0

Choose a tag to compare

@mdlsvensson mdlsvensson released this 14 Nov 14:08
· 23 commits to main since this release

Moonwell 0.16.0 adds Moonwell.AI, a base for AI that any map can use: brains for units, players and the game, a blackboard of facts, behaviour trees and utility AI that call each other, full control of a unit beside the game's own AI, development tools that show what a brain thinks, and a fast simulation in .NET to test AI code without the game. Moonwell.AI.Combat builds lane fighters on top of it. It also takes in 0.15.1.

The full suite passes, and Moonwell's cases pass on .NET and in Lua, in development and release builds. Each part was checked in the game (3.0.1.24371) in its own probe or check map, and all of it together in one map, in single player and classic graphics. Multiplayer checks are still to come.

New

  • Brains: UnitBrain, PlayerBrain and GameBrain are components that think on one shared 0.02 s loop and end with what they belong to. A brain's own Order, OrderAt and OrderOn reach the game only when they change. In the game's probes, 1,000 brains thinking every 0.25 s cost about 40 to 50 ms of Lua a game second; orders, not thinking, are the limit.
  • Facts: Fact<T> is a typed key. A fact is written by any code or worked out when read, remembers when it was set, and is read up the chain from a unit's brain to its player's and the game's. A unit's brain reads its current owner's facts.
  • Behaviour trees: a Tree per brain, built in C# from node helpers (using static Moonwell.AI.Nodes: Select, Sequence, When, MoveTo, ...). A When in a Select is checked at every think and cuts in on a lower branch. Unit actions cover moving, attacking, casting, following a route and using items (Unit.UseItem, UseItemAt, UseItemOn, also new in core). A map's own node is a class inheriting Node, or a Do(...) one-liner.
  • Utility AI: a Choice of Options, each with an action, a weight and inputs through curves (Line, Power, S, Step, Points). The best score wins. An option's action can run a tree, and a tree can hold a choice.
  • Full control: UnitBrain.FullControl takes a unit from the game. Orders the game or an AI script gives it, and a player's clicks, are answered with hold position, so only the brain's orders stand. Set it false, or end the brain, and the unit goes back to the game. The melee and campaign AI scripts stay natives, and the guide says how they meet brains.
  • AI tools, development builds only: the debug panel shows a brain's trees, its choices' scores and its facts (Ctrl + click a unit, or -brain <class>). -brainlog writes a decision log of what won, its score and the facts read. -force, -fact and -wake steer a brain from chat. A release build carries none of them.
  • Fast simulation: Moonwell.Simulation, a package for a map's test project. Simulation.Start(map) runs the map's components outside the game, units walk, fight and cast at their type's numbers, and sim.Run(seconds) plays it faster than real time, the same each run from the same seed.
  • Combat: Moonwell.AI.Combat gives a ready LaneWalker brain that walks a route, such as a Procgen road, fights what it meets and goes on. It picks targets by rules (Target.Nearest, Weakest, MostDangerous, Attacker or a map's own), casts its spells in priority order when their conditions hold, and pulls back when hurt or outnumbered, coming back when its reason is gone. Its tree is made of public combat nodes, so a map can build its own.
  • From 0.15.1: hills on a whole 480 by 480 area, no leak report for generated ground, IsMade after a world ends, and text extensions in a packaged map.

Fixed

  • A Fact<T> declared in a file whose name sorts before Moonwell's own Fact.cs no longer stops the script at load.

Known

  • The game gives code no way to end a unit's chase, so the lane walker's leash is the only limit on how far it chases.
  • The simulation plays orders, walking, attacks, cooldowns and mana, not spell effects or pathing.
  • Big-area heights (0.15.1) are experimental: on one map, classic graphics drew the ground flat while trees and units followed the heights.
  • Multiplayer is not checked yet, nor a game in another language.