Holger's
Java API

com.antelmann.game.muehle
Class MuehlePosition

java.lang.Object
  extended by com.antelmann.game.GameBoardPosition
      extended by com.antelmann.game.muehle.MuehlePosition
All Implemented Interfaces:
Serializable, 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
 

Author:
Holger Antelmann
See Also:
Serialized Form

Field Summary
static int NUMBER_OF_FIELDS
           
 
Constructor Summary
MuehlePosition(int pos)
           
 
Method Summary
 boolean connectsTo(int pos)
           
 boolean connectsTo(MuehlePosition pos)
           
 int[] getConnections()
          returns getMuehlePairs(asInteger())
static int[] getConnections(int pos)
           
 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)
           
 String toString()
           
 
Methods inherited from class com.antelmann.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
Constructor Detail

MuehlePosition

public MuehlePosition(int pos)
               throws IllegalArgumentException
Throws:
IllegalArgumentException
Method Detail

isValidPosition

public static boolean isValidPosition(int p)

getMuehlePairs

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


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.

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)

connectsTo

public boolean connectsTo(int pos)

getConnections

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


getConnections

public static int[] getConnections(int pos)

toString

public String toString()
Overrides:
toString in class GameBoardPosition


(c) 2001-2006 Holger Antelmann - all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads