summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobby Zambito <contact@robbyzambito.me>2022-01-22 16:12:50 -0500
committerRobby Zambito <contact@robbyzambito.me>2022-01-22 16:12:50 -0500
commit36bb70cb481352151cb8ba63156b417f4ec42560 (patch)
tree76e42f9a11c92b3143720f8c9f6ac7f6fbbb735f
parenta33c266de08a0fe39d4d3b9c4d720695e217d024 (diff)
Added a README that describes the available primitives from Scheme.
-rw-r--r--README.md63
1 files changed, 63 insertions, 0 deletions
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
+