X-Git-Url: http://nitlanguage.org?ds=sidebyside diff --git a/lib/ai/backtrack.nit b/lib/ai/backtrack.nit index f8c17c5..597164d 100644 --- a/lib/ai/backtrack.nit +++ b/lib/ai/backtrack.nit @@ -13,6 +13,8 @@ # This module provides a simple abstract class `BacktrackProblem[S,A]` to be specialized for a specific problem. # # The concrete class `BacktrackSolver` is used to configure, query, and run a solver for a given problem. +# +# For an example, see the `queens.nit` program in the `examples` subdirectory. module backtrack # Abstract backtrack problem of states (`S`) and actions (`A`). @@ -38,7 +40,7 @@ module backtrack # # Basic search # # The method `solve` returns a new solver for a backtrack search. -class BacktrackProblem[S: Object,A] +abstract class BacktrackProblem[S: Object,A] # The starting state of the problem. # It is this object that will be modified by `apply_action` and `backtrack`. fun initial_state: S is abstract @@ -84,7 +86,7 @@ end # 2. Apply the method `run`, that will search and return a solution. # 3. Retrieve information from the solution. # -# ~~~~ +# ~~~~nitish # var p: BacktrackProblem = new MyProblem # var solver = p.solve # var res = solver.run @@ -207,6 +209,7 @@ class BacktrackSolver[S: Object, A] problem.backtrack(state, a) node = node.parent + assert node != null continue end