Package net.royalur.rules.simple.fast
Class FastSimpleBoard
java.lang.Object
net.royalur.rules.simple.fast.FastSimpleBoard
The board of a simple game that is optimised for speed.
This speed comes at the cost of error checking and convenience.
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal intfinal int[]The pieces that are on all tiles of this board.final int[]final BoardShapefinal int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcalcTileIndex(int ix, int iy) voidclear()voidvoidcopyFrom(FastSimpleBoard other) intget(int tileIndex) Gets a piece from the board.booleanisTileRosette(int tileIndex) intlength()Gets the underlying length of this board.voidset(int tileIndex, int piece) toString()
-
Field Details
-
shape
-
width
public final int width -
height
public final int height -
pieces
public final int[] piecesThe pieces that are on all tiles of this board. Indexed by ix + iy * width. Empty tiles are zero. Light tiles are positive path indices + 1. Dark tiles are negative path indices - 1. -
rosetteTiles
public final int[] rosetteTiles
-
-
Constructor Details
-
FastSimpleBoard
-
-
Method Details
-
clear
public void clear() -
copyFrom
-
copyFrom
-
calcTileIndex
public int calcTileIndex(int ix, int iy) -
length
public int length()Gets the underlying length of this board. This is not the area of the board. Instead, it represents the number of indices that can be used to reference a tile on the board.- Returns:
- The underlying length of this board.
-
get
public int get(int tileIndex) Gets a piece from the board.- Parameters:
tileIndex- The tile index.- Returns:
- Zero if empty, otherwise the absolute value of the returned value gives the path index + 1, and the sign gives the player (positive is light, negative is dark).
-
set
public void set(int tileIndex, int piece) -
isTileRosette
public boolean isTileRosette(int tileIndex) -
toString
-
toString
-