Home
Download
Documents
About
|
Write your own AIs
Virtual Fight use client/server style. AIs must connect to the
server to start fighting! AIs can be in any language. Each AI is
a group of five warrior. AIs can control their warriors by sending
commands to the server.
This is not a real-time-battle. Its just like turn-base-strategy
games. Its mean an AI play its turn, and wait for others to do so.
So Its not that much important that your AI is how much fast.
Port
Default port for server is 4500, and GUIs can be connected to
4550.
You can use telnet for testing commands.
Commands Format
Commands are in a format like this:
n&Command[&Direction]
- n: Number of warrior.
- Command: can be one of
'MOVE',
'SHOOT',
'POS',
'DIR',
'SAW',
'NONE'
- Direction: can be one of
'UP',
'DOWN',
'LEFT',
'RIGHT'
'n' is the number of the warrior you want send command to.
Warriors numbers are start from 0 to 4.
'Direction' is needed only for
'MOVE'
and 'SHOOT' commands, but
'NONE'
command can either have this option or not.
Commands are NOT case sensitive.
1&MOVE&DOWN is equal to
1&mOvE&DOWn
Commands
'MOVE'
: Move a warrior among specific direction. For
example:
4&MOVE&LEFT
will move warrior number 4 to left.
Very simple, isn't it?
'POS' : Get the position of a specific warrior.
For example if an AI send 0&POS
to the server, server will
return somthing like 3,14
in the image below, position of the warrior is 4,4
'DIR' : Get the direction of a specific charachter.
For example if an AI send 2&DIR
to the server, server will return
LEFT. In the image below, direction of
the warrior is UP.
'SAW' : Get what is in sight of a specific charachter. See
image below, warrior can see green squares.
If this warrior send 'SAW' command to the server, server will
return:
2,5,E&1,3,#
Its mean there is an enemy in 2,5 and there is a wall in 1,3
Notic that warrior can't see the enemy on his right.
Objects that an AI will receves are:
E: emeny.
O: his teammate.
#: wall.
x: dead body.
'SHOOT' : Shoot your gun!
For example if AI send 2&SHOOT&LEFT
to the server, warrior number
two will shoot to his left. 'SHOOT'
command can either have
direction or not. If you use this command with direction, warrior
will change its direction then shoot. If you use this command
without direction, warrior will shoot straight. Shot will goes
three squere straight line.
'NONE' : Do nothing! Just stand there and watch!
This command can contain direction. For example if you don't want
move your warrior number one, but want to see what is in his
right, you can send: 1&NONE&RIGHT
(change direction to the right without moving) and then
1&SAW
Server Messages
OK message
If server do a command successfully, it will return
255.
For example, if AI send 1&MOVE&UP
, and warrior number one can
move up, server will return 255
to the AI.
But there is an exception. If an AI send 1&none
to the server,
server will return 255. If this AI send 1&none another time, it
will return 255 again, not
120. It's because
'NONE' command do
nothing. But if this AI send 1&none&up
, it will receve 120.
(because of none&up do a thing!)
Doing 'SHOOT' command
If AI send 'SHOOT' command, server will
immediately return 255,
but don't shoot at the same time. When all of the AIs send their
movements, then server will proccess shoot commands and send the
result to the AIs. In this way, if a warrior try to kill an enemy,
and at the same time enemy move to another location, enemy will
survive! (don't forget that this is a turn-base game.)
After a turn, server will send result of shooting to the AIs.
It send '200' message to the AI, then
result of shooting.
For example if warrior number one hit nothing, (shoot to empty
space) server will return:
1&HIT&NOTHING
if he shoot to a wall, or a dead body:
1&HIT&WALL
if he kill an enemy:
1&HIT&ENEMY
Or if he kill one of his teammates:
1&HIT&OWN
If some one kill AI warrior, the AI will receve:
1&KILLED
Errors
If you send a bad command to the server, you will receve error.
The error numbers are:
100 | Invalid command.
111 | The destination is not empty.
112 | Charachter wants to move out of
screen.
120 | Charachter which moved before.
For example if you send 1&MOVE&UP
to the server, you will
recevie 255, and when you send 1&MOVE&LEFT again, you will receve
120. Because a warrior can't move twice
in a single turn.
OK and READY messges.
When an AI connect to the server successfully, server send OK
message to it. At the end of each turn (and in the start of the
game)
server will send READY to all of the AIs. Before sending first
READY (game start) server don't accept any command.
Writted by Aidin Gharibnavaz, 15-Jul-2006
Last update, 3-Aug-2006
|