Tank war
Djmips mention of an old Apple II game called RobotWar got me wondering if something similar could be done for Combat tanks. Of course with the 2600, a tank language would have to be really minimal. So I've come up with a 4-bit machine code that might work. You would enter the machine code into the 2600 via the joystick. Each tank might feasibly get 64 units (nybbles) of memory. Although I'm not sure if that much is even needed.
mnemon opcode nybbles description ROTL 0 1 Rotate left (latched register, enables rotation once every 16 frames) ROTR 1 1 Rotate right (see above) FWD 2 1 Move forward (latched, but has immediate effect) STOP 3 1 Stop all motion (immediate effect) FIRE 4 1 Fire gun (Immediate, but only fires if a projectile isn't being fired) IFFIR 5 2 IF my projectile is in flight IFAGE 6 2 IF my angle > enemy angle then branch IFANE 7 2 IF my angle <> enemy angle then branch IFNRF 8 2 IF enemy is within firing range then branch IFHIT 9 2 IF hit obstacle then branch IFXGX A 4 IF value1>value2 then branch IFXEX B 4 IF value1=value2 then branch GOTO C-F 2
IF branches are relative, -7 to +7 in memory (not including branch instruction or the following inst) and 0 means END
GOTO can go to any location 0-63. The last two bits in the opcode nybble contain the first two bits in the destination address
Tank registers, contain 0-15. Written indirectly, and read with IFXGX or IFXEX. Use lower 3 bits of nybble:
value name description 0 X my X pos 1 Y my Y pos 2 ANG my rot angle 3 EDST enemy distance (firing range=8) 4 EANG enemy angle relative to me 5 PDST enemy's projectile distance 6 PANG enemy's projectile angle relative to me 7 TIME time left in game
If you are comparing two registers, leave the high bit of each nybble clear. If you want to use a constant in value2, set the high bit of value1's nybble.
While it is possible to hand-assemble the above code, it could get tedious.
There could be a simple compiler that could build the machine code to enter into the 2600, though it would run on a computer. I have no desire to write one for the 2600 itself...
Example (spin and fire)
1 ROTR
2 IFANE END
3 FIRE
coded as:
1704 (the rest would be F. FF indicates GOTO END)
Slightly better example (track enemy, fire if in range)
1 ROTR
2 IFAGE +1
3 ROTL
4 IFNRF +1
5 FIRE
Coded as:
1610814
If one can have 64 memory units, it may be possible to get some decent AI in there. I'm sure a simple Combat clone could be written from scratch, and would have 64 bytes of RAM free for AI code for two tanks that can play each other.
I suppose it would also be possible to pit a computer tank against a human player, if nothing else, for testing.
Infinite loops would not crash the game, as INTIM could be monitored in the interpreter.
I'm not sure how effective the AI will be with such a limited language, and I'm sure there are ways to improve it. For instance, some of the 2-nybble specialized branches could be eliminated to add extra instructions, and maybe "TIME" could be a user variable. Who knows?
8 Comments
Recommended Comments