#include <disassembly.h>
Public Member Functions | |
separation_c (separation_c *r, separation_c *l, const std::vector< unsigned int > &pcs) | |
create a separation with sub separations r and l and the pieces in the array pcs | |
separation_c (xmlParser_c &pars, unsigned int pieces) | |
load a separation from an xml node | |
separation_c (const separation_c *cpy) | |
copy constructor | |
void | save (xmlWriter_c &xml, int type=0) const |
~separation_c () | |
unsigned int | getMoves (void) const |
return the number of moves that are required to separate the puzzle. | |
const state_c * | getState (unsigned int num) const |
get one state from the separation process | |
const separation_c * | getLeft (void) const |
get the separation for the pieces that were removed | |
const separation_c * | getRemoved (void) const |
get the separation for the pieces that were left over | |
void | addstate (state_c *st) |
add a new state to the FRONT of the current state list. | |
unsigned int | getPieceNumber (void) const |
return the number of pieces that are in this separation | |
unsigned int | getPieceName (unsigned int num) const |
get the number for the num-th piece that is in this separation | |
void | exchangeShape (unsigned int s1, unsigned int s2) |
2 pieces have exchanged their place in the problem list | |
virtual unsigned int | getSequenceLength (unsigned int x) const |
helper function used for "compare" to get the number of moves for the x-th place in the string | |
virtual unsigned int | getNumSequences (void) const |
helper function used for "compare" to get the number of move sequences | |
virtual unsigned int | sumMoves (void) const |
the number of moves to completely disassemble the puzzle, including all sub separations | |
virtual void | movesText (char *txt, int len) const |
fill a string with dot separated numbers containing the moves required to disassemble the puzzle not more than len characters are written | |
void | removePieces (unsigned int from, unsigned int cnt) |
void | addNonPlacedPieces (unsigned int from, unsigned int cnt) |
Private Member Functions | |
bool | containsMultiMoves (void) |
used in movesText to find out if a branch has a movesequence longer than 1 | |
int | movesText2 (char *txt, int len) const |
helper function for movesTxt | |
separation_c (const separation_c &) | |
void | operator= (const separation_c &) |
Private Attributes | |
std::vector< unsigned int > | pieces |
this array is here to identify the piecenumber for the given pieces that are in this part of the tree | |
std::deque< state_c * > | states |
vector with all the states that finally lead to 2 separate subpuzzles. | |
separation_c * | removed |
separation_c * | left |
unsigned int | numSequences |
the number of sequences this separation and all its sub separations contain |
The separation of a puzzle into lots of single pieces consists of a tree of such separations. The root class starts with the assembled puzzle and the lower parts divide the puzzle more and more until only single pieces are left
separation_c::separation_c | ( | separation_c * | r, | |
separation_c * | l, | |||
const std::vector< unsigned int > & | pcs | |||
) |
create a separation with sub separations r and l and the pieces in the array pcs
References numSequences, and pieces.
Referenced by separation_c().
separation_c::separation_c | ( | xmlParser_c & | pars, | |
unsigned int | pieces | |||
) |
load a separation from an xml node
References xmlParser_c::END_TAG, xmlParser_c::exception(), xmlParser_c::getAttributeValue(), xmlParser_c::getName(), getNumbers(), xmlParser_c::getText(), left, xmlParser_c::next(), xmlParser_c::nextTag(), numSequences, pieces, removed, xmlParser_c::require(), separation_c(), xmlParser_c::skipSubTree(), xmlParser_c::START_TAG, states, and xmlParser_c::TEXT.
separation_c::separation_c | ( | const separation_c * | cpy | ) |
separation_c::separation_c | ( | const separation_c & | ) | [private] |
void separation_c::addNonPlacedPieces | ( | unsigned int | from, | |
unsigned int | cnt | |||
) |
References addNonPlacedPieces(), left, pieces, and removed.
Referenced by solution_c::addNonPlacedPieces(), and addNonPlacedPieces().
void separation_c::addstate | ( | state_c * | st | ) |
add a new state to the FRONT of the current state list.
this is necessary because the list is generated when back tracking from the graph search, so we visit the states in the wrong order keep in mind that the new state must have the same number of pieces as all the other states
References bt_assert, state_c::getPiecenumber(), pieces, and states.
Referenced by disassembler_a_c::checkSubproblems().
bool separation_c::containsMultiMoves | ( | void | ) | [private] |
used in movesText to find out if a branch has a movesequence longer than 1
References containsMultiMoves(), left, removed, and states.
Referenced by containsMultiMoves(), and movesText2().
void separation_c::exchangeShape | ( | unsigned int | s1, | |
unsigned int | s2 | |||
) |
2 pieces have exchanged their place in the problem list
References exchangeShape(), left, pieces, and removed.
Referenced by solution_c::exchangeShape(), and exchangeShape().
const separation_c* separation_c::getLeft | ( | void | ) | const [inline] |
get the separation for the pieces that were removed
References left.
Referenced by disasmToMoves_c::doRecursive(), print_rec(), and separationInfo_c::recursiveConstruction().
unsigned int separation_c::getMoves | ( | void | ) | const [inline] |
return the number of moves that are required to separate the puzzle.
this number is one smaller than the number of states
References states.
Referenced by disasmToMoves_c::doRecursive(), print_rec(), and separationInfo_c::recursiveConstruction().
unsigned int separation_c::getNumSequences | ( | void | ) | const [virtual] |
helper function used for "compare" to get the number of move sequences
Implements disassembly_c.
References numSequences.
unsigned int separation_c::getPieceName | ( | unsigned int | num | ) | const [inline] |
get the number for the num-th piece that is in this separation
References bt_assert, and pieces.
Referenced by disasmToMoves_c::doRecursive().
unsigned int separation_c::getPieceNumber | ( | void | ) | const [inline] |
return the number of pieces that are in this separation
References pieces.
Referenced by disasmToMoves_c::doRecursive(), and print_rec().
const separation_c* separation_c::getRemoved | ( | void | ) | const [inline] |
get the separation for the pieces that were left over
References removed.
Referenced by disasmToMoves_c::doRecursive(), print_rec(), and separationInfo_c::recursiveConstruction().
unsigned int separation_c::getSequenceLength | ( | unsigned int | x | ) | const [virtual] |
helper function used for "compare" to get the number of moves for the x-th place in the string
Implements disassembly_c.
References getSequenceLength(), left, numSequences, removed, and states.
Referenced by getSequenceLength().
const state_c* separation_c::getState | ( | unsigned int | num | ) | const [inline] |
get one state from the separation process
References bt_assert, and states.
Referenced by disasmToMoves_c::doRecursive(), and print_rec().
virtual void separation_c::movesText | ( | char * | txt, | |
int | len | |||
) | const [inline, virtual] |
fill a string with dot separated numbers containing the moves required to disassemble the puzzle not more than len characters are written
Implements disassembly_c.
References movesText2().
int separation_c::movesText2 | ( | char * | txt, | |
int | len | |||
) | const [private] |
helper function for movesTxt
References bt_assert, containsMultiMoves(), left, movesText2(), removed, and states.
Referenced by movesText(), and movesText2().
void separation_c::operator= | ( | const separation_c & | ) | [private] |
void separation_c::removePieces | ( | unsigned int | from, | |
unsigned int | cnt | |||
) |
References bt_assert, left, pieces, removed, and removePieces().
Referenced by solution_c::removePieces(), and removePieces().
void separation_c::save | ( | xmlWriter_c & | xml, | |
int | type = 0 | |||
) | const |
References xmlWriter_c::addContent(), xmlWriter_c::endTag(), left, xmlWriter_c::newAttrib(), xmlWriter_c::newTag(), pieces, removed, save(), and states.
Referenced by solution_c::save(), and save().
unsigned int separation_c::sumMoves | ( | void | ) | const [virtual] |
the number of moves to completely disassemble the puzzle, including all sub separations
Implements disassembly_c.
References bt_assert, left, removed, states, and sumMoves().
Referenced by solveThread_c::assembly(), and sumMoves().
separation_c * separation_c::left [private] |
Referenced by addNonPlacedPieces(), containsMultiMoves(), exchangeShape(), getLeft(), getSequenceLength(), movesText2(), removePieces(), save(), separation_c(), sumMoves(), and ~separation_c().
unsigned int separation_c::numSequences [private] |
the number of sequences this separation and all its sub separations contain
Referenced by getNumSequences(), getSequenceLength(), and separation_c().
std::vector<unsigned int> separation_c::pieces [private] |
this array is here to identify the piecenumber for the given pieces that are in this part of the tree
Referenced by addNonPlacedPieces(), addstate(), exchangeShape(), getPieceName(), getPieceNumber(), removePieces(), save(), and separation_c().
separation_c* separation_c::removed [private] |
std::deque<state_c *> separation_c::states [private] |
vector with all the states that finally lead to 2 separate subpuzzles.
one state represents the position of all the pieces inside this subpuzzle relative to their position in the completely assembled puzzle
the last state will move all the pieces, that can be removed a long way out of the puzzle (more than 10000 units)
the first state is the beginning state, for this partition, e.g for the root node the first state represents the assembles puzzle with all values 0
Referenced by addstate(), containsMultiMoves(), getMoves(), getSequenceLength(), getState(), movesText2(), save(), separation_c(), sumMoves(), and ~separation_c().