separation_c Class Reference

A list of states that lead to a separation of the puzzle into 2 parts. More...

#include <disassembly.h>

Inheritance diagram for separation_c:

Inheritance graph
[legend]
Collaboration diagram for separation_c:

Collaboration graph
[legend]

List of all members.

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_cgetState (unsigned int num) const
 get one state from the separation process
const separation_cgetLeft (void) const
 get the separation for the pieces that were removed
const separation_cgetRemoved (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_cremoved
separation_cleft
unsigned int numSequences
 the number of sequences this separation and all its sub separations contain


Detailed Description

A list of states that lead to a separation of the puzzle into 2 parts.

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


Constructor & Destructor Documentation

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 
)

separation_c::separation_c ( const separation_c cpy  ) 

copy constructor

References left, numSequences, pieces, removed, separation_c(), and states.

separation_c::~separation_c (  ) 

References left, removed, and states.

separation_c::separation_c ( const separation_c  )  [private]


Member Function Documentation

void separation_c::addNonPlacedPieces ( unsigned int  from,
unsigned int  cnt 
)

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 
)

void separation_c::save ( xmlWriter_c xml,
int  type = 0 
) const

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().


Member Data Documentation

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().

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().


The documentation for this class was generated from the following files:

Generated on Sun Oct 10 10:03:07 2010 for BurrTools by  doxygen 1.5.8