image

Àlex Moré Guardiola

Rules

Poquémon is a game based on the Japanese video game saga Pokémon1.

Each player controls a number of Poquémon. The goal of a player is to get the maximum score by collecting point bonuses and killing opponent Poquémon.

A match of the game consists of a number @nb_rounds()@ of rounds. In each of these rounds, Poquémon can move around a rectangular board. Cells in this board may be occupied by a Poquémon or contain bonuses of several kinds, or be a wall (which Poquémon cannot cross), or be empty.

Whenever a Poquémon moves to a cell with a bonus (for instance, a point bonus), it collects it; in this case, after some rounds the bonus appears again in a random cell of the board.

The board will always be surrounded by walls. Some walls may appear and disappear along the game. These are called ghost walls and cannot be placed in the perimeter. These ghost walls are located on the board and may be present or hidden. Every @wall_change_time()@ rounds every ghost wall will change its state (present, or not present) but it is not necessary that all board’s ghost walls change at the same round. In other words, they have the same period but not the same phase. If a Poquémon is located in a position where a ghost wall appears, it dies. To know if there is a ghost wall at a certain position P you can use ghostWall(Pos p) function, which returns the remaining rounds to change the state of the wall or -1 if this cell is not a ghost wall.

In each round, a Poquémon can also attack another Poquémon and wage a battle. As a result, the attacked Poquémon can die. Each Poquémon has some attributes that are considered in a battle: attack, defense and scope. These attributes can be improved by collecting respective bonuses (attack bonus, defense bonus, scope bonus and stone bonus, a special bonus that improves all Poquémon’s stats). The scope of a Poquémon and the number of stones can be collected are limited.

Any dead Poquémon will appear again after @player_regen_time()@ rounds in a position that guarantees that an action can be performed in the next round.

As pointed out above, there are two ways to get points. A player can collect point bonuses of the board or kill opponent Poquémon and win the @battle_reward()@ percent of the total points of the opponent.

Viewer

In the following image we can see a screenshot with most of the elements that are present in the game:

image

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 HTML5/Javascript viewer to watch them in a nice animated format. Also, a ”Demo” player is 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 Chromium.

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 the Makefile will identify as a player any file matching the expression ”AI*.cc”.

  3. The call to make should create an executable file called Game. This executable allows you to run a match as follows:

    ./Game Demo Demo Demo Demo < default.cnf > default.res

    Here, we are starting a match with 4 instances of the player ”Demo” (included with the source code), with the game configuration defined in ”default.cnf”. The output of this match will be stored in ”default.res”.

  4. To watch the match, open the viewer (viewer.html) with your browser and load the ”default.res” file.

A script run.sh for carrying out steps 2-4 automatically is also provided.

Use the --help option of Game to see a list of all options you can use. For instance, the option --list will show a list with all the available player names.

If needed, remember you can run make clean to delete the executable and all object files and start over the build.

Adding your player

To create a player, copy the file AINull.cc (an empty player that is provided as a template) to a new file with the same name format (AIWhatever.cc).

Then, edit the file you just created and change the playername line to your own player name, as follows:

@#define PLAYER_NAME Whatever@

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 @Board@ class in Board.hh, and to command your units, as defined in the @Action@ class in Action.hh. These functions are made available to your code using multiple inheritance via the class @Player@ in Player.hh . The documentation on the available functions can be found in the aforementioned header files of each class. 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 file Utils.hh for useful data structures.

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 available 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.

Pro tip: You can ask your friends for the object files of their players and add them to the Makefile too!

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


  1. More info in http://www.pokemon.com/us/↩︎