Introduction
| Driving program
| Tips
Function blocking
Function blocking is an important concept. To understand this, it is necessary
to know how the combat server works.
To start the game, the combat server is run. It will then start the driving
program of the first bot and waits for about one second for that program to
call init. If the program doesn't call init, the bot is disqualified. Otherwise,
it is loaded in the arena. This process is repeated for all the bots in a
sequential manner. All the init's are made to return simultaneously only after
this process is over. This is done to prevent the first bot from getting an
early start.
Whenever a bot calls a function defined in aibots.c (like move, scan, getinfo,
msgsend,etc) the function sends an appropriate request to the combat server and
waits for its reply. The combat server checks for requests from each of the bots
every game time and processes it accordingly (This processing won't take much
time. It just involves changing some variables). After that it sends a reply to
the bot. The function will interpret this reply and then returns.
Relative co-ordinates
The concept of relative co-ordinates has been introduced from v2.07 onwards.
The co-ordinates are relative to the bot. The bot behaves as if it has been loaded
at 49,6 though it may have been loaded at 50,93. Bots belonging to team0 will be
randomly in the square with corners (41,2) and (57,18). Team1 bots will be loaded
in the square with the corners (42,81) and (58,97). These co-ordinates are w.r.t.
the map. However the functions move, scan, getinfo, fire will use
99 - abscissa, 99 - ordinate and (angle - 180)%360 if the
bot is in team 1. This has been done to make sure that you need not break your
head to make your program run identically, independent of its team number. (I am
not sure if i've explained this concept properly. If you don't understand this
concept too well, don't worry. Just assume that your program will always be assigned
to team 0 and write your program). Note that this concept DOES NOT apply to the
bot id. That is, your bot id's will be 0 to 4 for team 0 and 5 to 9 for team 1.
The process of moving and the concept of bombs
Moving: A bot moves once in every three game time. To be precise,
it moves one step whenever the game time modulus 3 is 2. When you give a move
instruction to make the bot move in a particular direction but the bot is not
facing that direction, it will take some time to face that direction. A bot
turns twenty degrees whenever the game time modulus 3 is 2.
The concept of a bomb: A bomb can be dropped with a range between
zero and 20. A bomb explodes in 4 stages as its radius increases from 0 to 3.
The stage of explosion changes whenever the game time modulus 3 is 2. A nearby
bot will suffer damage whenever the stage of explosion changes. Stage 1 will
cause a damage of 4 to a bot which is at the exact location of the bomb, Stage 2
will cause a damage of 3 to bots which are at a distance less than or equal to 1
unit from the bomb, stage 3 will cause a damage of 2 to bots at a distance less
than or equal to 2 units and stage 4 will cause a damage of 1 to bots at a
distance less than or equal to 3 units.
It is also important to know that bombs can be thrown over walls. You can use
this concept for stealth bombing. One bot will see the enemy from a distance and
send his coordinates to his team member, who will drop a bomb on that enemy from
behind a wall.
Note that the effect of bombs will be felt through walls. A bomb exploding on
one side of a wall will cause damage to a bot on the other side.
Program termination
The worst thing that could ever happen in a aibots game is termination of the
driving program. It is a programmers nightmare. So beware of it and take
necessary steps to prevent it. In AI Bots II a program termination will remove
the bot from the arena and it will also be penalised. Program termination is
usually caused by the following:
1. Normal program termination will occur whenever the main function of the
driving program exits. Check your program flow properly to prevent this kind of
termination. This type of termination can be avoided very easily.
2. Abnormal program termination will be caused whenever there is a NULL pointer
assignment or your program tries to access a memory location that is not
allotted to it ( segmentation fault ). This error is very difficult to detect
and debug. You need careful examination of the code to spot this error.
3. Whenever a driving program makes a request that the combat server can not
understand, the driving program will not be terminated but any further requests
from it will be ignored and the bot will be disqualified and penalised
similarly. This error will occur only if you try to use sockets (it is illegal
for driving programs to use sockets, multi threads, etc ) and do it the wrong
way.
It is highly difficult to tell whether an abnormal termination will occur or
not. It is even more difficult to tell when it will occur. So test your
program as many times as possible. In Shaastra 2002, a driving program
qualified till the finals without any glitch, but ended up in the second place
because it had an abnormal termination during the tie-breaker for the first
place. There were other nice programs that had some nice strategies but they
could not make it to the first place because they had abnormal terminations in
the final round. So a good strategy is not enough; error free coding is also
necessary.
The samples
The samples are given to explain the usage of the bot functions and the conepts.
These are not typical driving programs. They are not designed to win. Most of
the samples are ripped from the previous version of the game. See the Readme
file in the samples directory for further details.
Introduction
| Driving program
| Tips
For bugs, queries and suggestions contact :
Arunkumar Subramanian
ee01b115@ee.iitm.ernet.in
(regarding the game engine and the text and graphics displays in Linux)
Sandeep V
ee01b119@ee.iitm.ernet.in
(regarding OS independence and Windows text display).