Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

Move Class Reference

This class represents a single move of the keeper. More...

#include <move.h>

List of all members.

Public Methods

 Move ()
 Move (QPoint from, AtomicMove atomic_move, bool stone_pushed)
 Move (QPoint from, QPoint to, bool stone_pushed)
 Move (QDataStream &stream)
bool isEmpty () const
QPoint from () const
QPoint to () const
bool stonePushed () const
bool isAtomicMove () const
AtomicMove atomicMove () const
bool operator== (Move const &other_move) const
bool operator!= (Move const &other_move) const
QPoint diff () const
QPoint diffSign () const
void reverse ()
QString toText () const
void writeToStream (QDataStream &stream) const

Private Methods

int sign (int number) const

Private Attributes

QPoint m_from
QPoint m_to
bool m_stone_pushed


Detailed Description

This class represents a single move of the keeper.

A single move may consist of more than one atomic move (an atomic move is a move one field left, up, right or down). If you want to get the atomic moves for a move, look at the documentation of Map (because they may depend on the layout of the map).

For a non pushing move (a move were the keeper does not pushes a stone) there are no restrictions, while for a pushing move we are only allowed to move in one direction. For example:

 Move move1(QPoint(1, 0), QPoint(7, 12), false); // This is OK.
 Move move2(QPoint(1, 0), QPoint(3, 0), true);   // This is also OK.
 Move move3(QPoint(1, 0), QPoint(1, 7), true);   // And so is this.
 Move move4(QPoint(1, 0), QPoint(7, 12), true);  // But this is an error!

Author:
Ralf Schmelter (ralfs@pc2a.chemie.uni-dortmund.de).
Version:
0.1


Constructor & Destructor Documentation

Move::Move
 

Constructs an empty move (a move from (0, 0) to (0, 0)).

Move::Move QPoint from,
AtomicMove atomic_move,
bool stone_pushed
 

Constructs the move.

Parameters:
from   The start field.
atomic_move   The AtomicMove made from the start field.
stone_pushed   If true, we pushed a stone during the move.

Move::Move QPoint from,
QPoint to,
bool stone_pushed
 

Constructs the move.

Parameters:
from   The start field of the move.
to   The end field of the move.
stone_pushed   If true, we pushed a stone during the move.

Move::Move QDataStream & stream
 

Constructs the move by reading it from a data stream.

Parameters:
stream   The stream to use.


Member Function Documentation

AtomicMove Move::atomicMove const
 

Returns a code for the move.

Note that the move <e>must</e> be an atomic move!

QPoint Move::diff const
 

Returns to() - from().

QPoint Move::diffSign const
 

Returns the sign (-1, 0 or 1) of every element in diff().

QPoint Move::from const
 

Returns the from point of the move.

bool Move::isAtomicMove const
 

Returns true, if the move is an atomic move (the keeper moves only one field).

bool Move::isEmpty const
 

Returns true, if the move is empty (meaning no movement of the keeper is involved).

bool Move::operator!= Move const & other_move const
 

Returns true, if two moves are unequal.

bool Move::operator== Move const & other_move const
 

Returns true, if two moves are equal.

void Move::reverse
 

Swaps from and to.

int Move::sign int number const [private]
 

Is there really no sign function? Hard to belive.

bool Move::stonePushed const
 

Returns true, if the move was a stone move.

QPoint Move::to const
 

Returns the to point of the move.

QString Move::toText const
 

Returns a human readable representation of the move,.

void Move::writeToStream QDataStream & stream const
 

Writes the move to a QDataStream.

Note that the x and y componets of the from and to position of the move must be in the range [0:128[. This should be no problem since the map is restricted to this size also.

Parameters:
stream   The stream to use.


Member Data Documentation

QPoint Move::m_from [private]
 

The from point.

bool Move::m_stone_pushed [private]
 

Are we pushing a stone?

QPoint Move::m_to [private]
 

The to point.


The documentation for this class was generated from the following file:
Generated at Sun Jan 6 18:49:12 2002 for EasySok by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001