The Tank Language


The tank language will look very similar to Logo if you're familar with it. The object of the language is not to provide a sophsticated programming language so that the genius programmers can wreak unstoppable mechanical havok on their opponents. The goal is to create a language so simple that anyone could program a tank capable of standing a chance in the arena.

This means that there are no complicated gramatical structures. We're not trying to make a language that requires a text book to figure out. Just something, that with a little time, can be used to create a superior tank. You give it a mind; it uses it to kill.

What does it look like?

The basic structure of a single command is simple. You call the command passing in a list of parameters. These parameters can either be variables or literals. The command will return a list of out puts that are stored into variables.

return1, return2, ... = command(param1, param2, ... )

Commands will be grouped into labeled sections. This allows the user of a GOTO command that can jump to another label in the tanks programmings. Here is a basic example written in psuedo-code. When the tank language is finalized upon, this will be updated to be real code.

  numOfOpponents = ping()
  areOpponents = compare('>', numOfOpponents, '0')
  if(areOpponents, 'ATTACK', 'MOVE')

  bearing, distance = locate('0')


How is it stored?

For the purposes of storing, the language will be in an XML file. The above tank commands in the START label will look similar to this:

<label name="START">
  <command name="ping">
    <return name="numOfOpponents">
  <command name="compare">
    <param value="'>'">
    <param value="numOfOpponents">
    <param value="'0'">
    <return name="areOpponents">
  <command name="if">
    <param value="areOpponents">
    <param value="'ATTACK'">
    <param value="'MOVE'">

Commands for v1.0.

Jump to command: | add | assign | compare | fire | getTurretBearing | gosub | goto | if | locate | move | ping | random | rotate | scan | subtract | survey | taunt | turn |

Segment Cost 0
Description Adds two opperands together
Parameter #1 (OPERAND1) First operand to add
Parameter #2 (OPERAND2) Second operand to add
Return #1 Result of the addition
Commands Commands
Segment Cost 0
Description Assigns the value of RVALUE into the memory location LVALUE
Parameter #1 (LVALUE) Name of key in tank memory to assign value to
Parameter #2 (RVALUE) Value to assign to LVALUE
Commands Commands
Segment Cost 0
Description returns 1 or 0 based on evaluation of OPERATION
Parameter #1 (OPERATION) Operation of comparison. Valid values are: <, >, >=, <=, =, !=
Parameter #2 (LEFT_OPERAND) Opperand that goes to the left of the operation.
Parameter #3 (RIGHT_OPERAND) Opperand that goes to the right of the operation
Return #1 (RESULT) 0 or 1 depending if the comparison is true or false
Commands Commands
Segment Cost 5
Description fires gun
Commands Commands
Segment Cost 0
Description Gets the relative bearing of your turret
Return #1 (TURRET_BEARING) Returns the bearing of your turret relative to bearing of your tank.
Commands Commands
Segment Cost 0
Description Jumps to a label and then returns to this point of the program afterwards.
Parameter #1 (LABEL) Labeled command section to jump to. Returns to current position after processing.
Commands Commands
Segment Cost 0
Description jumps to label LABEL:
Parameter #1 (LABEL) Labeled command section to jump to
Commands Commands
Segment Cost 0
Description Conditionally jumps to a label
Parameter #1 (CONDITION) Either 1 or zero to tell if the command should execute a goto or not.
Parameter #2 (THEN) If the condition is 1, a goto will execute to this label.
Parameter #3 (ELSE)* If the conditiion is 0, a goto will execute to this label. This parameter is optional. If not given, processing will continue down the current label.
Commands Commands
Segment Cost 3
Description returns bearing and position to tank TANK_NUMBER
Parameter #1 (TANK_NUMBER) Usually gotten from the ping command
Return #1 (BEARING) The bearing to the tank specified
Return #2 (DISTANCE) Distance to the tank specified.
Commands Commands
Segment Cost 10 for each unit of distance
Description moves tank forward DISTANCE
Parameter #1 (DISTANCE) Distance to move tank forward
Commands Commands
Segment Cost 2
Description locates nearby tanks; returns the number of tanks found
Return #1 (TANK_COUNT) Number of tanks found.
Commands Commands
Segment Cost 0
Description Generates a random number between 0 and MAX
Parameter #1 (MAX) Maximum number to generate
Return #1 Integer between 0 and less than MAX
Commands Commands
Segment Cost 1 for each 10 degrees
Description rotates turret DEGREES degrees clockwise
Parameter #1 (DEGREES) Rotates turret this many degrees clockwise. Negative values are allowed.
Commands Commands
Segment Cost 5
Description returns orientation and gun position for tank TANK_NUMBER
Parameter #1 (TANK_NUMBER) Usually gotten from the ping command
Return #1 (ORIENTATION) Returns the opponents orientation. This is the orientation result he would get from calling the locate command on you.
Return #2 (TURRET_ORIENTATION) Orientation of the opponents turret. This is the result he would get from calling getTurretBearing
Commands Commands
Segment Cost 0
Description Subtracts one operand from another
Parameter #1 (OPERAND1) Operand to subtract from
Parameter #2 (OPERAND2) Amount to subtract from operand 1
Return #1 Result of the subtraction
Commands Commands
Segment Cost 3
Description returns distance to nearest obstacle at bearing BEARING
Parameter #1 (BEARING) Bearing to find the closest obstacle at.
Return #1 (DISTANCE) The distance to the nearing obstacle
Commands Commands
Segment Cost 2
Parameter #1 (DIS) Disrespectful remark to print to players screens
Commands Commands
Segment Cost 1 for each 10 degrees
Description turns tank DEGREES degrees clockwise
Parameter #1 (DEGREES) Turns tank this many degrees clockwise. Negative values are allowed.
Commands Commands