Hardcore Programming Compo Case - "Submerged Temple"

Summary

Create an artificial intelligence that plays a game called "Submerged Temple", described here. Two players competes to collect as many gold coins as possible in a temple that is completely filled with water. The goal is to collect as many gold coins as possible, but at the same time make sure that the player doesn’t run out of air.

There are movable crates in the temple that can be used to block your opponent from collecting the treasures. To survive in the submerged temple you have to find air bubbles and make sure your path doesn’t get blocked by your opponent.

Go to competition rules

Downloads

How to compete

Create your entry as one of the following:

  • A C++ source file (.cpp)
  • A Java source file (.java)
  • A C# source file (.cs)
  • A Python source file (.py)
  • A PHP script (.php)

Entries in C++ must compile with Visual C++ 2008 the following way:

  • Visual C++: Your file will be added to an empty Win32 Console Application project and built from there.

There is no need to include your own project file.

Make sure your entry compiles with the following rules:

  • The source code of your program should be in one single file in your language of choice. (for those languages that have a predefined abstract class that you implement, that file won't count)
  • When your program is started it should read data from the standard input (stdin). This data describes the game state (see bellow).
  • The program output should be exactly one character plus newline to the standard output (stdout), for each move. This character represents the direction you want to move on the map (see details below).
  • Your program should not save anything between different executions except internal variables. Do not write to disk or in any other way try to save information persistently. If your program uses an extreme amount of memory for this purpose, your entry may get disqualified. Contact the compo crew if in doubt (demo@gathering.org).
  • Your entry should never use more than than one second to process each move, no matter what language you use. If the execution time exceeds this limit, you loose your chance to make a move, and your program may get killed. This should be more than enough, don't try to push it. We have tested different AI's without any problems.
  • Your program must not depend on any external library or file except the standard library of your language.
  • Multi-threading is not allowed, even if supported by the standard library of your language.

How the game works

"Submerged Temple" is played in a grid of NxM cells. This grid is sent to your application through the standard input stream. In this kit you'll find example code that parses this stream into a data structure appropriate for the language. Each grid cell contains one of the following values:

  • ' ': An empty cell
  • '1' or '2': Your or your opponents position.
  • '#': A blocked cell (walls)
  • 'M': A cell/block that can be moved
  • 'o' : A coin
  • '.' : An air bubble

A very simple example level can look like this:

# # # # # #
# # o 2 . #
# 1 # # M #
# . o . #
# #
# # # # # #

In this kit you'll find more complex example levels. However, the levels that will be used in the compo can be much larger and look completely different. Maximum size for a level is 64x64. Your AI should not try to optimize for this particular level, but general levels of this type.

You start with 0 points and 15 air points. The game proceeds in turns until all of the gold coins are found or when you run out of air bubbles, leaving you with a final score. The air bubbles you collected during the game do not affect your final score.

Each turn, the following happens:

  1. Your program is run (if it isn't running already), and you receive the following ASCII characters on the standard input stream:
    1. The first line contains information of which player you are as a number, 1 or 2.
    2. The second contains the amount of air you have left, as a number of moves left before you drown (unless you find more air bubbles before your time runs out).
    3. The third line contains your current score.
    4. The fourth contains map width
    5. The fifth contains map height
    6. The remaining lines holds the current map
    7. The last line contains ‘;’ to end this round. When you find ‘;’ – you must decide which move you want to make and write that to the standard output. In the next round, you’ll return to the first point and continue to read from standard input.
  2. Your program outputs the direction you want the player to move. This must be one of the following characters:
    • 'N': Go north (upwards)
    • 'S': Go south (downwards)
    • 'W': Go west (left)
    • 'E': Go east (right)
  3. Your position, '1' or '2', is then moved in the direction returned by your program to a target cell. These are the possible outcomes:
    • If the target cell contains a wall, '#', the move is blocked, and the player ('1' or '2') is returned to the previous cell.
    • If the target cell contains a coin, 'o', the score increase with 1 point, and the target cell is converted to an empty cell as the player moves to another cell.
    • If the target cell contains an air bubble '.', the amount of air points will increase to 15, and the target cell is converted to an empty cell as the player moves to another cell.
    • If the target cell contains a movable cell ‘M’, the block will be moved to the next empty cell if that cell is not already occupied by a wall or an opponent. If the next cell contains an air bubble or a treasure chest, the block will switch place with it.
    • If the target cell is empty ‘’, nothing happens.
    • If your program fails to write its response to the standard output stream within the time limit, nothing happens.
    Regardless of the outcome of the move - the player loses 1 air point after each move. The game is over for your part when a you reach 0 air points, and the number of the collected gold coins is your final score. Your opponent can continue to play until he/she runs out of air or collects the rest of the available gold coins. Your program will be terminated by force by the simulator application if you don’t terminate it yourself when this occurs.
  4. Then the opponent's AI runs in the same way.
    Note: The game is turn based. One player "thinks", then acts, then the next player does the same. Moves are not simultaneous.

Remarks:

  • You are free to store states between each move, your program will not terminate between each move (the way it did in the case from last year).
  • The air point increase TO 15, not BY 15, when you find an air bubble. You can never have more than 15 air points at a time. If you collect an air bubble when you already have 15 air points, you still only have 15 air points.

About the development kit

This kit contains the following files and folders

SubmergedTemple.exe

This is the simulation application which contains the game logic and works as a server application for the AIs. It's written in Java, so you'll need to have Java installed to be able to run it. When you start the application, you'll get a user interface where you can set up which AIs that are going to play against each other. You may also use the arrow keys or "WASD" keys to manually move one of the players.

SubmergedTemple.sh

This script let you run the simulator on Linux.

AI

This folder contains setups for the different languages that you may use as a base for your own AI.

bin

This folder contains various programs that the simulator needs in order to run the entries in different languages.

map

This folder contains the levels that can be used in the game. There are some levels included, but you may also make your own levels. It's recommended to make some more advanced levels in order to test your AI in different situations.

Help and support

If you have any questions regarding this competition, you may:
  • Ask the question in the Gathering forums in the Hardcore Programming Compo Support Thread
  • Send an email to the compo crew (demo@gathering.org). If your question is of public interest, you will be prompted to ask your question again in the forum support thread.