From 36bb70cb481352151cb8ba63156b417f4ec42560 Mon Sep 17 00:00:00 2001 From: Robby Zambito Date: Sat, 22 Jan 2022 16:12:50 -0500 Subject: Added a README that describes the available primitives from Scheme. --- README.md | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 README.md (limited to 'README.md') diff --git a/README.md b/README.md new file mode 100644 index 0000000..14effa8 --- /dev/null +++ b/README.md @@ -0,0 +1,63 @@ +# Othello with AI + +## Creating an AI Script + +### Primitives + +Function: (get-board) + + Gets the current board as a list of lists. + Each space is one of the symbols 'black, 'white, or 'empty. + +Function: (current-player) + + Gets the current player color. + Either the symbol 'black, or 'white. + +Function: (other-player) + + Gets the other players color. + This could be trivially computed from the result of (current-player), but since + this operation is likely to be common, it is provided as a primitive for + convenience. + +Function: (valid-move? move #:optional board player) + + Returns #t or #f based on if the provided move is valid or not on a board by a player. + If no player is provided, the current player is assumed. + If no board is provided, the current board is assumed. + +Function: (valid-moves #:optional board player) + + Returns the list of moves which (valid-move? board player) would return true. + If no player is provided, the current player is assumed. + If no board is provided, the current board is assumed. + +Function: (apply-move move #:optional board player) + + Applies the given move to the board, returning the board after the move is applied, + or '() if the move was not valid. + If no player is provided, the current player is assumed. + If no board is provided, the current board is assumed. + +Function: (get-winner board player) + + Gets the winner for a board for a certain players turn. + It does not make sense for these fields to be optional, because it will + never be the case that the current board has a winner, since the game + will have already terminated. + Returns 'empty if there was no winner. + +Function: (flipped-by-move move #:optional board player) + + Returns the number of flipped spaces if a move were to be applied. + If no player is provided, the current player is assumed. + If no board is provided, the current board is assumed. + +Function: (print-board #:optional board) + + Prints the board the same way as the interactive game. + This is mostly useful for debugging scripts. + If you wish to print the Scheme representation of the board, + you could either simply `display` it or use `pretty-print` from ice-9 + -- cgit v1.2.3