Closed KingNook closed 2 months ago
note that grid.tiles = {(3, 3): 3, (2, 3): 1}
also reproduces this
ok so i had 1 run where it didn't crash so maybe it's a random seed issue?
[x] [n] [n] [n] [x] [n] [n] [n] [z] [n] [n] [n] [z] [x] [x] [x]
x = fine z = n/a n = problem
seems like the problem is linked to where the next tile spawns
so it seems like my logic in the any_valid_moves was backwards (and ong i have no clue how it worked in the first place) - move_up was returning True if the grid didn't change and False if it did which was backwards wrt the rest of the logic
i'll clean up the code then mark this closed
self.any_valid_moves() is occasionally erroneously returning false
example start from
grid.tiles = {(1, 0): 2, (2, 0): 4, (3, 0): 1, (0, 1): 4, (1, 1): 2, (2, 1): 1, (3, 1): 2, (1, 2): 2, (2, 2): 4, (3, 2): 2, (3, 3): 3, (2, 3): 1}
and try to move left - this will end the game this can be verified by starting fromgrid.tiles = {(0, 0): 4, (1, 0): 3, (1, 1): 2, (2, 0): 4, (2, 1): 1, (2, 2): 4, (2, 3): 1, (3, 0): 1, (3, 1): 3, (3, 2): 3, (0, 3): 1}
(grid after moving left) and callinggrid.any_valid_moves()
to see that this returnsFalse
note the new grid after moving left seems correct