Cookie settings

We use analytics cookies to improve the service. Learn more

ALPHANO Logo

Catch The Mouse

Top PlayerSubmissionsParticipants

Problem

A fierce confrontation is taking place between a group of mice (R) and Nadori's team (C, N) on a 7×117 \times 11 kitchen floor.

The board consists of 77 rows and 1111 columns. Rows are numbered 11 to 77 from top to bottom, and columns are numbered 11 to 1111 from left to right. A cell at the xx-th row and yy-th column is denoted as (x,y)(x, y).

Delicious cheese is placed at the very bottom of the board. The mice are descending the kitchen floor to eat the cheese, while the cats and Nadori are trying to stop them.

fig1

Each cell can be in one of four states: empty ., mouse R, cat C, or Nadori N. Initially, the pieces are placed as follows:

State Count Initial Placement
Mouse R 1111 (1,1),(1,2),,(1,11)(1, 1), (1, 2), \cdots, (1, 11)
Cat C 44 (6,4),(6,5),(6,7),(6,8)(6, 4), (6, 5), (6, 7), (6, 8)
Nadori N 11 (6,6)(6, 6)
Empty cell . 6161

The battle begins with the mice, and Nadori and the mice take turns.

On the mice's turn, the following action is performed:

  1. Select a cell (x1,y1)(x_1, y_1) containing a mouse R and move it to (x1+1,y1)(x_1 + 1, y_1).

fig2

  • The destination (x1+1,y1)(x_1 + 1, y_1) must be an empty cell ..
  • The starting cell (x1,y1)(x_1, y_1) becomes an empty cell ..
  • The destination cell (x1+1,y1)(x_1 + 1, y_1) becomes a cell containing a mouse R.

In essence, the mice descend one cell at a time, rushing toward the cheese.

On Nadori's turn, one of the following actions is performed:

  1. Select a cell (x1,y1)(x_1, y_1) containing a cat C and move it to (x2,y2)(x_2, y_2). (2x26;1y211)(2 \le x_2 \le 6; 1 \le y_2 \le 11)

fig3

  • A cat can choose one of the 88 directions (horizontal, vertical, or diagonal) and move along a straight path as long as there are no other pieces in the way. (i.e., the cat moves like a Queen in chess)
  • The destination (x2,y2)(x_2, y_2) must be an empty cell ..
  • The starting cell (x1,y1)(x_1, y_1) becomes an empty cell ..
  • The destination cell (x2,y2)(x_2, y_2) becomes a cell containing a cat C.
  1. Select a cell (x1,y1)(x_1, y_1) containing Nadori N and move it to (x2,y2)(x_2, y_2). (2x26;1y211)(2 \le x_2 \le 6; 1 \le y_2 \le 11)

fig4

  • max(x2x1,y2y1)=1\max(\lvert x_2 - x_1 \rvert, \lvert y_2 - y_1 \rvert) = 1 (i.e., Nadori moves like a King in chess)
  • The destination (x2,y2)(x_2, y_2) must be either an empty cell . or a cell containing a mouse R.
  • The starting cell (x1,y1)(x_1, y_1) becomes an empty cell ..
  • The destination cell (x2,y2)(x_2, y_2) becomes a cell containing Nadori N.

The battle ends when any of the following conditions are met:

  • If any mouse reaches the 77th row, the mouse swarm wins and obtains the cheese.
  • If all mice completely disappear from the board, Nadori's team wins.
  • If there are no legal moves available for any mouse on the mice's turn, Nadori's team wins.

Please design an AI to become the ultimate winner of the kitchen floor!

Input

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 | SECOND) OK 3000 Informs whether you are the first or second player.
TURN TURN my_time opp_time MOVE x1 y1 x2 y2 my_time Informs your remaining time and the opponent's remaining time. Output the chosen (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) for this turn.
OPP OPP x1 y1 x2 y2 time - - Informs the opponent's last move and the time they used.
FINISH FINISH - - Signals the end of the game. The agent must terminate normally without further output.
  • x1, y1, x2, y2 are integers.
  • 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
READY FIRST READY SECOND
OK OK
TURN 10000 10000
MOVE 1 1 2 1
OPP 1 1 2 1 50
TURN 10000 9950
MOVE 6 6 5 7
OPP 6 6 5 7 20
TURN 9950 9980
...
FINISH FINISH

Sample Code

Limit

  • Time: For the first TURN command given to each agent, my_time is 1000010\,000 ms.
  • Memory: 1024MB
  • Judging Environment: HELP > Judging Environment