-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.py
49 lines (39 loc) · 1.16 KB
/
game.py
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
"""
Superclass Game
"""
from typing import Any
from game_state import GameState
class Game:
"""
Abstract class for a game to be played with two players.
"""
def __init__(self, p1_starts: bool) -> None:
"""
Initialize this Game, using p1_starts to find who the first player is.
"""
raise NotImplementedError
def get_instructions(self) -> str:
"""
Return the instructions for this Game.
"""
raise NotImplementedError
def is_over(self, state: GameState) -> bool:
"""
Return whether or not this game is over at state.
"""
raise NotImplementedError
def is_winner(self, player: str) -> bool:
"""
Return whether player has won the game.
Precondition: player is 'p1' or 'p2'.
"""
raise NotImplementedError
def str_to_move(self, string: str) -> Any:
"""
Return the move that string represents. If string is not a move,
return some invalid move.
"""
raise NotImplementedError
if __name__ == "__main__":
from python_ta import check_all
check_all(config="a2_pyta.txt")