Apocalypse Now 2018

Omer Giménez, Jordi Petit, Enric Rodríguez, Salvador Roura

Game rules

Game parameters

A game is defined by a board and the following set of parameters:

Parameter Value Description
@NUM_PLAYERS @ 4 Number of players
@GAME_ROUNDS @ 200 Rounds that the game lasts
@MAX @ 60 Number of rows and columns of the board
@NUM_SOLDIERS @ 20 Initial number of soldiers per player
@NUM_HELICOPTERS @ 2 Number of helicopters per player
@NUM_POSTS @ 16 Total number of posts
@LIFE @ 100 Initial life points of soldiers
@FOREST_DAMAGE @ 20 Minimum damage per attack at forest
(maximum damage: the double)
@GRASS_DAMAGE @ 50 Minimum damage per attack at grass
(maximum damage: the double)
@ROUNDS_NAPALM @ 30 Rounds before napalm is available again
@REACH @ 2 Napalm is thrown in the square (2*@REACH@+1)×\times (2*@REACH@+1)
centered at the helicopter
@FOREST_BURNS @ 10 Rounds that a forest cell burns
@OTHER_BURNS @ 5 Rounds that any other cell burns
@PROB_FIRE @ 10 % of probability of propagation of fire
@ROUNDS_JUMP @ 20 Maximum number of rounds to jump
@MAX_JUMP @ 4 Maximum number of parachuters of a player
who can jump in the same round
@HIGH_VALUE @ 100 Value of the most valuable posts
@LOW_VALUE @ 50 Value of the least valuable posts

Unless there is a force majeure event, the above values of the parameters are the ones that will be used in all matches of the game.

Programming

The first thing you should do is to download the source code. This source code includes a C++ program that runs the matches and also an HTML viewer to watch them in a nice animated format. Also, a “Null” player and a “Demo” player are provided to make it easier to start coding your own player.

Running your first match

Here we will explain how to run the game under Linux, but a similar procedure should work as well under Windows, Mac, FreeBSD, OpenSolaris, …The only requirements on your system are g++, make and a modern browser like Mozilla Firefox or Google Chrome.

To run your first match, follow the next steps:

  1. Open a console and cd to the directory where you extracted the source code.

  2. Run

    make all

    to build the game and all the players. Note that Makefile identifies any file matching AI*.cc as a player.

  3. This creates an executable file called Game. This executable allows you to run a match using a command like:

    ./Game Demo Demo Demo Demo -s 30 -i default.cnf -o default.out

    In this case, this runs a match with random seed 30 where four instances of the player “Demo” play with the parameters defined in default.cnf (the default parameters). The output of this match is redirected to the file default.out.

  4. To watch a match, open the viewer file viewer.html with your browser and load the file default.out. Or alternatively use the script viewer.sh, e.g. viewer.sh default.out.

Use

./Game --help

to see the list of parameters that you can use. Particularly useful is

./Game --list

to show all the registered player names.

If needed, remember that you can run

make clean

to delete the executable and object files and start over the build.

Adding your player

To create a new player with, say, name MyPlayer, copy AINull.cc (an empty player that is provided as a template) to a new file AIMyPlayer.cc. Then, edit the new file and change the

@#define PLAYER_NAME Null@

line to

@#define PLAYER_NAME MyPlayer@

The name you choose for your player must be unique, non-offensive and less than 12 letters long. It will be used to define a new class @PLAYER_NAME@, which will be referred to below as your player class. The name will be shown as well when viewing the matches and on the website.

Now you can start implementing the method @play()@. This method will be called every round and is where your player should decide what to do, and do it. Of course, you can define auxiliary methods and variables inside your player class, but the entry point of your code will always be this @play()@ method.

From your player class you can also call functions to access the board state, as defined in the @State@ class in State.hh, and to command your units, as defined in the @Player@ class in Player.hh. These functions are made available to your code using multiple inheritance. The documentation on the available functions can be found in the aforementioned header files. You can also examine the code of the “Demo” player in AIDemo.cc as an example of how to use these functions. Finally, it may be worth as well to have a look at the files Structs.hh for useful data structures, Random.hh for random generation utilities, Settings.hh for looking up the game settings.

Note that you should not modify the @factory()@ method from your player class, nor the last line that adds your player to the list of registered players.

Playing against the “Dummy” player

To test your strategy against the “Dummy” player, we provide the AIDummy.o object file. This way you still will not have the source code of our “Dummy”, but you will be able to add it as a player and compete against it locally.

To add the “Dummy” player to the list of registered players, you will have to edit the Makefile file and set the variable DUMMY_OBJ to the appropriate value. Remember that object files contain binary instructions targeting a specific machine, so we cannot provide a single, generic file. If you miss an object file for your architecture, contact us and we will try to supply it.

You can also ask your friends for the object files of their players and add them to the Makefile by setting the variable EXTRA_OBJ.

Restrictions when submitting your player

Once you think your player is strong enough to enter the competition, you should submit it to the Jutge.org website (https://www.jutge.org). Since it will run in a secure environment to prevent cheating, some restrictions apply to your code:

Tips