Commit d0515a68 authored by Taddeüs Kroes's avatar Taddeüs Kroes

Dynamic programming: reuse changes made by common prefix moves

parent 409354ab
......@@ -56,10 +56,8 @@ if __name__ == '__main__':
vprint_state(state)
vprint()
start = time.time()
newstate = state.solve()
end = time.time()
vprint('thought for', round((end - start) * 1000, 1), 'ms')
assert state.exa is not None
except (TypeError, AssertionError):
vprint('\rerror during parsing, wait for a bit...', end='')
time.sleep(0.050)
......@@ -69,14 +67,23 @@ if __name__ == '__main__':
time.sleep(0.500)
continue
try:
start = time.time()
newstate = state.solve()
end = time.time()
vprint('thought for', round((end - start) * 1000, 1), 'ms')
except AssertionError:
print('error board 99:')
state.print()
board.convert('RGB').save('screens/board99.png')
break
if state.held == NOBLOCK and any(map(newstate.loops, buf)):
vprint('\rloop detected, wait for a bit...', end='')
time.sleep(0.03)
elif newstate.moves:
vprint('moves:', newstate.keys())
vprint(' score:', newstate.score)
if buf:
vprint('prev score:', buf[-1].score)
vprint('score:', newstate.score)
vprint()
vprint('target after moves:')
......@@ -88,7 +95,7 @@ if __name__ == '__main__':
#moves_delay = max(0, newstate.delay() - keys_delay)
#vprint('wait for', moves_delay, 'ms')
#time.sleep(moves_delay / 1000)
time.sleep(0.075)
time.sleep(0.080)
elif state.nrows - 2 <= MAX_SPEED_ROWS:
vprint('no moves, speed up')
press_keys(win, 'l')
......
This diff is collapsed.
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