-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.py
More file actions
59 lines (49 loc) · 1.29 KB
/
Copy pathgame.py
File metadata and controls
59 lines (49 loc) · 1.29 KB
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
"""
This file contains the classes for the game logic of the games StoneGame and TicTacToe
"""
from typing import List
class GameLogic:
"""
GameLogic class
"""
def __init__(self):
self.state = []
self.rules = ""
self.player_score = 0
self.computer_score = 0
def actions(self, state: List[int]) -> List[int]:
"""
Generates a list of possible actions based on the current state
"""
pass
def result(self, state: List[int], action: int) -> (List[int], int):
"""
Returns the resulting state and the score gained by taking 'action' number of stones
"""
pass
def reset(self):
self.state = []
self.player_score = 0
self.computer_score = 0
def check_winner(self, state: List[int]) -> str:
"""
Determines the winner of the game
"""
pass
def __str__(self):
"""
return pretty print of the game state
"""
ret = ""
for i, s in enumerate(self.state):
ret += str(s)
if i % 3 == 2:
ret += "\n"
else:
ret += " "
return ret
def __type__(self):
"""
return the type of the game
"""
pass