lib/ai: fix raw code in now tested docunit for puzzle test module
[nit.git] / lib / ai / examples / puzzle.nit
index 782fee6..dd85629 100644 (file)
@@ -25,7 +25,7 @@
 #
 # The argument "abcd.fgeh" is the grid
 #
-# ~~~
+# ~~~raw
 # abc
 # d.f
 # geh
@@ -33,7 +33,7 @@
 #
 # The goal is:
 #
-# ~~~
+# ~~~raw
 # abc
 # def
 # gh.
@@ -41,6 +41,8 @@
 #
 # 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.
@@ -103,7 +105,7 @@ class PuzzleProblem
                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
@@ -276,7 +278,6 @@ for arg in args do
                continue
        end
 
-       var c = new Clock
        var s = pb.astar
        s.memorize = true
        var r = s.run
@@ -285,6 +286,6 @@ for arg in args do
                break
        end
 
-       print "Solved, after looking at {r.steps} positions during {c.lapse}"
+       print "Solved, after looking at {r.steps} positions"
        pb.print_plan(r.plan)
 end