org.jscience.computing.game.muehle
Class MuehlePosition

java.lang.Object
  extended by org.jscience.computing.game.GameBoardPosition
      extended by org.jscience.computing.game.muehle.MuehlePosition
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class MuehlePosition
extends GameBoardPosition

The class MuehlePosition represents a Muehle game position. The representation is an integer based on the following little ASCII graphic:

 00----------01----------02  |           |           |
   |  08------09------10   |  |   |       |       |   |
   |   |  16--17--18   |   |  |   |   |       |   |   |
  07--15--23      19--11--03  |   |   |       |   |   |
   |   |  22--21--20   |   |  |   |       |       |   |
   |  14------13------12   |  |           |           |
  06----------05----------04

See Also:
Serialized Form

Field Summary
static int NUMBER_OF_FIELDS
          DOCUMENT ME!
 
Constructor Summary
MuehlePosition(int pos)
          Creates a new MuehlePosition object.
 
Method Summary
 boolean connectsTo(int pos)
          DOCUMENT ME!
 boolean connectsTo(MuehlePosition pos)
          DOCUMENT ME!
 int[] getConnections()
          returns getMuehlePairs(asInteger())
static int[] getConnections(int pos)
          DOCUMENT ME!
 int[] getMuehlePairs()
          returns getMuehlePairs(asInteger())
static int[] getMuehlePairs(int pos)
          As every potential muehle is closed by two pairs of 2 other positions having a piece of the same color, getMuehlePairs() returns an array of integers that represent the two pairs of Positions that fullfill this condition.
static boolean isValidPosition(int p)
          DOCUMENT ME!
 java.lang.String toString()
          DOCUMENT ME!
 
Methods inherited from class org.jscience.computing.game.GameBoardPosition
asInteger, equals
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NUMBER_OF_FIELDS

public static int NUMBER_OF_FIELDS
DOCUMENT ME!

Constructor Detail

MuehlePosition

public MuehlePosition(int pos)
               throws java.lang.IllegalArgumentException
Creates a new MuehlePosition object.

Parameters:
pos - DOCUMENT ME!
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!
Method Detail

isValidPosition

public static boolean isValidPosition(int p)
DOCUMENT ME!

Parameters:
p - DOCUMENT ME!
Returns:
DOCUMENT ME!

getMuehlePairs

public int[] getMuehlePairs()
returns getMuehlePairs(asInteger())

Returns:
DOCUMENT ME!

getMuehlePairs

public static int[] getMuehlePairs(int pos)
As every potential muehle is closed by two pairs of 2 other positions having a piece of the same color, getMuehlePairs() returns an array of integers that represent the two pairs of Positions that fullfill this condition.

Parameters:
pos - DOCUMENT ME!
Returns:
an int[] with 4 elememts; the first two array elements represent the first position pair to potentially close the muehle, the next two elements represent the second position pair - or null if the given pos is not valid.

connectsTo

public boolean connectsTo(MuehlePosition pos)
DOCUMENT ME!

Parameters:
pos - DOCUMENT ME!
Returns:
DOCUMENT ME!

connectsTo

public boolean connectsTo(int pos)
DOCUMENT ME!

Parameters:
pos - DOCUMENT ME!
Returns:
DOCUMENT ME!

getConnections

public int[] getConnections()
returns getMuehlePairs(asInteger())

Returns:
DOCUMENT ME!

getConnections

public static int[] getConnections(int pos)
DOCUMENT ME!

Parameters:
pos - DOCUMENT ME!
Returns:
DOCUMENT ME!

toString

public java.lang.String toString()
DOCUMENT ME!

Overrides:
toString in class GameBoardPosition
Returns:
DOCUMENT ME!