Skip to content

Commit e17cf85

Browse files
committed
Fixed some bugs
1 parent b7fea9f commit e17cf85

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

Game.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,29 +98,32 @@ def makeMove(self, player):
9898
self.text = 'Game over! It\'s a tie!'
9999

100100
if player == 'red':
101-
if self.topTile is None:
102-
self.topTile = tile.gridPosition
101+
print("old top tile", Game.topTile)
102+
if Game.topTile is None:
103+
Game.topTile = tile.gridPosition
103104
else:
104-
if tile.gridPosition[0] < self.topTile[0]:
105-
self.topTile = tile.gridPosition
106-
107-
if self.bottomTile is None:
108-
self.bottomTile = tile.gridPosition
105+
if tile.gridPosition[1] < Game.topTile[1]:
106+
Game.topTile = tile.gridPosition
107+
print("new top tile", Game.topTile)
108+
109+
if Game.bottomTile is None:
110+
Game.bottomTile = tile.gridPosition
109111
else:
110-
if tile.gridPosition[0] > self.bottomTile[0]:
111-
self.bottomTile = tile.gridPosition
112+
if tile.gridPosition[1] > Game.bottomTile[1]:
113+
Game.bottomTile = tile.gridPosition
112114
elif player == 'blue':
113-
if self.leftTile is None:
114-
self.leftTile = tile.gridPosition
115+
if Game.leftTile is None:
116+
Game.leftTile = tile.gridPosition
115117
else:
116-
if tile.gridPosition[1] < self.leftTile[1]:
117-
self.leftTile = tile.gridPosition
118+
if tile.gridPosition[0] < Game.leftTile[0]:
119+
Game.leftTile = tile.gridPosition
118120

119-
if self.rightTile is None:
120-
self.rightTile = tile.gridPosition
121+
if Game.rightTile is None:
122+
Game.rightTile = tile.gridPosition
121123
else:
122-
if tile.gridPosition[1] > self.rightTile[1]:
123-
self.rightTile = tile.gridPosition
124+
if tile.gridPosition[0] > Game.rightTile[0]:
125+
Game.rightTile = tile.gridPosition
126+
124127
return x, y
125128

126129
def getNearestTile(self, pos):
@@ -192,7 +195,7 @@ def isValidMove(self):
192195
return self.matrix[tile.gridPosition[1]][tile.gridPosition[0]] == self.EMPTY
193196
return False
194197

195-
def estimateScore(self):
198+
def estimateScore(self, depth):
196199
return 0
197200

198201
def getComputerShortestPath(self):

algorithms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
def createPossibleMove(state):
88
if not state.possibleMoves:
9-
i = randint(0, state.board.NUM_ROWS)
10-
j = randint(0, state.board.NUM_COLS)
9+
i = randint(0, state.board.NUM_ROWS - 1)
10+
j = randint(0, state.board.NUM_COLS - 1)
1111

1212
newMatrix = copy.deepcopy(state.board.matrix)
1313
newMatrix[i][j] = state.board.JMAX[0].upper()

0 commit comments

Comments
 (0)