Angry Mob

Game rules

Angry Mob is a turn-based strategy game on the board where two players draw their moves simultaneously. The map and the exact state of the game are known to each player at the every moment.

Map description

The map is a h × w matrix. Each cell can be passable or impassable. Any passable field can contain a number of units of each kind. There are three kinds of units: units belonging to the first player (player 0 - blue), units belonging to the second player (player 1 - red), and neutral units (gray). Two distinct cells are marked as bases, each player having one base.

Bases are always passable cells, and they do not contain neutral units. Initially, before the first move, each player has exactly one unit, located in their base. Passable and impassable cells, initial numbers and locations of neutral units, and the location of the bases are all centrally symmetrical relative to the center of the map. Two cells are neighboring if they have a common side (thus, each cell can have at most 4 neighbors). There will always be a path (made of neighboring passable cells) between the bases.

Map examples:

MapExample1.png
MapExample2.png
MapExample3.png
MapExample4.png
MapExample5.png
MapExample6.png
MapExample7.png

The goal

The goal is to conquer the opponent's base. That will happen when at least one of the units of one player is located in the base of the other player. When a base is conquered, the game is finished and the winner is the player who conquered the opponent's base. If it happens that both player conquer each other bases at the same moment, the result is a draw. The result will also be a draw if both players lose all of their units, or 2400 moves are played. In case a player makes an illegal move that player immediately loses the game. If both players make an illegal move in the same move, the result is a draw.

Move

The players make their moves simultaneously. Each player decides what his next move is going to be without knowing what the other player decided for his move. After both players made a decision, the moves are played at the same time.

In each move, a player can move any of their units to one of the neighboring passable cells.

After both players decide which of their units will be moved where, the following steps are being executed, in the stated order.

  1. Units are moved to their destination cells. It is possible that a player has several units at a single cell.
  2. If there are units of both players at a single cell, the fight happens. After the fight, that cell will contain only the units belonging to the player who had more units at that cell immediately before the fight (after the step 1), and that number will equal the difference in the number of units before the fight. The other player loses all of his units in that cell.
  3. If the total number of units in the whole map belonging to a player is not greater than 8, the number of units of that player in each cell will be increased by the number of the neutral units in that cell, and the number of neutral units will become zero.
  4. The check if a unit of some player is located in the opponent's base is performed. If that happens, the player has conquered the opponent's base.

After all the move steps are made it is not possible to have opposing units in the same cell.

Neutral units never move, and their number in a cell remains constant until they are acquired by one of the players, after which their number in that cell is zero.

It is possible to send units from one cell to different neighborng cells in the same move. Units can also stay where they are.

If two neighboring cells contain units of both players, and units from the first cell are sent to the second cell while units from the second cell are sent to the first cell, they will pass through each other without a fight.

Example: Assume that after the step 1 of the execution of a move, a cell contains 3 units of the first player, 5 units of the second player, and 4 neutral units. After the move is fully executed, that cell will contain 0 units of the first player, 6 units of the second player, and 0 neutral units.

Example: Assume that a player has 2 units in some cell. The cell above contains 9 neutral units, and the cell on the right contains 7 neutral units. If one of the player's units moves up, and the other to the right, after the move is executed the player will have 10 units in the cell above and 8 units in the cell on the right. The total number of the player's units is now more than 8, so that player cannot acquire new units until the total number of units drop to at most 8.

Arena

Arena is a program that manages the game execution and the communication with the players. Players do not communicate with each other, but only with the arena. All the communication is transmitted through TCP/IP protocol.

The arena is started first, after which each player should be started. A player contacts the arena by sending the name. After two players contact the arena, the arena shows up with the graphical interface from which the game can be staretd.

After the game is started, arena sends to the players the map description with the information about passable and impassable cells, and the location of the bases and neutral units.

After the map is sent to the players, the communication is done move-by-move until the game finishes. After players decide on the move, they send it to the arena as a sequence of submoves. A submove is a directive to move some number of units from one cell to one of the neighboring cells. Each submove is specified using the following parameters.

i The row index of a cell from which the units are moved (the top row is indexed with 0).
j The column index of a cell from which the units are moved (the leftmost column is indexed with 0).
k The number of units that should be moved.
d The direction in which the units are sent (0 - right, 1 - up, 2 - left, 3 - down).

In the same move it is possible to have several submoves from the same cell, or even submoves from the same cell in the same direction. If a player does not want to move any of the units in the current move, no submoves should be made.

After a player sends the move to the arena, the arena will send back the move played by the opposing player in the same turn.

All moves are time constrained. No more than 20 seconds should pass from the moment the arena sends the map description until the moment a player returns the first move. No more than 0.2 seconds should pass from the moment a player gets the opponent's move until the moment the next move is sent.

Example communication:

Player 1 Player 2
input output input output
map 6 7 . 1 . . # # 2 # 1 1 . 3 . 1 . A . # # . . . . # # . B . 1 . 3 . 1 1 # 2 # # . . 1 . 6 7 . 1 . . # # 2 # 1 1 . 3 . 1 . B . # # . . . . # # . A . 1 . 3 . 1 1 # 2 # # . . 1 .
move 1 2 1 1 1 3 5 1 3
3 5 1 3 2 1 1 1
move 2 1 1 1 0 1 1 1 1 3 4 2 3
3 4 2 3 1 1 1 0 1 1 1 1
...

The legality of a movea

A submove is illegal if a player tries to do any of the following:

A move is illegal if any of the following is true:

Using Arena

AngryMobArena.jar
Arena is given as an executable JAR file. One can run it using a command:
java -jar AngryMobArena.jar [-seed <seed>] [-moveLimit <moveLimit>] [-delay <delay>] [-timeInit <timeInit>] [-timeMove <timeMove>] [-size <size>] [-console]

All the parameters are optional and can be specified in arbitrary order.

-seed <seed> 64-bit signed integer uniquely determining the map. If not specified, it is generated randomly.
-moveLimit <moveLimit> The limit on the number of moves before a draw is declared. If not specified, this value is 2400
-delay <delay> The pause interval between two moves during the visualisation. If not specified, this value is 50.
-timeInit <timeInit> The time limit in seconds for the first move. If not specified, this value is 20.
-timeMove <timeMove> The time limit in seconts for every other move except the first. If not specified, this value is 0.2.
-size <size> The size of a cell in pixels. If not specified, this value is 11.
-console If specified, graphical interface will not be displayed, and only the game result will be printed to the console.

RandomRunners.zip
Java source code of a player that plays random moves.

A simple wrapper written in C++, to jump-start writing the player programs. To compile a program using this wrapper for Windows, you might need to use linker option "-lws2_32".

CamperJoe.zip
C++ source code of a player that does not move.

ProfessorRandom.zip
C++ source code of a player that plays random moves.

GravityGoers.jar
An example of a player.