Commit 47fcb032 authored by Taddeüs Kroes's avatar Taddeüs Kroes

Skip simulated moves that try to move exploding blocks

parent 0bb45a59
...@@ -92,6 +92,15 @@ class State: ...@@ -92,6 +92,15 @@ class State:
score += row - start_row + 1 score += row - start_row + 1
return score return score
def locked(self, i):
block = self.blocks[i]
if block == NOBLOCK:
return False
if is_basic(block):
return self.groupsizes[i] >= MIN_BASIC_GROUP_SIZE
assert is_bomb(block)
return self.groupsizes[i] >= MIN_BOMB_GROUP_SIZE
def move(self, *moves): def move(self, *moves):
deep = any(move in (GRAB, DROP, SWAP) for move in moves) deep = any(move in (GRAB, DROP, SWAP) for move in moves)
s = self.copy(deep) s = self.copy(deep)
...@@ -112,14 +121,14 @@ class State: ...@@ -112,14 +121,14 @@ class State:
row = s.colskip[s.exa] row = s.colskip[s.exa]
assert row < s.nrows assert row < s.nrows
i = row * COLUMNS + s.exa i = row * COLUMNS + s.exa
if not s.locked(i):
s.held = s.blocks[i] s.held = s.blocks[i]
s.blocks[i] = NOBLOCK s.blocks[i] = NOBLOCK
s.colskip[s.exa] += 1 s.colskip[s.exa] += 1
s.ungroup(i) s.ungroup(i)
elif move == DROP: elif move == DROP:
assert not s.colbusy(s.exa) if s.held != NOBLOCK:
assert s.held != NOBLOCK
row = s.colskip[s.exa] row = s.colskip[s.exa]
assert row > 0 assert row > 0
i = (row - 1) * COLUMNS + s.exa i = (row - 1) * COLUMNS + s.exa
...@@ -133,7 +142,7 @@ class State: ...@@ -133,7 +142,7 @@ class State:
row = s.colskip[s.exa] row = s.colskip[s.exa]
i = row * COLUMNS + s.exa i = row * COLUMNS + s.exa
j = i + COLUMNS j = i + COLUMNS
assert j < len(s.blocks) if j < len(s.blocks) and not s.locked(i) and not s.locked(j):
bi = s.blocks[i] bi = s.blocks[i]
bj = s.blocks[j] bj = s.blocks[j]
if bi != bj: if bi != bj:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment