#include <disassembler_a.h>
Public Member Functions | |
disassembler_a_c (const problem_c *puz) | |
construct the disassembler for this concrete problem. | |
~disassembler_a_c (void) | |
separation_c * | disassemble (const assembly_c *assembly) |
Disassemble an assembly of the puzzle. | |
Protected Member Functions | |
void | init_find (disassemblerNode_c *nd, const std::vector< unsigned int > &pieces) |
start analysing the position given in the disassemblerNode | |
disassemblerNode_c * | find (void) |
get one possible next position for the currently running analysis | |
separation_c * | checkSubproblems (const disassemblerNode_c *st, const std::vector< unsigned int > &pieces) |
Analyze a sub-problem. | |
virtual separation_c * | disassemble_rec (const std::vector< unsigned int > &pieces, disassemblerNode_c *start)=0 |
this function must be implemented by the real disassemblers | |
Private Member Functions | |
unsigned short | subProbGroup (const disassemblerNode_c *st, const std::vector< unsigned int > &pn, bool cond) |
bool | subProbGrouping (const std::vector< unsigned int > &pn) |
separation_c * | checkSubproblem (int pieceCount, const std::vector< unsigned int > &pieces, const disassemblerNode_c *st, bool left, bool *ok) |
disassembler_a_c (const disassembler_a_c &) | |
void | operator= (const disassembler_a_c &) |
Private Attributes | |
grouping_c * | groups |
For grouping pieces. | |
const problem_c * | puzzle |
the problem we solve | |
unsigned short * | piece2shape |
Converts piece number to the corresponding shape number. | |
movementAnalysator_c * | analyse |
the movement analysator we use. |
It provides common functionality for both all disassemblers. This is mainly bookkeeping of disassemblerNode_c objects
the space grid dependend information is collected from movementCache classes. those are like the assemblerFrontends for the assembler (a bit more complicated though)
All that the real disassemblers need to to is implement the disassemble_rec function which analyzes one piece of the puzzle until it falls apart
disassembler_a_c::disassembler_a_c | ( | const problem_c * | puz | ) |
construct the disassembler for this concrete problem.
The problem can not be changed, once you done that but you can analyse many assemblies for disassembability
References grouping_c::addPieces(), analyse, problem_c::getShape(), problem_c::getShapeGroup(), problem_c::getShapeGroupCount(), problem_c::getShapeGroupNumber(), problem_c::getShapeMax(), groups, problem_c::partNumber(), piece2shape, problem_c::pieceNumber(), and puzzle.
disassembler_a_c::~disassembler_a_c | ( | void | ) |
References analyse, groups, and piece2shape.
disassembler_a_c::disassembler_a_c | ( | const disassembler_a_c & | ) | [private] |
separation_c * disassembler_a_c::checkSubproblem | ( | int | pieceCount, | |
const std::vector< unsigned int > & | pieces, | |||
const disassemblerNode_c * | st, | |||
bool | left, | |||
bool * | ok | |||
) | [private] |
References create_new_params(), disassemblerNode_c::decRefCount(), disassemble_rec(), subProbGroup(), and subProbGrouping().
Referenced by checkSubproblems().
separation_c * disassembler_a_c::checkSubproblems | ( | const disassemblerNode_c * | st, | |
const std::vector< unsigned int > & | pieces | |||
) | [protected] |
Analyze a sub-problem.
once a separating node has been found by the disassemble_rec function, it should call this function to analyze the sub-problems
References separation_c::addstate(), bt_assert, checkSubproblem(), disassemblerNode_c::getComefrom(), disassemblerNode_c::getX(), disassemblerNode_c::getY(), disassemblerNode_c::getZ(), disassemblerNode_c::is_piece_removed(), and state_c::set().
Referenced by disassembler_0_c::disassemble_rec().
separation_c * disassembler_a_c::disassemble | ( | const assembly_c * | assembly | ) | [virtual] |
Disassemble an assembly of the puzzle.
Because we can only have or don't have a disassembly sequence we don't need the same complicated callback interface. The function returns either the disassembly sequence or a null pointer. you need to take care of deleting the disassembly sequence after doing with it whatever you want.
Reimplemented from disassembler_c.
References bt_assert, disassemblerNode_c::decRefCount(), disassemble_rec(), disassemblerNode_c::getPiecenumber(), groups, assembly_c::isPlaced(), problem_c::pieceNumber(), assembly_c::placementCount(), puzzle, and grouping_c::reSet().
virtual separation_c* disassembler_a_c::disassemble_rec | ( | const std::vector< unsigned int > & | pieces, | |
disassemblerNode_c * | start | |||
) | [protected, pure virtual] |
this function must be implemented by the real disassemblers
Implemented in disassembler_0_c.
Referenced by checkSubproblem(), and disassemble().
disassemblerNode_c* disassembler_a_c::find | ( | void | ) | [inline, protected] |
get one possible next position for the currently running analysis
References analyse, and movementAnalysator_c::find().
Referenced by disassembler_0_c::disassemble_rec().
void disassembler_a_c::init_find | ( | disassemblerNode_c * | nd, | |
const std::vector< unsigned int > & | pieces | |||
) | [inline, protected] |
start analysing the position given in the disassemblerNode
References analyse, and movementAnalysator_c::init_find().
Referenced by disassembler_0_c::disassemble_rec().
void disassembler_a_c::operator= | ( | const disassembler_a_c & | ) | [private] |
unsigned short disassembler_a_c::subProbGroup | ( | const disassemblerNode_c * | st, | |
const std::vector< unsigned int > & | pn, | |||
bool | cond | |||
) | [private] |
References problem_c::getShapeGroup(), problem_c::getShapeGroupNumber(), disassemblerNode_c::is_piece_removed(), piece2shape, and puzzle.
Referenced by checkSubproblem().
bool disassembler_a_c::subProbGrouping | ( | const std::vector< unsigned int > & | pn | ) | [private] |
References grouping_c::addPieceToSet(), groups, grouping_c::newSet(), and piece2shape.
Referenced by checkSubproblem().
movementAnalysator_c* disassembler_a_c::analyse [private] |
the movement analysator we use.
The movement analysator will return the possible moves from a given position
Referenced by disassembler_a_c(), find(), init_find(), and ~disassembler_a_c().
grouping_c* disassembler_a_c::groups [private] |
For grouping pieces.
Referenced by disassemble(), disassembler_a_c(), subProbGrouping(), and ~disassembler_a_c().
unsigned short* disassembler_a_c::piece2shape [private] |
Converts piece number to the corresponding shape number.
These are needed for the grouping functions
Referenced by disassembler_a_c(), subProbGroup(), subProbGrouping(), and ~disassembler_a_c().
const problem_c* disassembler_a_c::puzzle [private] |