Skip to content

Commit 98b6e32

Browse files
committed
Changed hardcoded values. Fixed bug at the end.
Signed-off-by: SemperDarky <[email protected]>
1 parent 84bab68 commit 98b6e32

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

SameGame.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def board_find_groups(board):
8787
for c in range(board_width(board)):
8888
for l in range(board_height(board)):
8989
curr = make_pos(l, c)
90-
if curr not in visited:
90+
if curr not in visited and color(board_get_color(board, curr)):
9191
curr_group = board_get_group(board, curr)
9292
groups.append(curr_group)
9393
for pos in curr_group:
@@ -104,9 +104,9 @@ def board_remove_group(board, group):
104104

105105
new_board = list(map(list, zip(*new_board))) #this transposes the matrix
106106
for row in new_board:
107-
row.sort(key=lambda x: x != 0) #this pushes all zeroes to left
107+
row.sort(key=lambda x: x != get_no_color()) #this pushes all zeroes to left
108108

109-
new_board.sort(key=lambda x: x.count(0) == board_height(board))
109+
new_board.sort(key=lambda x: x.count(get_no_color()) == board_height(board))
110110

111111
new_board = list(map(list, zip(*new_board)))
112112
return new_board
@@ -127,7 +127,7 @@ def board_height(board):
127127
def board_get_color(board, pos):
128128
return board[pos_l(pos)][pos_c(pos)]
129129
def board_del_color(board, pos):
130-
board[pos_l(pos)][pos_c(pos)] = 0
130+
board[pos_l(pos)][pos_c(pos)] = get_no_color()
131131
def board_print(board):
132132
print_table(board, sep=' ')
133133
"""
@@ -163,7 +163,7 @@ def get_actions(self):
163163

164164
class same_game(Problem):
165165
def __init__(self, board):
166-
Problem.__init__(self, sg_state(board), sg_state([[0 for i in range(board_width(board))] for i in range(board_width(board))]))
166+
Problem.__init__(self, sg_state(board), sg_state([[0 for i in range(board_width(board))] for i in range(board_height(board))]))
167167
def actions(self, state):
168168
return state.get_actions()
169169
def result(self, state, action):

0 commit comments

Comments
 (0)