You are minding your own business when your friend approaches you and asks you to play a game of chess against his approximately 2300-rated engine, Weakfish. Unfortunately, you are not very good at chess. So, you tell him to wait a moment as you open a new file in your favorite text editor - you are going to create a chess engine to play against his chess engine!
The game of chess is to follow the FIDE rules of Chess, with the following added rules:
- Threefold repetition is removed
- 50-move rule is removed
- 300-move rule is added: if 300 moves pass with no result, the game will end as a draw
- The game ends once the king is taken; therefore, stalemate does not exist
You will play as black.
Interaction
This is an interactive problem. The first line will contain a string in long algebraic notation specifying Weakfish's first move.
Long algebraic notation is a form of notation where each move consists of two parts: the starting square and the ending square. For example, if a pawn was moved from e2 to e4, the resulting long algebraic notation move would be e2e4
. If a knight was moved from f3 to e5 to capture a piece, the resulting move would be f3e5
. When promotion occurs, simply add the first letter of the name of the piece to the end, unless it is a knight, in which case you should add an n
(e.g. e7e8q
, e7e8n
, e7e8b
, e7e8r
). Castling is represented as a king move, and must be one of the following: e1g1, e1c1, e8g8, e8c8.
You will then begin interaction. To make a move, print the move in long algebraic notation.
You should read in a string from Weakfish, which will contain the next move in long algebraic notation, unless the game has ended, in which case Weakfish will output the move 0000
. Upon receiving this, your program must terminate to prevent undefined behavior. Note that 0000
may come immediately after a move by Weakfish.
Please note that you may need to flush stdout
after each operation, or interaction may halt.
Do not print any uppercase letters. Weakfish output will not contain any uppercase letters.
Note that the judge is non-deterministic, meaning it may play different moves even when faced with the same position.
Grading
- If black wins, you will receive a verdict of
Accepted
and full points. - If white wins or a draw occurs, you will receive a verdict of
Wrong Answer
and judge feedback according to how the game ended (e.g.Judge wins by checkmate
) - If at any point your output is ill-formatted, an illegal move, or printed after the game has terminated, you will receive a verdict of
Wrong Answer
along with judge feedback according to why the move was rejected (e.g.Illegal move
) - If your submission runs for over 90 seconds, you will receive a verdict of
Time Limit Exceeded
, even if it is not possible for the judge to checkmate your engine in the current position.
Sample Interaction 1
>>>
denotes your output; don't actually print this out.
f2f3
>>> e7e5
g2g4
>>> d8h4
a2a3
>>> h4e1
0000
Explanation for Sample Interaction 1
The game goes: 1. f3 e5 2. g4 Qh4 3. a3 Qxe1
Since the white king has been taken, black wins, therefore this will receive a verdict of Accepted
.
Note that the judge will not play such a weak sequence of moves.
Sample Interaction 2
e2e4
>>> e7e5
g1f3
>>> g8f6
f3e5
>>> b8c6
e5c6
>>> d7c6
d2d3
>>> f8c5
c1g5
>>> f6e4
g5d8
>>> c5f2
e1e2
>>> c8g4
a2a3
>>> g4e2
0000
Explanation for Sample Interaction 2
The game goes: 1. e4 e5 2. Nf3 Nf6 3. Nxe5 Nc6 4. Nxc6 dxc6 5. d3 Bc5 6. Bg5 Nxe4 7. Bxd8 Bxf2+ 8. Ke2 Bg4 9. a3 Bxe2
Since the white king has been taken, black wins, therefore this will receive a verdict of Accepted
.
Comments
this question seems oddly specific to projects that the author has made (I'm looking at you kevlu8)