A higher resolution is required to access the IDE
- 9
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
This is a port from the board game
Abalone
The Goal
The goal of the game is to push six of the opponent's marbles out of the board.
Rules
Game Board
The game is played on a hexagonal board. The board does not change during the game.
Each player starts with14 marbles placed on opposite sides of the grid.
The coordinates of each cell are represented on the image below. White and black cells depict the initial positions of the marbles.
The players take turns, black starts.
On their turn, each player chooses from one to three marbles of their color that lie in a straight line and moves them one cell in a choosen direction. Each direction is labelled from0 to 5 .
The directions:
The marbles can be moved only into empty cells.
If the direction of the move is parallel to the line of marbles, the move is called an in-line move.
Sumito
When the player's in-line move is blocked by enemy marbles, the player might sometimes apply a Sumito move.
If the length of player's marbles column is strictly longer than the number of enemy marbles in a consecutive line in that direction and after the enemy marbles' line there is an empty space or the end of the board, the player may still apply an in-line move and push the enemy marbles.
If the last marble of the pushed enemy column gets pushed out of the board, the marble is then removed.
Winning
The first player that successfuly removes six enemy marbles wins. The game lasts for350 turns. If after the last round both players removed
less than six marbles, to avoid excessive amount of draws, the player that removed more marbles wins.
If both of the players removed the same amount of marbles, there is a draw.
The game is played on a hexagonal board. The board does not change during the game.
Each player starts with
The coordinates of each cell are represented on the image below. White and black cells depict the initial positions of the marbles.
The players take turns, black starts.
On their turn, each player chooses from one to three marbles of their color that lie in a straight line and moves them one cell in a choosen direction. Each direction is labelled from
The directions:
The marbles can be moved only into empty cells.
If the direction of the move is parallel to the line of marbles, the move is called an in-line move.
Sumito
When the player's in-line move is blocked by enemy marbles, the player might sometimes apply a Sumito move.
If the length of player's marbles column is strictly longer than the number of enemy marbles in a consecutive line in that direction and after the enemy marbles' line there is an empty space or the end of the board, the player may still apply an in-line move and push the enemy marbles.
If the last marble of the pushed enemy column gets pushed out of the board, the marble is then removed.
Winning
The first player that successfuly removes six enemy marbles wins. The game lasts for
If both of the players removed the same amount of marbles, there is a draw.
Examples
An example of an in-line move made by the black player.
An example of a side-step move made by the white player.
An example of a Sumito move made by the white player (there are two white marbles blocked by only one black, white marbles can push the black marble.
An example of an another Sumito move made by the white player, who manages to remove the black's marble.
Game Input
Initial input
First line: The id of the player(myId) - 1 : white, 2 : black.
Input for one game turn
First line: Your score Opponent score
Next 9 lines: characters representing one line of the game board's grid, top to bottom. (0 : empty, 1 : white, 2 : black).
Next line: five integers representing your opponent's last move (see Output section for details). If this is the first turn and you're the starting player, each integer is equal to-1 .
Next line: The number of valid moves(legalActionsCount).
Next legalActionCount lines: five integers representing each of the legal moves (see Output section for details).
Next 9 lines: characters representing one line of the game board's grid, top to bottom. (
Next line: five integers representing your opponent's last move (see Output section for details). If this is the first turn and you're the starting player, each integer is equal to
Next line: The number of valid moves(legalActionsCount).
Next legalActionCount lines: five integers representing each of the legal moves (see Output section for details).
Output
A single line containing the position of the first marble and the last marble of the
chosen marble column and the direction of their move.
Example: "2 3 3 5 4" - moving marbles from cells (2, 3), (3, 4) and (3, 5) in the direction labbeled by number4 .
Example: "2 3 3 5 4" - moving marbles from cells (2, 3), (3, 4) and (3, 5) in the direction labbeled by number
Constraints
Response time first turn is ≤
Response time per turn is ≤
A higher resolution is required to access the IDE