-
Notifications
You must be signed in to change notification settings - Fork 0
/
solver_components.py
47 lines (37 loc) · 1.3 KB
/
solver_components.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
class SolverView:
def __init__(self, first_click, bombs_unflagged, lost, won, board_view):
self.first_click = first_click
self.bombs_unflagged = bombs_unflagged
self.lost = lost
self.won = won
self.board_view = board_view
def __str__(self):
return self.first_click_str() + self.state_str() + self.bombs_unflagged_str() + self.view_str()
def first_click_str(self):
return "First Click: " + str(self.first_click) + "\n"
def state_str(self):
if self.won:
string = "Won"
elif self.lost:
string = "Lost"
else:
string = "Neutral"
return "State: " + string + "\n"
def bombs_unflagged_str(self):
return "Bombs Unflagged: " + str(self.bombs_unflagged) + "\n"
def view_str(self):
string = "View:"
for row in self.board_view:
string += "\n"
string += str(row)
return string
class SolverAction:
def __init__(self, index, flag):
self.index = index
self.flag = flag
def __str__(self):
return str(self.index) + " " + str(self.flag)
def __eq__(self, other):
return (self.index == other.index) and (self.flag == other.flag)
def __hash__(self):
return hash((self.index, self.flag))