#include <solver.h>
Public Methods | |
Solver (Map const &map, int cache_size) | |
bool | prepare () |
bool | solve (int steps) |
int | depth () const |
int | actMinDepth () const |
int | actMaxDepth () const |
int | maxDepthReached () const |
int | maxDepth () const |
int | nextMaxDepth () const |
double | percentageCompleted () const |
Movements | moves () const |
Movements | bestEffort () const |
Private Types | |
enum | PatternType { KEEPER = 1 << 0, KEEPER_ON_GOAL = 1 << 1, GEM = 1 << 2, GEM_ON_GOAL = 1 << 3, EMPTY = 1 << 4, GOAL = 1 << 5, WALL = 1 << 6, OUTSIDE = 1 << 7 } |
Private Methods | |
bool | doSingleStep () |
bool | startSearch () |
bool | collapse () |
void | expand () |
bool | processEndNodes () |
std::vector< int > const & | validMoves () const |
int | movesForGem (int keeper_pos, int gem_pos, int goal_pos) const |
bool | isDeadlock (int position, bool ignore_on_goal=false) const |
int | minMovesForSolution (int moved_gem_pos) const |
int | assignmentSolver (std::vector< int > &matrix, int dim) const |
int | lowerBound (Hash const &hash, int moved_gem_pos, int depth) |
void | updateCache (Hash const &hash, int moves_to_solve, int depth) |
void | insertInCache (Hash const &hash, int moves_to_solve, int depth, bool calculated) |
void | setupCache () |
std::vector< int > | getGemPositions (Map const &map) const |
void | setupDistanceMap () |
void | setupDeadlockPatterns () |
Movements | getFullMoves () const |
Private Attributes | |
Map | m_map |
Map | m_start_map |
Map | m_empty_map |
std::vector< int > | m_pos |
std::vector< int > | m_move_lengths |
std::vector< int > | m_move_offsets |
std::vector< int > | m_min_solve_moves |
std::vector< int > | m_moves |
std::vector< int > | m_gem_positions |
Movements | m_solution_moves |
Movements | m_best_effort |
int | m_best_effort_max_depth |
int | m_best_effort_lower_bound |
std::vector< int > | m_possible_gem_positions |
std::vector< int > | m_goal_positions |
std::vector< Hash > | m_hashs |
int | m_goals |
int | m_depth |
int | m_act_min_depth |
int | m_act_max_depth |
int | m_max_depth_reached |
int | m_max_depth |
int const | m_width |
int const | m_height |
int const | m_size |
int | m_xy_offsets [4] |
int | m_min_add_depth |
bool | m_solution_possible |
std::map< Hash, CacheEntry > | m_cache |
int | m_max_cache_size |
int | m_cache_size |
std::vector< int > | m_depth_counts |
int | m_max_depth_counts |
std::vector< int > | m_distance_map |
std::vector< Q_UINT32 > | m_reachable_map |
int | m_reachable_map_gem |
bool | m_solve_finished |
std::vector< int > | m_deadlock_patterns |
std::vector< int > | m_deadlock_pattern_positions |
std::vector< int > | m_deadlock_pattern_lengths |
Static Private Attributes | |
int const | s_unsolvable |
Uses IDA* and some simple enhancements.
|
Used to define the patterns.
|
|
Constructs the solver for the given map.
|
|
Returns the actual max depth for the last call to solve().
|
|
Returns the actual min depth for the last call to solve().
|
|
Utility function used to find the minimum number of moves.
|
|
Returns the moves of the best current effort.
|
|
Callapses to an old depth.
|
|
Returns the actual search depth.
|
|
Makes a single solve step.
|
|
Expands to a new depth.
|
|
Returns the movements (including keeper moves) to get to the current map.
|
|
Returns a vector holding the positions (sorted) of all gems.
|
|
Inserts the given entry in the cache and removes som elements of the cache if it is full.
|
|
Returns true, if the gem at the given position is deadlocked.
|
|
Returns the lower bound for the map. Uses the cache to get better results.
|
|
Returns the actual maximum search depth.
|
|
Returns the max search depth reached.
|
|
Returns the minimum number of atomic gem moves to solve a map. If there are no possible moves, we return -1.
|
|
Returns the moves of the solution or and empty move list if it is not solvable.
|
|
Returns the minimum number of moves to move a gem from pos1 to pos2. If there is no way from pos1 to pos2 the return -1.
|
|
Returns the next max depth for the next iteration.
|
|
Returns the percentage (0 to 100) of the work in the actual iteration completed.
|
|
Sets up the solver. You need to call this function as long as it does not returns true. |
|
Searche the end nodes.
|
|
Updates the cache after starting a new search.
|
|
Sets up the deadlock patterns.
|
|
Sets up the distance map.
|
|
Tries to solve the map. You need to call this function as long as it does not returns true.
|
|
Starts the search with a new limit.
|
|
Updates the cache entry for the given map.
|
|
Returns the valid moves (menaing movements of gems) in compressed format .
|
|
The actual max depth in the last call to solve.
|
|
The actual min depth in the last call to solve.
|
|
The best effort moves.
|
|
The min lower bound for the best effort.
|
|
The max depth for the best effort.
|
|
The map used to find cycles in the move graph.
|
|
The actual cache size.
|
|
Here we store the length of the patterns.
|
|
Here we store the deadlock pattern positions.
|
|
Here we store the deadlock patterns.
|
|
The actual depth.
|
|
Here we store the number of entries of a given depth.
|
|
Here we store the distance map.
|
|
The start map without gems, goals and keeper.
|
|
The actual positions of the gems.
|
|
Here we store the indices of positions with a goal.
|
|
The number of goals.
|
|
Here we store the hashs for the maps.
|
|
The height of the map.
|
|
The act map.
|
|
The maximum cache size.
|
|
The actual max depth.
|
|
Here we store the max depth for m_depth_counts.
|
|
The maximum depth reached.
|
|
The current mimimum distance to a solution at the current depth.
|
|
The minimum moves to solve the map.
|
|
The movement lengths.
|
|
The move offsets.
|
|
The valid moves in a compressed format.
|
|
The move positions.
|
|
Here we store the indices of positions where a moveable gem might reside.
|
|
Here we store the the reachable fields for gems.
|
|
Here we store the current index of the gem position for which we calc the reachable map.
|
|
m_width * m_height.
|
|
The solution moves.
|
|
True, if at least one move seems to lead to a solution.
|
|
If true, no further calls ot solve are needed.
|
|
The start map.
|
|
The width of the map.
|
|
The offsets for atomic moves.
|
|
The number of pushes for unsolvable positions.
|