View Source Backfish.ProblemDefinition behaviour (Backfish v0.1.0)
A behaviour module for defining problems that can be solved using the Backfish backtracking library.
This module provides three callback functions that must be implemented by any module that uses it:
initial_state/1
is_goal?/1
next_steps/1
The __using__
macro also defines default implementations for these callbacks
that raise errors, ensuring that any module using this behaviour implements its
own versions of these functions.
Summary
Callbacks
Returns the initial state of the problem.
Checks if the given state is a goal state.
Generates the next possible states from the given state.
Callbacks
Returns the initial state of the problem.
Parameters
args
: A keyword list of arguments that can be used to customize the initial state.
Returns
- The initial state of the problem.
Checks if the given state is a goal state.
Parameters
state
: The current state of the problem.
Returns
true
if the state is a goal state,false
otherwise.
Generates the next possible states from the given state.
Parameters
state
: The current state of the problem.
Returns
- A list of the next possible states.