BCAS 1.6 · RULESET v0.10
Program a vehicle.
Send it into battle.
In Battle Code Arena you don't drive your vehicle: you write the program that does. This is the reference for that language, Battle Code Arena Script (BCAS): how it works, every function it has, and tutorials that take you from a first program to one that wins.
from vehicle import drive, radar, missiles
def update(state, memory):
contact = radar.contact()
if contact and state.time - contact.seen_at <= 0.2:
# Seen it a moment ago: keep the radar on it, aim, and fire.
radar.scan(contact.bearing)
missiles.aim(contact.bearing)
if missiles.ready():
missiles.fire()
else:
# Nothing in sight: sweep the radar round.
radar.scan(wrap(state.time * 120))
drive.set(throttle=0.5, turn=0.2)What BCAS is
A small language that will feel familiar if you've seen Python: indentation for blocks, if, elif and else, numbers, strings and None. It is deliberately small. There are no loops and no functions of your own: your program is one function, update(state, memory), and the game calls it ten times a second for the whole battle. Each time it looks at what the vehicle knows, decides, and gives its orders.
Your vehicle and its opponent run the same rules and the same language. Neither program can see the other's code; both see the same battle.
Where to go next
How a program runs, and one that finds, chases and shoots, line by line.
Hitting a moving targetLead the target: aim where it will be when the missile arrives.
Staying aliveShields, energy, dodging missiles and keeping off the walls.
Missiles, energy and repairsFind crates, charging points and depots with the radar, and use them.
Memory, timers and modesRemember things between updates, time things, and switch between behaviours.
The languageThe whole of BCAS in one page: syntax, values, operators and limits.
Functions and recordsEvery library function, built-in and field, from the game's own definition.
Example programsThe Starter, lessons and training opponents that ship with the game.
Always up to date
The function reference, the rules, the equipment and the examples on this site are generated from the game's own core, the same code that runs every battle. Every program in the tutorials is checked by that core before the site is published, so each one will fight as written.