org.xistrat.math
Class ChessRules

java.lang.Object
  extended by org.xistrat.math.ChessRules

public class ChessRules
extends java.lang.Object

ChessRules checks that a Chess game follows the general rules.

Since:
0.5.42
See Also:
ExportData, (float, float, FigurData, int, int, int, int)

Constructor Summary
ChessRules()
           
 
Method Summary
static java.util.LinkedList<FigurData[]> createAllFig(FigurData[] _figures, java.util.LinkedList allMoves, FastFace fastFace)
          used in loading a game reconstructing all positions of all times of a game by help of the start position and all moves
static FigurData[] doMove(int mode, FigurData[] figs, int from, int to, FastFace fastFace)
          this method is used by XiStratPanel and Engine
static FigurData[] doMove(int mode, FigurData[] figs, int from, int to, FastFace fastFace, int id)
          used by F4Daemon, engine and gui
static int getNextEdge(FigurData fig, FastFace fastFace)
          Deprecated. now use getNextFEdge
static int getNextF(FigurData fig, FastFace fastFace)
          used to compute the next edge for figure D (used in ExportData for figure specific groups...)
static int getNextFEdge(FigurData fig, FastFace fastFace)
          edge labels start at 0 (for ExportData permutations at 1 though later on in the process)
static int getNextFEdge(int stand, int location, int distIE, FastFace fastFace)
          edge labels start at 0
static int getNextP(FigurData fig, FastFace fastFace)
          used to compute the next edge for figure D
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChessRules

public ChessRules()
Method Detail

doMove

public static FigurData[] doMove(int mode,
                                 FigurData[] figs,
                                 int from,
                                 int to,
                                 FastFace fastFace,
                                 int id)
used by F4Daemon, engine and gui

Parameters:
mode - 0 use null (engine) , 1 use kill (gui) , 2 use kill and do some rule checking (serverside)
figs -
from - should be changed to represent locations in order to be able to deal with piece E type as well
to - should also be changed (see from)
fastFace -
id -
Returns:
the resulting pieces

doMove

public static FigurData[] doMove(int mode,
                                 FigurData[] figs,
                                 int from,
                                 int to,
                                 FastFace fastFace)
this method is used by XiStratPanel and Engine

Parameters:
mode - 0 use null (engine) , 1 use kill (gui)
figs -
from - should be changed to represent locations in order to be able to deal with piece E type as well
to - should also be changed (see from)
fastFace -
Returns:
the resulting figures

getNextEdge

public static int getNextEdge(FigurData fig,
                              FastFace fastFace)
Deprecated. now use getNextFEdge

assumes that next stand would not be < 0 (else returns -1)

edge labels start at 0 (for permutations at 1 though)

Parameters:
fig - fig.stand is in [0, polygons-1]

getNextFEdge

public static int getNextFEdge(FigurData fig,
                               FastFace fastFace)
edge labels start at 0 (for ExportData permutations at 1 though later on in the process)

Parameters:
fig - fig.stand is in [0, faces - 1]

assumes fig is type D or E

Returns:
-1 in case next stand would be < 0, else next edge label is returned

getNextFEdge

public static int getNextFEdge(int stand,
                               int location,
                               int distIE,
                               FastFace fastFace)
edge labels start at 0

Parameters:
stand - is in [0, faces - 1]

location - may NOT point to a hole

Returns:
-1 in case next location would point to a stand with < 0

getNextP

public static int getNextP(FigurData fig,
                           FastFace fastFace)
used to compute the next edge for figure D


getNextF

public static int getNextF(FigurData fig,
                           FastFace fastFace)
used to compute the next edge for figure D (used in ExportData for figure specific groups...)


createAllFig

public static java.util.LinkedList<FigurData[]> createAllFig(FigurData[] _figures,
                                                             java.util.LinkedList allMoves,
                                                             FastFace fastFace)
used in loading a game

reconstructing all positions of all times of a game by help of the start position and all moves