superttt
A Python module implemented in Rust.
class
Game:
Game class
Methods:
- get_available_moves() - Returns a vector containing the cells that are
validin the current state. - make_move(input, player_id_authentication)
def
make_move(self, /, input, player_id_authentication):
Make a move. This does nothing else.
Args
input- the cell that the current player makes a move in.player_id_authentication- the id of the player that is making the move. This should be one of: {1, 2}
def
get_winner(self, /):
Returns the id of the winner of the game.
If it is equal to 0, then the game ended in a draw.
def
make_checkpoint(self, /):
Create a checkpoint. This can be saved somewhere and loaded in at a later point in time.
class
Player:
class
Checkpoint:
class
State:
Represent a Pythonlike state. The current board, next player, and all possible moves. Uses Numpy arrays when possible.
Important note:
- board - this attribute is a 1D-array. The first 9 elements represent the first field (upper left), the next 9 the second field (upper center) and so on
Layout:
0 1 2 9 10 11 18 19 20
3 4 5 12 13 14 21 22 23
6 7 8 15 16 17 24 25 26
27 28 29 36 37 38 45 46 47
30 31 32 39 40 41 48 49 50
33 34 35 42 43 44 51 52 53
54 55 56 63 64 65 72 73 74
57 58 59 66 67 68 75 76 77
60 61 62 69 70 71 78 79 80
def
play_game(player1, player2, game):
Play one game between two player objects. Delegates to overridden make_move method if it exists.
Todo: add caching for speeding up perhaps?
def
play_multiple_games(player1, player2, number_of_games):
Play multiple games in a single-threaded environment