For a few minutes I started to think I can't assume the original position of the crate is always invisible. But no, I was just not handling the case where empty_cell == occupied cell (should be considered occupied)
3CIDHIL2YPGFIPMVPGROBQPUGPGF5OPDQXHSRCQ7EVLNKJ6XDNHQC
local curr = level[y][x]
if (y == empty_cell.y and x == empty_cell.x) or
(not (y == occupied_cell.y and x == occupied_cell.x) and
curr ~= CELL_WALL and
curr ~= CELL_CRATE and
curr ~= CELL_CRATE_ON_TARGET) then
if is_empty(level, x,y, empty_cell, occupied_cell) then
function is_empty(level, x,y, empty, occupied)
Real_print('aa', x,y, empty.x,empty.y, occupied.x,occupied.y)
if empty.y ~= occupied.y or empty.x ~= occupied.x then
Real_print('bb')
if x == empty.x and y == empty.y then
Real_print('cc')
return true
end
end
if x == occupied.x and y == occupied.y then
Real_print('dd')
return false
end
local curr = level[y][x]
return curr ~= CELL_WALL and curr ~= CELL_CRATE and curr ~= CELL_CRATE_ON_TARGET
end
end
function dump_path(c)
if c == nil then return end
if not c.dir then
assert(not c.moves)
assert(not c.prev)
io.stdout:write('\n')
return
end
io.stdout:write('push '..c.dir..' ')
local c2 = c.moves
while c2 do
if c2.dir then
io.stdout:write('move '..c2.dir..' ')
end
c2 = c2.prev
end
dump_path(c.prev)