A simple class to encapsulate the symbol and the goal position.
ai :: Tile :: defaultinit
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Object :: defaultinit
ai :: Tile :: defaultinit
core :: Comparable :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).
# A movable tile
# A simple class to encapsulate the symbol and the goal position.
class Tile
super Comparable
redef type OTHER: Tile is fixed
# The symbol written on the tile
var symbol: Char
# The expected position in the grid
var goal_idx: Int
redef fun to_s do return symbol.to_s
redef fun ==(o) do return o isa Tile and goal_idx == o.goal_idx
redef fun <(o) do return goal_idx < o.goal_idx
redef fun <=>(o) do return goal_idx <=> o.goal_idx
end
lib/ai/examples/puzzle.nit:211,1--227,3