#include <movementanalysator.h>
Public Member Functions | |
movementAnalysator_c (const problem_c *puz) | |
construct the analysator for this concrete problem. | |
~movementAnalysator_c (void) | |
void | init_find (disassemblerNode_c *nd, const std::vector< unsigned int > &pieces) |
disassemblerNode_c * | find (void) |
void | completeFind (disassemblerNode_c *searchnode, const std::vector< unsigned int > &pieces, std::vector< disassemblerNode_c * > *result) |
disassemblerNode_c * | findMatching (disassemblerNode_c *nd, const std::vector< unsigned int > &pcs, unsigned int piece, int dx, int dy, int dz) |
Private Member Functions | |
void | prepare (void) |
bool | checkmovement (unsigned int maxPieces, unsigned int nextstep) |
disassemblerNode_c * | newNode (unsigned int amount) |
disassemblerNode_c * | newNodeMerge (const disassemblerNode_c *n0, const disassemblerNode_c *n1) |
movementAnalysator_c (const movementAnalysator_c &) | |
void | operator= (const movementAnalysator_c &) |
Private Attributes | |
unsigned int * | matrix |
unsigned int * | movement |
int * | weights |
unsigned int | piecenumber |
movementCache_c * | cache |
countingNodeHash * | nodes |
int | nextpiece |
int | next_pn |
int | nextstate |
int | nextpiece2 |
int | state99nextState |
unsigned int | nextdir |
unsigned int | maxstep |
unsigned int | nextstep |
disassemblerNode_c * | state99node |
disassemblerNode_c * | searchnode |
const std::vector< unsigned int > * | pieces |
It takes a position of pieces and then tries to find all other positions that can be reached directly from that starting point.
It is implemented using Bill Cuttlers algorithm, so please read there in case you are interested how it works. The comments are written with the thought that you know his algorithm
movementAnalysator_c::movementAnalysator_c | ( | const problem_c * | puz | ) |
construct the analysator for this concrete problem.
Ts can not be changed, once you done that but you can analyse many positions
References bt_assert, cache, problem_c::getGridType(), gridType_c::getMovementCache(), problem_c::getShapeMax(), problem_c::getShapeShape(), voxel_c::getWeight(), matrix, movement, nextstate, nodes, movementCache_c::numDirections(), problem_c::partNumber(), problem_c::pieceNumber(), piecenumber, and weights.
movementAnalysator_c::~movementAnalysator_c | ( | void | ) |
movementAnalysator_c::movementAnalysator_c | ( | const movementAnalysator_c & | ) | [private] |
bool movementAnalysator_c::checkmovement | ( | unsigned int | maxPieces, | |
unsigned int | nextstep | |||
) | [private] |
References bt_assert, cache, dirs, matrix, movement, next_pn, nextdir, nextpiece, movementCache_c::numDirections(), and piecenumber.
Referenced by find(), and findMatching().
void movementAnalysator_c::completeFind | ( | disassemblerNode_c * | searchnode, | |
const std::vector< unsigned int > & | pieces, | |||
std::vector< disassemblerNode_c * > * | result | |||
) |
References find(), init_find(), and maxstep.
disassemblerNode_c * movementAnalysator_c::find | ( | void | ) |
References bt_assert, cache, checkmovement(), countingNodeHash::clear(), countingNodeHash::initScan(), countingNodeHash::insert(), maxstep, newNode(), newNodeMerge(), next_pn, nextdir, nextpiece, countingNodeHash::nextScan(), nextstate, nextstep, nodes, movementCache_c::numDirections(), state99nextState, and state99node.
Referenced by completeFind(), and disassembler_a_c::find().
disassemblerNode_c * movementAnalysator_c::findMatching | ( | disassemblerNode_c * | nd, | |
const std::vector< unsigned int > & | pcs, | |||
unsigned int | piece, | |||
int | dx, | |||
int | dy, | |||
int | dz | |||
) |
References bt_assert, cache, checkmovement(), movementCache_c::getDirection(), newNode(), next_pn, nextdir, nextpiece, nextstate, nextstep, movementCache_c::numDirections(), pieces, prepare(), and searchnode.
void movementAnalysator_c::init_find | ( | disassemblerNode_c * | nd, | |
const std::vector< unsigned int > & | pieces | |||
) |
References next_pn, nextdir, nextpiece, nextstate, nextstep, pieces, prepare(), and searchnode.
Referenced by completeFind(), and disassembler_a_c::init_find().
disassemblerNode_c * movementAnalysator_c::newNode | ( | unsigned int | amount | ) | [private] |
References bt_assert, cache, movementCache_c::getDirection(), max(), movement, nextdir, pieces, searchnode, disassemblerNode_c::set(), disassemblerNode_c::setRemove(), and weights.
Referenced by find(), findMatching(), and newNodeMerge().
disassemblerNode_c * movementAnalysator_c::newNodeMerge | ( | const disassemblerNode_c * | n0, | |
const disassemblerNode_c * | n1 | |||
) | [private] |
References bt_assert, disassemblerNode_c::getAmount(), disassemblerNode_c::getDirection(), disassemblerNode_c::getX(), disassemblerNode_c::getY(), disassemblerNode_c::getZ(), movement, newNode(), next_pn, nextdir, and searchnode.
Referenced by find().
void movementAnalysator_c::operator= | ( | const movementAnalysator_c & | ) | [private] |
void movementAnalysator_c::prepare | ( | void | ) | [private] |
References cache, dirs, movementCache_c::getMoValue(), disassemblerNode_c::getTrans(), disassemblerNode_c::getX(), disassemblerNode_c::getY(), disassemblerNode_c::getZ(), matrix, min(), movementCache_c::numDirections(), piecenumber, pieces, and searchnode.
Referenced by findMatching(), and init_find().
movementCache_c* movementAnalysator_c::cache [private] |
Referenced by checkmovement(), find(), findMatching(), movementAnalysator_c(), newNode(), prepare(), and ~movementAnalysator_c().
unsigned int* movementAnalysator_c::matrix [private] |
Referenced by checkmovement(), movementAnalysator_c(), prepare(), and ~movementAnalysator_c().
unsigned int movementAnalysator_c::maxstep [private] |
Referenced by completeFind(), and find().
unsigned int* movementAnalysator_c::movement [private] |
Referenced by checkmovement(), movementAnalysator_c(), newNode(), newNodeMerge(), and ~movementAnalysator_c().
int movementAnalysator_c::next_pn [private] |
Referenced by checkmovement(), find(), findMatching(), init_find(), and newNodeMerge().
unsigned int movementAnalysator_c::nextdir [private] |
Referenced by checkmovement(), find(), findMatching(), init_find(), newNode(), and newNodeMerge().
int movementAnalysator_c::nextpiece [private] |
Referenced by checkmovement(), find(), findMatching(), and init_find().
int movementAnalysator_c::nextpiece2 [private] |
int movementAnalysator_c::nextstate [private] |
Referenced by find(), findMatching(), init_find(), and movementAnalysator_c().
unsigned int movementAnalysator_c::nextstep [private] |
Referenced by find(), findMatching(), and init_find().
countingNodeHash* movementAnalysator_c::nodes [private] |
Referenced by find(), movementAnalysator_c(), and ~movementAnalysator_c().
unsigned int movementAnalysator_c::piecenumber [private] |
Referenced by checkmovement(), movementAnalysator_c(), and prepare().
const std::vector<unsigned int>* movementAnalysator_c::pieces [private] |
Referenced by findMatching(), init_find(), newNode(), and prepare().
Referenced by findMatching(), init_find(), newNode(), newNodeMerge(), and prepare().
int movementAnalysator_c::state99nextState [private] |
Referenced by find().
Referenced by find().
int* movementAnalysator_c::weights [private] |
Referenced by movementAnalysator_c(), newNode(), and ~movementAnalysator_c().