#
# The argument "abcd.fgeh" is the grid
#
-# ~~~
+# ~~~raw
# abc
# d.f
# geh
#
# The goal is:
#
-# ~~~
+# ~~~raw
# abc
# def
# gh.
#
# The shortest plan, in two steps, is to move *up* the tile under the hole (e),
# then to move *left* the tile after the hole (h).
+module puzzle is example
+
import ai::search
# The state (`S`) is a square grid, modeled as a one-dimensional array of Tile.
if x < width-1 then res.add(1)
if y >= 1 then res.add(-width)
if y < width-1 then res.add(width)
- return res.as_random.take_all
+ return res
end
# Return the state where the tile at hole+action has moved
continue
end
- var c = new Clock
var s = pb.astar
s.memorize = true
var r = s.run