▚ BATTLE CODE ARENA // PLAYER'S GUIDE PLAY ▶

Writing the program

The PROGRAM tab: the editor for your vehicle's program, and how it tells you what's wrong.

Your vehicle's program is written in BCAS (Battle Code Arena Script), a small language made for the game that reads like Python. A program is one function, update(state, memory), which the game runs ten times a second during a battle. Each time, the program reads what the vehicle knows (state, and what it remembered in memory) and gives its orders: where to drive, where to scan, where to aim and when to fire.

This page is about the editor. For the language itself, Your first program starts from nothing, and the reference has every function and rule.

The editor, with the STARTER program
The editor, with the STARTER program

Starting out

You don't have to start from a blank page. Every new vehicle comes with the STARTER program, which already searches for the opponent, closes in and fires. Change a number in it, run a battle, and watch what's different. Most players start that way.

EXAMPLES has complete programs to load, including the training opponents' own. Loading one replaces the program of the vehicle you have open, so COPY the vehicle in the garage first if you want to keep what it has.

The buttons

ButtonWhat it does
REFThe command reference: every library, function, field, built-in and limit, straight from the game. Each library says whether it's FITTED on this vehicle.
EXAMPLESComplete programs to read or load.
UNDO, REDOSteps back and forward through your changes.
FINDFinds text in the program, with ▲ and ▼ for the previous and next match.
▶ RUNRuns a battle against the opponent chosen in the arena (on a phone; on a bigger screen the arena's controls are beside the editor).
PUBLISHPublishes the vehicle to the league, once it's ready to fight (see The league).

Typing

The editor colours the program as you type and draws a faint guide at each level of indentation. BCAS uses indentation, as Python does, of four spaces a level:

The status line

The line under the editor says how the program stands:

A battle won't start while there's an error, so you're never left wondering why your vehicle sat still.

Sections, one for each class

A program has a section for each class the vehicle has reached, Bronze first. The headings above and below the editor are the sections. Tap one to open it, and tap the open one to fold it away. Each heading says how long the section is, or NOTHING WRITTEN.

Each section is a program of its own, with its own imports and its own update. In a battle they all run every update, from Bronze up, and a later section's orders replace an earlier one's. They share memory. So when a vehicle is promoted to Silver, its Bronze program keeps working, and you write a Silver section only for what you want to do differently.

A section marked SET ASIDE · NOT RUN belongs to a class above the vehicle's own: after it was relegated, or in a copy (a copy starts in Bronze). It's kept, but not run.

Limits

A program has to fit the vehicle's processor and memory. These are Bronze's; Silver and Gold have more (see Classes):

Limit (Bronze)Value
Program size64 KiB
Operations per update2000
Cost of a call10 operations extra
Memory fields64
Memory size16 KiB
Local variables128
String length256 characters
Debug messages per update4
Nesting32 levels

An update that goes over a limit, or fails in any other way, is a fault: everything it did is thrown away, the fault goes on the battle's timeline, and the program runs again at the next update. The battle report shows them.