summaryrefslogtreecommitdiff
path: root/README.md
blob: 14effa8a8810bf975694f570f7e31df59e2fa361 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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