
-= Robot Warfare 1 =-
Copyright (c) 1998-2002 by
Shabarshin A.A. (shaos@mail.ru),
December 1998 - December 2002
Robot Warfare 1 Rules
Version 2.0.0
1. ROBOT WARFARE 1 - GAME BY E-MAIL
1.1 INTRODUCTION
1.2 GAMERS
1.3 ELECTRONIC ADDRESSES, MAIL-LIST
1.4 REQUESTING BY E-MAIL
2. COMPETITION RULES
2.1 COMPETITION CONDUCT
2.2 RIGHTS OF THE BEST ROBOT AUTHOR
2.4 RESULTS COUNTING AND ROBOT-WINNER DESIGNATION
2.5 ROBOT IDENTIFICATION
2.6 ROBOT DELETING
3. BATTLE RULES
3.1 BATTLE FIELD
3.2 ROBOT EQUIPMENT
3.3 MOVING AND RELATIVE COORDINATES OF ROBOT
3.4 ENERGY
3.5 WALLS AND STONES
3.6 GUN USING
3.7 EYE USING
3.8 RADAR USING
4. "ROBOT WARFARE 1" (RW1) LANGUAGE
4.1 RW1-TEXT AND RW0-PSEUDOCODE
4.2 ROBOT SAMPLE
4.3 RW1-LANGUAGE
4.4 NEW FEATURES IN VERSION 1.99
4.5 NEW FEATURES IN VERSION 2.0
===========================================================================
% ================= WSIMPLE.RW1 ==================
% Example of simple robot
% with an eye
% and a gun.
% Run: RW1_DUEL.EXE WSIMPLE.RW1
ROBOT "WinSimple Robot"
COLOR FFD010
FRONT EYE
LEFT GUN
START:
ACT FRONT % Look in front
if N!=6 : L1 % If there is a robot there then
RIGHT
ACT LEFT % shoot
LEFT
GOTO START
L1:
if N!=3 : L3 % If there is a box with missiles then
STEP % go ahead
GOTO START
L3: % If there is neither box nor robot then
% it means that there is a barrier in the direction
if D==1 : L4 % If the distance from it is greater then 1 then
STEP % make a step
GOTO START
L4:
RIGHT % If the barrier is in the next cell
GOTO START % turn to right
END
COLOR FF0000 % red
COLOR 00FF00 % green
COLOR 0000FF % blue
COLOR FFFFFF % white
COLOR C0C0C0 % light gray and so on.
The image of the robot is stored in eight of these IMAGE lines
Each number corresponds to a pixel.
IMAGE 0 0 0 0 0 0 0 0 % 1st string, 8 black points
IMAGE 0 0 0 0 0 0 0 0 % 2nd string,
IMAGE 0 0 1 1 1 1 0 0
.....
IMAGE 0 0 1 A B 0 0 0
IMAGE 0 0 0 0 0 0 0 0 % 8th string,
where
0 - BLACK 8 - DARKGRAY
1 - BLUE 9 - LIGHTBLUE
2 - GREEN A - LIGHTGREEN
3 - CYAN B - LIGHTCYAN
4 - RED C - LIGHTRED
5 - MAGENTA D - LIGHTMAGENTA
6 - BROWN E - YELLOW
7 - LIGHTGRAY F - WHITE
To set what equipment the robot has in which slot you should
use the following commands: FRONT, BACK, LEFT, RIGHT
followed by EYE or GUN. For example, if you want
to set all four slots to be guns, you should write
FRONT GUN
BACK GUN
LEFT GUN
RIGHT GUN
If you want to set a gun in front and an eye behind you should write
FRONT GUN
BACK EYE
The configuration of robot (color, picture and equipment) is set
after the line with the key word ROBOT and before label START.
A Label is a word followed by colon.
The first label in the program must be
START:
NB: You cannot write a command on a line where there is a label
only comments. A Label is not a command so it is not executed.
If you use arrays you should declare them after the START label
as follows:
DEF name[k]
where k is a number from 1 to 10000.
NB: the quantity of all variables and length of the array can
not be bigger then 10000.
Variables exist from their first usage. The numeric range of
variables and array elements is -32768..32767.
All variables, arrays and labels must have unique names.
Key words, names of registers can not be names.
(Basic programming concepts which should be obvious ;-)
Registers of robot (they are read only):
X,Y - relative coordinates of object,
D - distance,
N - type of object (see 3.1),
K - extra register,
R - random number 0..999
T - value of ticks counter
E - energy level of YOUR robot,
M - number of missiles which YOUR robot has,
Commands of RW1-language:
GOTO label % go to label which name is "label"
CALL label % call procedure from label "label"
RET % return from procedure
STEP % make a step in the direction in which the robot is facing,
% If the movement failed it returns into register N the type of object (see 3.1),
% which prevented the movement of the robot,
% or 0 if it succeeded
LEFT % turn to left
RIGHT % turn to right
SAY "string" % robot says (it will be output to terminal) string
% some of the commands are written in form, eg command n,
% where command is a name of command,
% and n can be a number, a variable or an element of array.
PRINT n % robot outputs to the terminal the value
% of a variable or an element of array.
ACT n % use the equipment (an eye or a gun)
% on that part of the robot
% ( 0- in front, 1- at right, 2- in back, 3- at left or
% FRONT, RIGHT, BACK and LEFT accordingly ),
% eye returns information to the follow registers:
% D - distance from the object (1 - adjacent cell),
% N - type of object in the chosen direction (see 3.1),
% K - energy level if you see another robot,
% stone safety if you see a stone,
% flight direction if you see a missile (see 3.7)
SPY % get information about the last fired missile
% If it hit something the command returns current relative
% coordinates of the missile or the object which was struck by
% it to X and Y registers
% register N - type of object (see 3.1),
% 0 - if the missile is in flight,
% -1 - if no missiles were fired.
RADAR n % use radar for finding of n = 0..6 type object,
% relative coordinates returns to X and Y registers
% If both X and Y are equal to 0 then the object is not found.
% K - quadrant (0,1,2,3)
% D - minimal abs of coordinates (only for 1.8 version)
% in further text:
% n can be variable, element of array,
% m,k can be number, variable, element of array or register.
IF k<m : label % if k is less than m go to label
IF k>m : label % if k is greater than m go to label
IF k<=m : label % if k is less then m or equal to m go to label
IF k>=m : label % if k is greater than m or equal to m go to label
IF k==m : label % if k is equal to m go to label
IF k=m : label % if k is equal to m go to label
IF k!=m : label % if k is not equal to m go to label
IF k<>m : label % if k is not equal to m go to label
n=m % give the value of m to n
% possible expressions
n=-m % give the negative value of m to n
n=m+k % addition
n=m-k % subtraction
n=m/k % division. n will be integer namber
n=m*k % multiplication
n=m%k % remainder of the division m by k
n=m&k % binary AND
n=m|k % binary OR
n=m^k % binary exclusive OR
n=~m % binary inversion
If you incorrectly use stack of returns (CALL and RET), than
it lead to HALT state, that means that robot is dead. HALT state
is appear for any incorrect actions of RW1 program.
S and I registers
S - depth of stack of returns
I - identifier of robot in battle
DEF name[number]={list of values}
for example DEF aaa[10]={1,2,9}
it means that aaa[0]=1 aaa[1]=2 aaa[2]=9 and others are zero
DUMP number
print dump of variables in number columns
TEST "wildcard" : label
test last SAY with wildcard (?-one symbol *-number of symbols)
SHOT Arr[N_offset]
shot values of registers to array from N_offset to N_offset+15 :
Arr[N_offset+0]=X, Arr[N_offset+1]=Y, Arr[N_offset+2]=D,
Arr[N_offset+3]=N, Arr[N_offset+4]=K, Arr[N_offset+5]=R,
Arr[N_offset+6]=T, Arr[N_offset+7]=E, Arr[N_offset+8]=M,
Arr[N_offset+9]=I, Arr[N_offset+10]=0, Arr[N_offset+11]=0,
Arr[N_offset+12]=0, Arr[N_offset+13]=0, Arr[N_offset+14]=0,
Arr[N_offset+15]=S.
POP
take one value from stack of returns and decrement S register
(for returning from subprograms without RET by GOTO)
SEND var1 var2
send code var1 to robot with I (robot identifier) var2
(energy decries for 1 level) if var2=0 then it's broadcast
RECV var
receive code from buffer (sended by another rorbot) and
save it to var
SAY "VAR=&VAR "
print variable value by SAY
VAR=expression
long expressions with (,),?:,+,-,*,/,%,&,|,^,~,!,&&,||,=,==,>,<,>=,<=,!=,<<,>>
Preprocessor directives:
+filename // file including
@name(Nargs) = expr // macros for expressions
@name = const // macros for constant
main() START:
{
-->
} GOTO START
name() NAME:
{
-->
} RET
if expr : label --> (expr);IFY L label
if(expr) COMMAND (expr);IFN L l1
--> COMMAND
l1:
if(expr) (expr);IFN L l1
{ -->
} l1:
if(expr) (expr);IFN L l1
{
} GOTO l2
else --> l1:
{
} l2:
while(expr) l1:
{ (expr);IFN L l2
-->
continue GOTO l1
break GOTO l2
} GOTO l1
l2:
do l1:
{
-->
continue GOTO l1
break GOTO l2
}while(expr) (expr);IFY L l1
l2:
for(expr1,expr2,expr3)
{
expr1
l1:
(expr2);IFN L l2
-->
continue GOTO l1
break GOTO l2
expr3;
GOTO l1
} l2:
COMMAND1(expr)
--> A=expr;COMMAND1 A
COMMAND2(expr1,expr2)
--> A=expr1;B=expr2;COMMAND2 A B
SUBPROG1(expr1)
--> A=expr1;CALL SUBPROG1
SUBPROG2(expr1,expr2)
--> A=expr1;B=expr2;CALL SUBPROG2
SUBPROG3(expr1,expr2,expr3)
--> A=expr1;B=expr2;C=expr3;CALL SUBPROG3
--> END