The self play mode allows a person to play both sides of the game. This mode is used to allow people to practice using the client and also to allow planning moves.
To see an example of the current game client running in this mode view this practice page. However some things will be different for the JavaScript client so be sure to read the following specs carefully.
The selfPlay mode is very similar to the replay mode, except that the user can move the pieces. Once the move is made it gets added to the Move List and it automatically becomes the other players turn. The '--' button can be used to skip remaining steps if the move does not use all four steps.
If mode=selfPlay then the following parameters can also be given.
For meaning of the move notation see:
Move and Position Notation
If the result parameter has been given then the user will not be able to move the pieces and so the client functions exactly the same as it does when mode=replay. They can only review the moves that were given in the move list.
If the result parameter is not given then the user can move the pieces and add more moves.
After loading the client should display the board as it appears after the last move in the 'movelist' has been made. If the 'startmove' parameter is given then it should display the board at the start of this move.
The 'Move List' display area should highlight a blank line after the last move in the list. This line should only contain the next move number. The background of moves that are fixed should be shown in a different color then those of user entered moves.
If no movelist was given then the next move will be 1w and will be highlighted in the 'Move List' area.
If the startmove or fixedmoves parameter is greater than the moves in the movelist then that parameter should be set to the highest move in the movelist.
As the user moves the pieces, each step is added to the current move line. If the user undoes a step the step is removed from the current move line. After the user completes the move (either by taking 4 steps or skipping remaining steps) the side to move is changed and a new blank move line is added to the Move List and that becomes the current move line.
When the next move to be made by the user is 1w or 1b then the user is allowed to place the pieces on the board according to the game rules. There are two ways in which the user can place the pieces. The first way is how the current Flash client does it and this will be the default method. But if the user clicks on any of the 4 squares at the center of the board then switch to using the second method. If they click on any of these squares again then switch back to the first method. The user can toggle between the two methods by click on any of the four center squares.
If the next move to be made is not 1w or 1b then the pieces on the board can be moved a total of 4 steps according to the game rules.
When the mouse is moved over a piece that can be moved, the squares to which that piece can be moved are highlighted using arrow icons. A piece can be moved by clicking on one of the highlighted squares. The piece is moved to the selected square.
If the mouse is not on a piece or any of the highlighted squares then the squares which were highlighted should be cleared.
On all moves the number of steps remaining to be taken is shown on the left side of the board close the the elephant icon.
There is a button to undo a step. When this button is clicked the current step is removed from the current move in the Move List and the step is undone on the board. If there are no steps left to be undone for the current move then last step of the previous move is undone provided that this move was added by the user.
There is a button to redo a step. When this button is clicked the most recent step that was removed with the undo button should be restored. Thus the piece is moved on the board and the step is added to the current move in the Move List. All steps that were undone can be restored with the redo button as long as the user has not taken a different step.
After the user has added at least one move the 'Takeback' button becomes active. Clicking on the 'Takeback' button while on the last move in the 'Move List' should cause it to be removed and the state of the board returned to the way it was before the move was made.
'Takeback' can only be done for the moves that are greater than or equal to the fixedmoves parameter. Moves that are less then this parameter cannot be removed by clicking the 'Takeback' button.
If the user goes back in the move history to a move that was added by the user and then clicks the 'Takeback' button then this move and all the moves added by the user after this move are removed from the 'Move List' area. The user is then allowed to move the piecies from this position.
If the player sends a move that wins the game a window pops up to alert the user that they have won the game. Also the sound file for the win is played.
The username and other fields of the player who's turn it is should be highlighted. This makes it easy for the player to tell which players turn it is.
The number of steps remaining is shown to the left of the board close to the elephant icon of the player whos turn it is.
When the player makes the fourth step or clicks the button to skip the remaining steps, the client should check if this position is the same as the position at the start of the move. If so then the user should not be allowed to do this. Also the client should check if this same position with the same side to play has ever occured in the game before. If so the client should warn the user and indicate how many times this has occured before.
A perl script which shows how to generate the valid steps given the board position and the steps already taken is available. A function called getSteps returns an array of valid steps that can be made given the current position, steps already taken and which players turn it is.
All the functionality that was available in replay mode should continue to work the same in selfPlay mode.