A robot's brain for Cauldron2D.Robot: a robot joins a world as {:robot, n} and
flies by its view, deciding every few frames here.
On its base it turns to face away from the wall the base sits on and thrusts off,
burning straight until it is clear. In flight it picks the nearest live enemy it has
a clear line to and steers for the clear heading nearest the enemy's — clear as far as
it would travel in the time a turn takes — thrusting while far and below cruising
speed (slower where the map allows no shields, under the speed a wall crash takes), and
firing while lined up within reach; when drifting into a wall it turns to
face away and thrusts to brake, and it raises its shield when a shot is close. With
no enemy in sight it looks for a way to one of the three nearest on the arena's coarse
map (ExPilot.Robot.Route) and flies for the furthest point of that way it can see,
holding its fire; with none it holds its course the same way. Low on fuel, with a fuel station in sight, it
makes for the station and hovers there until the tank is full. A robot whose ship is
gone from the arena — a player took its base — leaves the world and stops.
The coarse map is built once per map name and kept, so a map's name must be unique among the maps open at once, as the radar's must be.
Every robot has a skill, drawn by Cauldron2D.Robot between 0.3 and 1.0 unless
given: it sets how tightly it aims, how far it fires from, how often it holds its
fire, how fast it reacts (the runner's cadence) and how late it raises its shield.
Cauldron2D.Robot.start_link(brain: ExPilot.Robot, world: world, number: 1, brain_opts: [arena: :dogfight])
ExPilot.Robot.decide(view, grid, 0, skill: 0.6, stations: stations, route: route, tick: tick)
Summary
Functions
The actions to hold for view, given the arena's collision grid, with no launch burn running.
The actions to hold for view and the launch burn left after them.
Functions
@spec decide(map(), Cauldron2D.Collision.grid()) :: MapSet.t(atom())
The actions to hold for view, given the arena's collision grid, with no launch burn running.
@spec decide(map(), Cauldron2D.Collision.grid(), non_neg_integer(), keyword()) :: {MapSet.t(atom()), non_neg_integer()}
The actions to hold for view and the launch burn left after them.
burn is how many decisions of the burn remain: a landed robot turns to face up and
thrusts off with a full burn, then holds thrust straight while the burn lasts and the
way ahead is clear. With the burn spent it flies: toward the nearest clear heading to
the nearest enemy in sight, braking when drifting into a wall, firing when lined up,
shielding when a shot is close; with no enemy in sight, toward the way :route finds
to the nearest one. With the tank below 350 and a station of :stations within 25
tiles the robot flies there instead and hovers within reach of it.
opts: :stations, the arena's fuel tiles (default none); :route, the arena's
ExPilot.Robot.Route (default none: an enemy out of sight is left alone); :skill,
0.3 to 1.0 (default 1.0); :tick, the frame count, which a robot with less than full
skill uses to hold its fire part of the time (default 0).