@@ -87,7 +87,7 @@ def board_find_groups(board):
87
87
for c in range (board_width (board )):
88
88
for l in range (board_height (board )):
89
89
curr = make_pos (l , c )
90
- if curr not in visited :
90
+ if curr not in visited and color ( board_get_color ( board , curr )) :
91
91
curr_group = board_get_group (board , curr )
92
92
groups .append (curr_group )
93
93
for pos in curr_group :
@@ -104,9 +104,9 @@ def board_remove_group(board, group):
104
104
105
105
new_board = list (map (list , zip (* new_board ))) #this transposes the matrix
106
106
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
108
108
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 ))
110
110
111
111
new_board = list (map (list , zip (* new_board )))
112
112
return new_board
@@ -127,7 +127,7 @@ def board_height(board):
127
127
def board_get_color (board , pos ):
128
128
return board [pos_l (pos )][pos_c (pos )]
129
129
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 ()
131
131
def board_print (board ):
132
132
print_table (board , sep = ' ' )
133
133
"""
@@ -163,7 +163,7 @@ def get_actions(self):
163
163
164
164
class same_game (Problem ):
165
165
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 ))]))
167
167
def actions (self , state ):
168
168
return state .get_actions ()
169
169
def result (self , state , action ):
0 commit comments