| |
INFO
Index
- Brief Description of the Game
- Example of Warrior Script
- Historical Background
- Why SMALL Language Scripts?
- About the APOCALYX 3D Engine
Brief Description of the Game
The game consists in a fight among teams (from 2 up to 4) of warriors
(from 64 bots down to 1).
The warriors move in a complex environment with walls that may be flat or
include ramps, bridges and two or more floors.
A warrior slides along the walls
maintaining its movement attitude, but it suddenly stops when hits another warrior.
Warriors have a brain that consists in a CPU with a clock frequency of 10KHz and a RAM with
a memory size of 32Kb. They are equipped with one gun that fires bullets
and
grenades. The number of bullets loaded at the beginning is 50 with a maximum
of 100,
while grenades are limited to a maximum load
of 3 and initially the gun has only one of them, but recharges are provided on the battlefield,
as well as barrels of bullets.
Every warrior has an initial amount of health, energy and armor. Health starts from the maximum, 100, and decreases when the warrior hits a bullet, 50 points per
hit, or a grenade explodes nearby. In the latter case the health lost
depends on the distance from the explosion up to 5 meters. When a warrior reach zero or less health, it
is disabled. Energy starts from 50, while the maximum is 100. It decreases 2 units per second when the warrior runs, increases 1 unit per second when the warrior is standing
or is crouched and keep its current value when the bot walks forward, or backward,
or crouched. When the energy reaches zero, the warrior can't run, but
can still walk. The Armor
value starts from 0, while the maximum is 100. Armor gives protection from hits decreasing the damage proportionally to its value, but every hit reduces at the same time the armor
value. Recharges for health (medikits), energy (food) and armor
(full-metal jackets) are available on the battlefield. When a recharge is
raised by a bot, it disappears from the battlefield but is respawned after a
certain amount of time.
Warriors may rotate their forward direction around their vertical axis, rotate and bend the torso up to specific values, rotate and bend the head up to specific values. The gun and its aim device are linked to the torso and follow its movement, while other sensors to watch and hear and the device to speak are linked to the head.
Among the others described in the documentation, some of the main functions available to warriors to interact with each other and with the environment are:
- bool:say(int:word)
it is used to communicate with the other bots. A warrior can "say" a word,
that corresponds to an integer value, every half a second.
- float:hear(&item,&sound,&float:yaw,&float:pitch,&float:id)
useful to hear gun shots, grenade explosions or words spoken by nearby warriors.
The nearest sound is reported with its type, distance and
direction (yaw and pitch angles). Every "hear" takes 0.04 seconds.
- float:sight()
it is used to get the distance of the walls in the direction in front of the head.
Every "sight" takes 0.01 seconds.
- float:aim(&item)
the same as sight(), but gets the distance of the walls in the direction of the gun or the distance of the nearest warrior between the gun and the
wall using a sort of laser beam (the aim device). Every "aim"
takes 0.04 seconds.
- int:watch(&item,&float:dist,&float:yaw,&float:pitch,&float:id)
useful to see the objects, not walls, around the warrior. Only the nearest object farther than a given distance is reported with its type, distance and direction. An object must be in front of the head within a characteristic angle of view
(60 degrees or PI/3 radians) to be seen. Every "watch" takes 0.04 seconds.
A match lasts for a certain duration (from 1 minute up to 1 hour) and this and
other values may be changed by the user. There are several condition for victory
the first of which can be selected by the player. They apply in the following order:
The winner is the team that...
- a) "terminates the enemy
chiefs", that are the warriors that carry the team sign. All
the chiefs of the enemy teams must be disabled. Chiefs can't drop the sign so
they are easily recognizable and their team mates must protect them, while
they also try to
hit enemies.
b) "terminates the enemy teams". All the warriors of
the enemy teams must be disabled to win. When this goal is active the chiefs
hold a weapon and not a sign.
c) "captures the enemy sign".
The warriors of a single team must capture the sign of all the other teams to
win, or alternatively disable all the enemies. The chiefs hold a sign at the
beginning but can drop it to raise a weapon.
... or, if the timeout is reached, ...
- has more team mates at the end of the match
- has terminated more enemies at the end of the match
- has more overall health at the end of the match
- has more overall energy at the end of the match
If none of the above conditions matches, the match resolves in a draw.
The winning conditions described above apply to 3 different modes of play: Fight
mode, Soccer mode and Race mode.
- Fight mode and its characteristics were already explained at the
beginning of this section. Warriors hold a weapon so they can shoot
bullets or grenades. Health, energy and the other warrior's properties
change according to the rules cited above. This was the first mode of play
implemented in GUN-TACTYX and the game includes 3 levels (arena, plaza
and maze) that are tailored for fights.
- Soccer mode is a particular kind of play where warriors don't
hold any weapon (but weapons may appear in the level and warriors may use
them). When this mode is active, a ball appears in the middle of the level
at the point of coordinate (0,0,0). Warriors can hit the ball simply
moving towards it. When a warrior hits the ball with its bounding box, the
simulator resolves the collision according to these rules:
a) if the ball hits the warrior's torso, it simply bounces
following the laws of elastic collisions, considering the normal vector
that goes from the center of the warrior to the ball. The speed of the
warrior is taken in account to compute the final speed of the ball.
b) if the ball hits the warrior's legs, it bounces as above but
also an additional "kick" velocity is added. The direction of
that velocity is given on the horizontal plane by the normal vector that
goes from the center of the warrior to the ball, while the vertical
component is given by the inclination of the warrior's torso. If the torso
points up with a certain angle, the "kick" velocity will acquire
an initial angle that points up. The speed of the "kick" is
selected by the warrior through the function setKickSpeed() and its
default maximum value is 5 m/s. When a "kick" is
performed, the ball bounces around losing a percentage of its speed equal
to getGroundRestitution() after every collision with the geometry
of the level, the restitution has a default value of 80%.
The objective of every team of warriors is to send the ball in the goal
area of enemy teams. The enemy area is located at the starting point of a
team and is sphere shaped. A warrior can retrieve information about enemy
goal areas through the function getGoalLocation(), with index 1, 2
or 3 as argument for the first, second and third enemy teams, and getGoalSize(),
that returns a default value of 7.5 m for the diameter of the
sphere. When the ball enters the goal area of a team, the warrior of that
team nearest to the goal area is immediately disabled and the ball becomes
a grenade that explodes in 3 seconds, while another ball suddenly appears
in the middle of the field. The "kills" are assigned to the
warrior that last touched the ball. Other behaviors of this mode are
similar to the Fight mode, including the rules to find out the
winner. This was the second mode of play
implemented in GUN-TACTYX and the game includes only one level (field) that
is tailored for Soccer matches.
- Race mode is another particular kind of play where warriors don't
hold any weapon (but weapons may appear in the level and warriors may use
them). When this mode is active, the objective of the warriors is to move
around the origin (the point with all coordinate equal to zero) in the
counter-clockwise direction (watching from the top) avoiding the obstacles
of the level. When a warrior move in the wrong direction, it loses health,
while moving in the right direction increases its health. A complete turn
around the origin gives an overall amount of health equal to 100. When a
warrior reaches 100 points of health, it does not increase its health any
more but all the other warriors decrease their health of the lacking
amount. Another rule that is different from the other modes of play is the
following: When two warriors collide, the one with the lowest health is
disabled. Other behaviors of this mode are similar to the Fight
mode, including the rules to find out the winner. This was the third mode of play
implemented in GUN-TACTYX and the game does not include yet any level tailored for
Race matches or examples of tactics suitable for this modality in
the sample scripts. A level for Race matches should provide an
obstacle in the middle around which the warriors must run: A
possible choice already included in the game may be the maze level,
but a more complex path, several obstacles and energy recharges make
matches more interesting.
To change mode or goal, enter the options panel, pressing '0' (zero)
when the game shows the main panel, and change the corresponding
entries according to your needs.
This is only a brief overview about the game.
Read the documentation included in the game package for more details.
If you have any question, contact me at tetractys@users.sf.net.
Index
Example of Warrior Script
The warriors in the GUN-TACTYX arena are controlled by SMALL scripts. The interface
to the surrounding environment is given by a schematic but realistic set of functions. The value
assigned to some arguments and returned values are specific to the current implementation of the game and may change in future releases, but the API and its specifications are
very likely fixed once for all. Returned values may also change when a player
configure the arena using scripts.
A player compiles the source code of his bot (for example "rookie.sma")
using the 's' command of the console built in the game - invoke it pressing the
[F3] key - or using the command line program "sc.exe" stored in the "/bots"
folder of the game. Type in a DOS window: sc rookie.sma and
you'll get the compiled
file "rookie.amx". A sample of a simple script is the following:
/* "rookie.sma" - simple control code for a team of warriors */
#include "core" // include core functions
#include "math" // include math functions
#include "bots" // include bot specific functions
main() { // the main entry point of the script
// defines a value to recognize enemy warriors
new const ENEMY_WARRIOR = ITEM_WARRIOR | ITEM_ENEMY;
// specifies a time limit to force a change in direction of the warrior
new const float:MAX_TIME = 10.0 // note the "point" in the constant
new float:lastTime = getTime()
// loops forever (or better, until the bot dies)
while(true) {
new float:thisTime = getTime()
if(thisTime-lastTime > MAX_TIME) {
// changes direction at random every MAX_TIME seconds
lastTime = thisTime
new float:randAngle = float(random(21)-10)*1.5708
rotate(getDirection()+randAngle)
} else if(sight() < 5.0) {
// if the warrior is within 5 meters from a wall,
// change slightly its direction
rotate(getDirection()+0.31415);
} else {
// give a look for the nearest enemy
new item = ENEMY_WARRIOR;
new float:dist = 0.0
new float:yaw
watch(item,dist,yaw)
if(item == ENEMY_WARRIOR) {
// Found one enemy!
// Do you walk? Stop!
if(isWalking()) stand();
// Do you run? Walk!
else if(isRunning()) walk();
// Rotate towards enemy direction adding
// the current direction (absolute) to the
// enemy direction (relative to the head)
rotate(getDirection()+yaw);
// aim and see what is in front of the gun.
new item
aim(item)
// It's an enemy, shoot!
if(item & ENEMY_WARRIOR == ENEMY_WARRIOR)
shootBullet()
} else {
// Can't find any enemy!
// Do you walk? Run!
if(isWalking())
run();
// Are you standing?
else if(isStanding()) {
// Maybe you collided into someone...
if(getTouched() & ITEM_WARRIOR != 0)
// if that is true, make a quarter turn...
rotate(getDirection()+1.5708);
else
// ... otherwise walk.
walk();
}
}
}
}
}
The script above makes use of a low number of the available functions. Other
sample scripts are available in the "\bots" folder of the game.
The complete list of the functions is available in the documentation included in the game package with some explanation that
specifies also the parameters of the warriors and some characteristic of the environment in the current implementation.
Index
Historical Background
GUN-TACTYX (read it like gun tactics) is a "CROBOTS-like game with QUAKE3-style graphics". It belongs to the genre of Programming Games like Tom Poindexter's CROBOTS, and old 1985 DOS game, where some robots fight in an arena, firing missiles and avoiding enemies' projectiles. Such kind of games is involving, but it is not interactive, in fact the player must develop the AI algorithms of his own robot using a programming language and then can follow its fights against other robots, possibly written by other players.
A great deal of these kind of games is available for download on the internet, most of them for free. An online example is my JROBOTS and you can visit its site, twin site of GUN-TACTYX, hosted by SourceForge. JROBOTS is a clone of CROBOTS with interesting features. While a player of CROBOTS had to use a subset of C to program his
robot (using only integer math because of the limitations of 1985 PCs), a player of JROBOTS uses the Java language and the robot consists of a single Java
class (visit http//:www.javasoft.com for more details about the Java language). A player can upload
the corresponding file to the on-line arena to compete in monthly tournaments against robots developed by other players. One of the most appealing characteristics of JROBOTS is the cooperative play, in fact, while the original CROBOTS had only
one-against-all kind of matches, JROBOTS supports matches among team of robots, from doubles to four
teams of eight robots each at a time.
During the past tournaments, since April 2000, a large number of interesting jrobots were uploaded online and they featured several different strategies that evolved with time.
Some months ago (September 2003) the arena was split in two categories, veterans and cadets, and
the major league is dominated by IonStorm, the strongest and more tuned
jrobot ever seen in the arena, written by Alan Lund from Eau Claire, WI, USA.
Even if JROBOTS is a great game in its genre, it has some limitations. First of all, for security reasons the players can't use any of the Java APIs, because the tournaments run on-line in Java applets hosted by the browser of the visitors. The latter could be a feature of the game, just like the reduced size (20Kb) of the class
file that contains the code of the robots and other rules of the same kind that makes the game more difficult for the players, but another issue
menaced the reliability of the game since the early beginning. Every robot loaded in the arena has a Java thread assigned that runs its code. The environment of the Java Virtual Machine doesn't provide any effective tool to control the execution of Java threads,
so different CPUs, OSes and JVMs ran the simulation of the matches more or less differently
favoring from time to time one or the other jrobot and invalidating the reliability of any testing phase conducted on a
single machine. The problem was caused by the thread-based design of the game, rather than turn-based as other game of this kind are, and a solution was found thanks to some of the most effective JROBOTS players
(Walter Nistic̣, author of another strong jrobot called KillerBees,
in collaboration with the already cited Alan Lund). They developed a "Virtual Clock Generator" that ticks the time of the simulations and
smoothes the behavior of different machines.
Anyway, since the beginning I wished to develop another game with the strongest points of JROBOTS, but at the same time graphically appealing, with an easy to control execution environment and a more realistic simulator. After a long list of failed
attempts, the answer to my wishes seems to be GUN-TACTYX.
To get the complete history of JROBOTS and more recent news or to participate
to the monthly on-line tournaments, visit its site at SourceForge (http://jrobots.sourceforge.net/).
Index
Why SMALL Language Scripts?
In GUN-TACTYX, the player must develop the AI algorithms of his team of bots using the SMALL scripting language. In the documentation included in the game package you can find a complete manual about the use of SMALL to create scripts that control the bots'
behavior. The SMALL language is a powerful scripting language easily extendable and embeddable in other applications. We limit ourself to the features that are useful to create GUN-TACTYX scripts, but
plenty of other possibilities are available. To know more about SMALL visit the site of ITB
CompuPhase (http://www.compuphase.com).
A SMALL interpreter can run instruction by instruction the bytecode generated by a compiler and provides a fine control of the execution. It is very easy to execute the code for any amount of ticks of (virtual)
CPU clock, suspend the execution starting the run of other code, resume it and simulate the heaviness (in clock ticks) of particular functions. As a consequence, all the bots of the game use the same amount of time to perform the same actions, saving the reliability of the simulation. Turn-based mechanisms, such as voluntary calls to functions
that release the execution of the bot's code, are no more needed.
Another advantage of a SMALL interpreter is the memory management. Every bot has a fixed amount of memory to store all the information that it needs
(stack and heap space). It is no more possible for a bot to use large sizes of the application memory, mining the reliability of the
program itself. The SMALL compiler ("sc.exe") translates sources
written in a C-like language (".sma" extension) in a particular
bytecode (".amx" extension). That kind of C-like language is very easy to learn for people who already knows Java, C, C++, C# or other
programming languages,
and may introduce inexperienced people to procedural programming. GUN-TACTYX includes a command-line console from which
you can compile and execute (GUN-TACTYX unspecific) SMALL scripts. To activate the console, press the 'F3' key during the execution of the
application. When a script is in execution, you can read all the messages
generated on the console.
Index
About the APOCALYX 3D Engine
GUN-TACTYX is a game based on the APOCALYX Engine. The use of an OpenGL 3D engine increases the hardware requirements of the application, in fact an accelerated 3D graphic card is absolutely necessary to follow the fights, but at the same time makes the game more
graphically
appealing. The engine is compatible with a simplified version of the resources used by Quake III (MD3 models and BSP levels), that's why I say that GUN-TACTYX is a "CROBOTS-like game with QUAKE3-style graphics".
APOCALYX is a 3D engine in development based on OpenGL and other free libraries. Its sources are available under the GPL license at http://apocalyx.sf.net. The engine already includes basic features, such as lens flares, sky boxes, height field terrains, wavy surfaces, a
scene graph, sprites and billboards, a particle system, 3D sound, compressed data management,
loaders of several image formats, MD3 models loader and animator, BSP levels loader, a simple physics simulator, support for LUA and SMALL scripting languages and other more advanced
characteristics are planned. The current implementation supports only Win98 (or higher) with an accelerated graphic card and OpenGL drivers installed. I wish to thank all the people who helped in developing this engine. First of all, I must thank
Matteo "Fuzz" Perenzoni and his Apocalypse demo written for the
2001 NeHe's Apocalypse Contest: The sources of his demo were the starting point
that made possible to develop the APOCALYX renderer and many nice effects. Then I must thank a
good deal of great internet resources about game programming: News Portals, such as GameDev, FlipCode, CFXweb,
Game Programming Italia and OpenGL.org, and Game Tutorials Sites, such as NeHe, Game Tutorials, SULACO and many others. Finally, I wish to thank
Grant Struthers and Janus for providing the models of the warrior and the weapon used in GUN-TACTYX.
They resources are hosted by PolyCount.
To know more about APOCALYX, visit http://apocalyx.sourceforge.net.
Index
| | |