Library
FSBar.Client is the core library. It owns the engine lifecycle, the protobuf wire protocol, the GameState projection, and the map-analysis primitives.
BarClient
open FSBar.Client
// Headless — fastest path for CI / scripts.
use client = BarClient.startHeadless ()
// Graphical — full BAR window (Linux only, windowed; fullscreen is disabled).
use graphical = BarClient.startGraphical ()
Two frame APIs:
- Pull —
client.WaitFrames n handlerblocks untilnframes have passed, invokinghandler : GameFrame -> unitper frame. Best for REPL. - Push —
client.Frames : IObservable<GameFrame>for reactive pipelines.
A GameFrame is:
type GameFrame =
{ FrameNumber: int
Events: GameEvent list
State: GameState }
client.GameState is an always-current snapshot updated each frame.
Commands
FSBar.Client.Commands produces typed AICommand values. Send any sequence with client.SendCommands : AICommand list -> unit.
open FSBar.Client.Commands
client.SendCommands [
MoveCommand 42 2000.0f 100.0f 1000.0f
BuildCommand 12 "armllt" 2100.0f 100.0f 1050.0f
StopCommand 17
]
Builders cover Move, Build, Attack, Guard, Patrol, Repair, Reclaim, Stop, Wait, SetFireState, SetMoveState, and more.
Events
GameEvent is a flat DU of all engine-sourced facts: UnitCreated, UnitFinished, UnitIdle, UnitDamaged, UnitDestroyed, EnemyEnterLOS, EnemyLeaveLOS, EnemyEnterRadar, PlayerCommand, and many more.
Typical handler shape:
client.WaitFrames 500 (fun frame ->
frame.Events
|> List.choose (function
| GameEvent.UnitIdle uid -> Some (MoveCommand uid 4096.0f 100.0f 4096.0f)
| _ -> None)
|> function [] -> () | cmds -> client.SendCommands cmds)
GameState
type GameState =
{ TrackedUnits: Map<int, TrackedUnit>
TrackedEnemies: Map<int, TrackedEnemy>
Economy: EconomySnapshot
FrameNumber: int
UnitDefs: UnitDefCache }
TrackedUnit carries position, heading, health, def id, team, and build progress. TrackedEnemy adds LOS/radar state. EconomySnapshot holds metal/energy income, storage, and pull.
Callbacks
FSBar.Client.Callbacks exposes 26 mid-frame queries (unit position/health, team economy, map info, raw heightmap data, LOS arrays, …). Use these when you need richer data than GameState carries, or data not fact-extracted into events.
Map analysis
Module |
Purpose |
|---|---|
|
Array2D heightmap / slope / resource / passability layers |
|
Spatial queries over a |
|
Parses |
|
Navmesh-style reachable-region primitives |
|
Static chokepoint extraction |
|
Candidate base-layout scoring |
|
Wall/choke blocking planner |
|
JSON+gzip on-disk cache under |
MapCacheFile.read is the hot path — the trainer bots warm up against committed per-map caches and hard-abort on codeVersion mismatch.
Synthetic data
FSBar.SyntheticData produces deterministic GameState snapshots + Scene values without a running engine — the basis of every Viz unit test and every Hub-tab preview. See Visualization.
API reference
Full auto-generated reference: API.
val int: value: 'T -> int (requires member op_Explicit)
--------------------
type int = int32
--------------------
type int<'Measure> = int
module List from Microsoft.FSharp.Collections
--------------------
type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ...
module Map from Microsoft.FSharp.Collections
--------------------
type Map<'Key,'Value (requires comparison)> = interface IReadOnlyDictionary<'Key,'Value> interface IReadOnlyCollection<KeyValuePair<'Key,'Value>> interface IEnumerable interface IStructuralEquatable interface IComparable interface IEnumerable<KeyValuePair<'Key,'Value>> interface ICollection<KeyValuePair<'Key,'Value>> interface IDictionary<'Key,'Value> new: elements: ('Key * 'Value) seq -> Map<'Key,'Value> member Add: key: 'Key * value: 'Value -> Map<'Key,'Value> ...
--------------------
new: elements: ('Key * 'Value) seq -> Map<'Key,'Value>
FSBarV1_Archived