7GQ5TOWHFPXHGR7RFYWHWWMO32MDSVVK7WRLWDEROVTKCQRHRMTAC
AHABKD5VEK5RSTM3CME4XJAHCVTHYV2D2WAWUGSJ6PBUCUI7CB3AC
FKENDSMEJXEZPAT6K5TYJC2KZBVYKMXA7LN7ZVPZMYIBODWIB64AC
LYLOM4SPCNQX64J76E7WDGCXPJOJ2GTSLJCDREJJFZY46HGMCR3QC
GVX7YSQYURPWFSUWVUAORZJTQBJURWWNBNUGEZYFAUMX3X5LSACQC
4IBBQBYGBZDCXQO5C7H6UTWT67YJUJ7R6FH6UNHX4QGXOO47UUBQC
MUADNESBQPELEGUUCGMPUZKVQZPUSSNALDW3MWCBJ42MRFWMQF7QC
X6AJODURS3K7O6ZNPOJLXFKI73E7OBRJRMBL66UHBDKFZXK4F6RAC
73FZRRIBGT2F6MK4C2JIK4M4BXVKLF5YWRWEERBB7BZ7X4XZCWTQC
TRZPDEYAE6S3FP7NKTNKQLECPVV2LRKGC7PJCC2MHPXDLU7CAABQC
table.insert(cands, {x=x-1, y=y, prev=cand})
table.insert(cands, {x=x+1, y=y, prev=cand})
table.insert(cands, {x=x, y=y-1, prev=cand})
table.insert(cands, {x=x, y=y+1, prev=cand})
table.insert(cands, {x=x-1, y=y, dir='left', prev=cand})
table.insert(cands, {x=x+1, y=y, dir='right', prev=cand})
table.insert(cands, {x=x, y=y-1, dir='up', prev=cand})
table.insert(cands, {x=x, y=y+1, dir='down', prev=cand})
table.insert(undo_history, u)
if add_to_undo then
table.insert(undo_history, u)
end
end
function plan_move_to_empty_space(y, x)
local path = find_path(level_state, player, {y=y, x=x})
if path == nil then return end
pending_moves = unwind_steps(path, {})
local src = level_state[player.y][player.x]
local dest = level_state[y][x]
local u = {
{x=player.x, y=player.y, cell=src},
{x=x, y=y, cell=dest}}
table.insert(undo_history, u) -- add to undo without making move yet
next_pending_move = Current_time
end
function car.update()
if next_pending_move and Current_time >= next_pending_move then
if #pending_moves > 0 then
local dir = table.remove(pending_moves)
move(dir, --[[add to undo]] false)
next_pending_move = Current_time + 0.1
end
end
elseif chord == 'left' then
move_left()
elseif chord == 'right' then
move_right()
elseif chord == 'up' then
move_up()
elseif chord == 'down' then
move_down()
elseif chord == 'left' or chord == 'right' or chord == 'up' or chord == 'down' then
move(chord, --[[add to undo]] true)