tanks

Blow up enemy tanks using code
git clone https://git.woozle.org/neale/tanks.git

tanks / docs
Neale Pickett  ·  2024-12-05

procs.md

 1# Tanks Procedure Reference
 2
 3Each tank's program is run once per turn.  The data and command
 4stacks are reset at the beginning of each turn, but memory is not,
 5so you can carry data over in memory registers if you want.  See
 6the [Forf manual](forf.md) for more information about
 7the base language.
 8
 9For tank specifications (sensor range, maximum speeds, etc.), see
10the [introduction](intro.html).
11
12## Limits
13
14Forf Tanks has a data stack size of 200, and a command stack size
15of 500.  This means your program cannot have more than 200 data
16items, or 500 instructions, including 2 instructions for each
17substack.
18
19Forf Tanks provides 10 memory registers (0-9) which persist across
20invocations of your tank's program.
21
22
23## Additional Procedures
24
25fire-ready?
26: Returns 1 if the tank can fire, 0 if not.
27
28fire!
29: Fires the cannon.
30
31l r set-speed!
32:  Sets the speed of the left and right treads (range: -100 to 100).
33
34get-turret
35: Returns the current angle of the turret, in degrees.
36
37a set-turret!
38: Begin moving the turret to a degrees.
39
40n sensor?
41: Returns 1 if sensor n is triggered, 0 if not.
42
43s set-led!
44: Turns off the LED if s is 0, on for any other value.
45
46n random
47: Returns a random number in the range [0, n).  That is, between 0 and n-1, inclusive.