disassemblerNode_c Class Reference

The node structure used by the disassembler. More...

#include <disassemblernode.h>

Collaboration diagram for disassemblerNode_c:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 disassemblerNode_c (unsigned int pn, disassemblerNode_c *comf, int _dir, int _amount, int step=1)
 Create a new node.
 disassemblerNode_c (const assembly_c *assm)
 creates a root node from an assembly
 disassemblerNode_c (unsigned int pn)
 create a new root node with pn pieces
 ~disassemblerNode_c ()
void replaceNode (const disassemblerNode_c *n)
 Replace this node with the information from another node.
bool decRefCount (void)
 this function is used by outsiders to free their own pointers to this node.
void incRefCount (void)
 Tell this node that you now have a pointer to it.
unsigned int hash (void) const
 Return the hash value for this node.
bool operator== (const disassemblerNode_c &b) const
 The comparison operations using "normalized" positions.
int getX (unsigned int i) const
 return x-position of piece i
int getY (unsigned int i) const
 return y-position of piece i
int getZ (unsigned int i) const
 return z-position of piece i
unsigned int getTrans (unsigned int i) const
 return orientation of piece i
unsigned int getPiecenumber (void) const
 return the number of pieces that are handled in this node
void setRemove (unsigned int i, int x, int y, int z)
 Setup piece i to be removed in this node.
void set (unsigned int i, int x, int y, int z, unsigned int tr)
 set position of piece i in this node to the given values
void set (unsigned int i, int tx, int ty, int tz)
 set position of piece i in this node relative to the position in the come-from node
bool is_piece_removed (unsigned int nr) const
 check if piece number nr is removed in this node
bool is_separation () const
 check, if there is any piece that is removed in this node
const disassemblerNode_cgetComefrom (void) const
 get the come-from node
int getAmount (void) const
 get the amount of movement for this node
unsigned int getDirection (void) const
 get the movement direction for this node
unsigned int getWaylength (void) const
 get the waylength from root node to this node

Public Attributes

disassemblerNode_cnext
 Next-pointer for the hash-table lists.

Private Member Functions

 disassemblerNode_c (const disassemblerNode_c &)
void operator= (const disassemblerNode_c &)

Private Attributes

disassemblerNode_ccomefrom
 The node that we came from to reach this node.
unsigned int piecenumber
 Number of pieces this node is handling.
int16_t * dat
 The position and orientation of all involved pieces.
unsigned int refcount
 A reference counter for automatic deletion of the node.
unsigned int dir
 The direction pieces are moved.
int amount
 Amount of steps that pieces are moved.
unsigned int hashValue
 The has value of this node.
unsigned int waylength
 Waylenth to get from the startnode to this node.

Static Private Attributes

static const int16_t maxMove = 32767
 Maximum possible distance from the original position.


Detailed Description

The node structure used by the disassembler.

This node contains the current position of all involved pieces. It also contains a pointer to the node that we came from to reach this node

Finally we have some additional redundant information for easier manipulation: the direction and the amount the pieces were moved to get to this node.

The node is used by the disassembler to construct its search tree. As the tree can grow pretty large with a lot of nodes, it is important to keep the node small. There is some possible optimisation available in this node. For example you could save just the direction, amount and pieces involved the transition from the come-from node to this node.

The redundant information could be calculated from the come-from node.


Constructor & Destructor Documentation

disassemblerNode_c::disassemblerNode_c ( unsigned int  pn,
disassemblerNode_c comf,
int  _dir,
int  _amount,
int  step = 1 
)

Create a new node.

Create a new node with the given number of pieces the given come-from pointer and the defined values for direction, amount. Thepsize is added to the waylength of the come-from pointer and the result will be saved in our waylength value

References bt_assert, comefrom, incRefCount(), and waylength.

disassemblerNode_c::disassemblerNode_c ( const assembly_c assm  ) 

disassemblerNode_c::disassemblerNode_c ( unsigned int  pn  ) 

create a new root node with pn pieces

disassemblerNode_c::~disassemblerNode_c (  ) 

References comefrom, dat, and decRefCount().

disassemblerNode_c::disassemblerNode_c ( const disassemblerNode_c  )  [private]


Member Function Documentation

bool disassemblerNode_c::decRefCount ( void   )  [inline]

this function is used by outsiders to free their own pointers to this node.

if the function returs true, delete the node

References bt_assert, and refcount.

Referenced by disassembler_a_c::checkSubproblem(), countingNodeHash::clear(), nodeHash::clear(), disassembler_a_c::disassemble(), disassembler_0_c::disassemble_rec(), replaceNode(), and ~disassemblerNode_c().

int disassemblerNode_c::getAmount ( void   )  const [inline]

get the amount of movement for this node

References amount.

Referenced by movementAnalysator_c::newNodeMerge().

const disassemblerNode_c* disassemblerNode_c::getComefrom ( void   )  const [inline]

get the come-from node

References comefrom.

Referenced by disassembler_a_c::checkSubproblems(), and create_new_params().

unsigned int disassemblerNode_c::getDirection ( void   )  const [inline]

get the movement direction for this node

References dir.

Referenced by movementAnalysator_c::newNodeMerge().

unsigned int disassemblerNode_c::getPiecenumber ( void   )  const [inline]

return the number of pieces that are handled in this node

References piecenumber.

Referenced by disassembler_a_c::disassemble().

unsigned int disassemblerNode_c::getTrans ( unsigned int  i  )  const [inline]

return orientation of piece i

References bt_assert, dat, and piecenumber.

Referenced by create_new_params(), and movementAnalysator_c::prepare().

unsigned int disassemblerNode_c::getWaylength ( void   )  const [inline]

get the waylength from root node to this node

References waylength.

Referenced by nodeHash::insert().

int disassemblerNode_c::getX ( unsigned int  i  )  const [inline]

int disassemblerNode_c::getY ( unsigned int  i  )  const [inline]

int disassemblerNode_c::getZ ( unsigned int  i  )  const [inline]

unsigned int disassemblerNode_c::hash ( void   )  const

Return the hash value for this node.

The has value uses relative positions just like the comparison below. So if 2 nodes are equal according to the comparison below they will return the same hash value

References dat, hashValue, and piecenumber.

Referenced by nodeHash::contains(), countingNodeHash::insert(), and nodeHash::insert().

void disassemblerNode_c::incRefCount ( void   )  [inline]

Tell this node that you now have a pointer to it.

References refcount.

Referenced by disassemblerNode_c(), countingNodeHash::insert(), nodeHash::insert(), and replaceNode().

bool disassemblerNode_c::is_piece_removed ( unsigned int  nr  )  const [inline]

check if piece number nr is removed in this node

References bt_assert, dat, and piecenumber.

Referenced by disassembler_a_c::checkSubproblems(), create_new_params(), is_separation(), and disassembler_a_c::subProbGroup().

bool disassemblerNode_c::is_separation (  )  const

check, if there is any piece that is removed in this node

References is_piece_removed(), and piecenumber.

Referenced by disassembler_0_c::disassemble_rec().

void disassemblerNode_c::operator= ( const disassemblerNode_c  )  [private]

bool disassemblerNode_c::operator== ( const disassemblerNode_c b  )  const

The comparison operations using "normalized" positions.

This means all the pieces are shifted so, that the position of piece 0 is (0; 0; 0). This prevents us from shifting the whole set around without movement of the pieces relative to each other because all nodes with all pieces shifted by the same mount do are equal

References dat, and piecenumber.

void disassemblerNode_c::replaceNode ( const disassemblerNode_c n  ) 

Replace this node with the information from another node.

This will only work, if the other node actually stands the the same node but reached that position via an other way

In that case the come-from pointer is replaced and the reference counting is updated

In other cases this will do strange things or throw an assert when compiled with debug

References amount, bt_assert, comefrom, dat, decRefCount(), dir, hashValue, incRefCount(), piecenumber, and waylength.

Referenced by nodeHash::insert().

void disassemblerNode_c::set ( unsigned int  i,
int  tx,
int  ty,
int  tz 
) [inline]

set position of piece i in this node relative to the position in the come-from node

References bt_assert, comefrom, dat, hashValue, maxMove, and piecenumber.

void disassemblerNode_c::set ( unsigned int  i,
int  x,
int  y,
int  z,
unsigned int  tr 
) [inline]

set position of piece i in this node to the given values

References bt_assert, dat, hashValue, maxMove, and piecenumber.

Referenced by movementAnalysator_c::newNode().

void disassemblerNode_c::setRemove ( unsigned int  i,
int  x,
int  y,
int  z 
) [inline]

Setup piece i to be removed in this node.

The x, y and z value define the direction in which the piece is removed

References bt_assert, dat, hashValue, maxMove, and piecenumber.

Referenced by movementAnalysator_c::newNode().


Member Data Documentation

Amount of steps that pieces are moved.

There was a movement involved to get from the come-from node to this node. The amount is saved in this field

Referenced by getAmount(), and replaceNode().

The node that we came from to reach this node.

The nodes are used to save the shortest way from the start to each node. So each node saves where the way to the start is. The root node obviously has a NULL pointer here.

Referenced by disassemblerNode_c(), getComefrom(), replaceNode(), set(), and ~disassemblerNode_c().

int16_t* disassemblerNode_c::dat [private]

The position and orientation of all involved pieces.

For more memory performance I will try to limit the amount of memory required by allocating only one big chunk of memory with interleaved data at position x4 == 0 is x, ==1 is y ==2 is z ==3 is trans

a piece NOT inside the rest is signified by trans == 0xFF, the direction the pieces were move out should be obtained from dir below, when trans is 0xFF then the data fields also contain the direction, not the position of the piece

Referenced by disassemblerNode_c(), getTrans(), getX(), getY(), getZ(), hash(), is_piece_removed(), operator==(), replaceNode(), set(), setRemove(), and ~disassemblerNode_c().

unsigned int disassemblerNode_c::dir [private]

The direction pieces are moved.

The direction the pieces were moved to get from the come-from node to this node.

When several pieces were moved in different directions (coordinated motion) this field will contain an invalid value. The interpretation is up to the user

Referenced by getDirection(), and replaceNode().

unsigned int disassemblerNode_c::hashValue [mutable, private]

The has value of this node.

Because calculating the hash value is expensive and we need it pretty ofen we cache the value in here. A value of 0 means we don't know the hash value and need to calculate it.

Referenced by hash(), replaceNode(), set(), and setRemove().

const int16_t disassemblerNode_c::maxMove = 32767 [static, private]

Maximum possible distance from the original position.

we have a movement limitation that pieces must not overstep, otherwise the used int datatype will overrun, this is the value

Referenced by disassemblerNode_c(), set(), and setRemove().

Next-pointer for the hash-table lists.

These node will be saved in disassembler-hash-tables. For those tables we need a next-pointer to save lists of nodes that go into the same hash-bucket

Referenced by nodeHash::clear(), nodeHash::contains(), and nodeHash::insert().

unsigned int disassemblerNode_c::piecenumber [private]

unsigned int disassemblerNode_c::refcount [private]

A reference counter for automatic deletion of the node.

Contains the number of pointers that point to this node most of there pointers are comefrom pointers from other nodes but one increment results from the pointer inside the node lists

Referenced by decRefCount(), and incRefCount().

unsigned int disassemblerNode_c::waylength [private]

Waylenth to get from the startnode to this node.

The waylength is not identical to the number of nodes to get here. It might be. But if you want to favour certain moves you can given them a shorter step size.

Referenced by disassemblerNode_c(), getWaylength(), and replaceNode().


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

Generated on Sun Oct 10 10:02:53 2010 for BurrTools by  doxygen 1.5.8