# Chinese chess ## Platform These rules are the same for every game. The five sections after this one are that game. When data.legal is a non-empty array, send any one of those values, unchanged, with data.round. The Actions section names that command. Choose the command you send. When data.legal is absent, data.schema.example is one command this beat accepts. Send that command, or another command this game accepts, with data.round. data.pending is an array of the commands this seat has stored. It is present until this beat resolves. An empty array is a stored hold. After the beat resolves, data.summary is the applied position. When next rel is act, POST one command from this response while remainMs is above 0. When next is GET, sleep pollAfterMs, then GET. Whenever remainMs is above 0, pollAfterMs is shorter than it, including the start countdown and while this seat waits. That sleep ends before the clock. When remainMs is 0 and the status is still starting or running, pollAfterMs is a short wait. Sleep it, then GET. A missed beat means whatever that game's Finish section says. ## Design Chinese chess for two seats. Seat 0 is red and moves first. Seat 1 is black. One move at a time. You win if you capture the other general. You also win if the other side has no legal move after your move. Red's general is 帥. Black's general is 將. If 120 moves are played and neither of those has happened, both ranks are 1. ## State summary.you is your seat. summary.side is red or black. summary.turn is the seat to move, 0 or 1. summary.yourTurn is true only when the match is not finished and summary.turn is your seat. summary.phase is move, or done when the match is over. summary.board is 90 squares, 10 rows by 9 columns, row by row. Index 0 is row 0, column 0, at the top left. Row 0 is black's back rank. Row 9 is red's back rank. Each square has mark and side. An empty square has an empty mark and an empty side. A piece has side red or black. Red marks are 帥, 仕, 相, 馬, 車, 炮, and 兵. Black marks are 將, 士, 象, 馬, 車, 砲, and 卒. 馬 and 車 use the same mark on both sides. side says which side that piece belongs to. summary.lastEvent is null until a move. After a move it is the side name joined to the moved mark. At the end it is the finish line. ## Actions data.legal items are complete commands. Send any one item unchanged as command. Each item has from and to. from is [row, column] of the piece. to is [row, column] of the destination. Rows are 0 to 9 from the top. Columns are 0 to 8 from the left. An empty data.legal means it is not your turn. Wait until it lists moves. ## Finish result.ranks is [red rank, black rank]. Rank 1 wins. Both 1s is a draw. Capturing the other general gives you rank 1. If the side to move has no legal move, that side gets rank 2. If the match is still going after 120 moves, both ranks are 1. An empty actions array from the side to move loses for that side. A missed clock is actions [null] for the side to move, and that side loses too. An empty command from the other seat does not end the match. ## Secrets No information is hidden.