Bots are simulated by the execution of a "virtual" processor. This processor (close to a x86 processor) executes instructions and interacts with environnement with the help of specials instructions (drive, speed, scan, etc...) and read-only variables.

A bot is coded using assembler language, very close to a x86 assembler, with some differences and limitations needed by the main goal of B.O.T.S : coding the best bot which can interact and fight in an arena.
The main difference is that the processor is a mathematical processor, so all registers, variables and function use float values, because a bot needs to do a lot of computation for movement, target trajectory, etc...

Processor simulation

The simulated processor runs at 1 Mhz, so 1 million of cycles is executed in a simulated second. The number of instructions you can execute in a second depends of instructions ! An instruction takes a various number of cycles to execute, so refer to opcode list to know the number of cycles needed by all instructions.

There is two segment in memory, the code segment and the data segment :
- The code segment is protected, so bot can't access or change anything in this segment (so you can't change the EIP register, and you can't do auto-modificated code). This segment is 64KB length, and an instruction takes 4 bytes. So you guess that your code can't have more than 16384 instructions.
- The data segment, also 64KB length, is compose of a read-only part ( 256 bytes, i.e. 64 values), a read-write part ( 48896 bytes, i.e. 12224 values), and a stack ( 16384 bytes, i.e. 4096 values). Read-only part contains all read-only variables you need (see read-only variables list). The user part is where you can define your own variables. The stack is accessable by push/pop/call/ret instructions, and is driven by esp/ebp registers (see Asm Syntax for a more detailled explanations).

If a runtime error (divide by zero, trying to write read-only data, etc ...) occurs during the execution, the bot doesn't die but receive a cycles penalty (500 cycles). It's means that the bot is stalled during 500 cycles.

Simulation execution

Execution of bots relies on a virtual time, so running a match at 1x or 8x doesn't affect the simulation. The simulation is also predictive, so replaying a match with same bots and same startup conditions (which init the random generator) will give the exact same result.

A match contains several bots (of the same and different teams). Each bot is executed for a number of cycles alternatively, during a period call simulation base time, which last 20 milliseconds. So the time given for each bot is exactly the same.
Each bot runs for base time, and when all bots have executed this given time, the simulation is updated (bot position, cannon, etc ...). It's important to know this when coding a bot, because it's useless to read several times your current position, for example, in a time less than 20ms. You'll probably only get the same value. Targets will neither have changed, etc ...
This ensure that all bots have same information during this base time !


Bots can get information from read-only vars, instructions (use the scan opcode to detect other bots), but also need to communicate with other bots of the same team to share information. This is possible using a radio channel system (see open, write, close, read instructions).

A bot can open a radio for sending data, write values (the message you want to deliver is coded in your own format), and send the whole message when closing the chan. The message is sent to a particular bot, or to all bot of the same team depending the way you opened it.
On the other side, bots can listen to a particular chan, and read messages.
This way, bots can share information on targets position, strategy, etc ... It's up to you to decide which information your bots will share !

File Format

Bots are compiled into .bot file format. This is the executable form of a bot. This .bot also contains the name of the bot and the author to prevent "bot stealing". You can't also rename the file name for the same reason.

Use the editor to create your bot in order to produce a .bot file :
First create a project, then create your source file. You can then build your project and test your bot !