Cookie settings

We use analytics cookies to improve the service. Learn more

ALPHANO

Domineering

Top PlayerSubmissionsParticipants
___31321

Problem

Two players play the game of Domineering on an 8×88 \times 8 board.

1. Board and Components

The board consists of 6464 cells arranged from row 11, column 11 to row 88, column 88. A cell at the xx-th row and yy-th column is denoted as (x,y)(x, y). Initially, all cells on the board are empty, and each cell (x,y)(x, y) contains a single integer Ax,yA_{x, y} uniformly distributed between 00 and 33, inclusive.

Below is an example of the initial board.

Initially, the first player starts the game with 00 points, and the second player starts with 2.52.5 points.

2. Gameplay

The game begins with the first player, and the two players take turns alternately.

During their turn, the first player can place a 1×21 \times 2 domino covering two horizontally adjacent empty cells, or select PASS. When placing a domino, the player must simultaneously cover the empty cells (x,y)(x, y) and (x,y+1)(x, y + 1) on the board, and earns points equal to the sum of the integers written on the two cells.

Below is an example of the first player placing a domino covering (4,5)(4, 5) and (4,6)(4, 6).

During their turn, the second player can place a 2×12 \times 1 domino covering two vertically adjacent empty cells, or select PASS. When placing a domino, the player must simultaneously cover the empty cells (x,y)(x, y) and (x+1,y)(x + 1, y) on the board, and earns points equal to the sum of the integers written on the two cells.

Below is an example of the second player placing a domino covering (5,4)(5, 4) and (6,4)(6, 4).

3. Game End

The game ends when both players select PASS consecutively, or when there are no valid positions left for either player to place a domino.

At the end of the game, the player with the higher score wins.

Please design an AI to become the ultimate winner of the board!

Input

Before the judge program and the agent begin communicating, the following input is provided over 88 lines.

  • On the ii-th line (1i8)(1 \le i \le 8), the integers Ai,1,Ai,2,,Ai,8A_{i, 1}, A_{i, 2}, \cdots, A_{i, 8} representing the numbers written on each cell of the board are given, separated by spaces. (0Ai,j3)(0 \le A_{i, j} \le 3)

Afterward, the judge program communicates with the agent using single-line text commands as follows:

Command Judge → Agent (Input) Agent → Judge (Output) Time Limit (ms) Description
READY READY (FIRST or SECOND) OK 3000 Informs whether you are the first or second player.
TURN TURN my_time opp_time MOVE x y my_time Informs your remaining time and the opponent's remaining time. Output the chosen cell (x,y)(x, y) to place the domino this turn. For PASS, output MOVE -1 -1.
OPP OPP x y time - - Informs the opponent's last move and the time they used. If the opponent chose PASS, OPP -1 -1 time is given.
FINISH FINISH - - Signals the end of the game. The agent must terminate normally without further output.
  • In the MOVE and OPP commands, x and y are integers. If x and y are not both -1, (x,y)(x, y) represents the coordinates of the cell with the smaller row and column numbers among the two cells covered by the placed domino.
  • my_time, opp_time, and time are integers representing time in milliseconds.
  • After every output, you must print a newline character and flush the buffer.
  • Failure to output within the time limit results in a Time Limit Exceeded (TLE) verdict.
  • Outputting an invalid format or an illegal move during a TURN command results in a Runtime Error (RE) verdict.

Example

First Player Input First Player Output Second Player Input Second Player Output
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3 3 0 0 0 0 0 0 3 3 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 2 0 0 0 0 0 0 0 2 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
READY FIRST READY SECOND
OK OK
TURN 10000 10000
MOVE 2 1
OPP 2 1 50
TURN 10000 9950
MOVE 5 7
OPP 5 7 20
... ... ... ...
FINISH FINISH

Sample Code

Limit

  • Time: In the first TURN command, my_time is 10,000ms10{,}000\mathrm{ms} for each player.
  • Memory: 1,024MB1{,}024\mathrm{MB}
  • Judge environment: HELP > Judge environment