Class FastSimpleBoard

java.lang.Object
net.royalur.rules.simple.fast.FastSimpleBoard

public class FastSimpleBoard extends Object
The board of a simple game that is optimised for speed. This speed comes at the cost of error checking and convenience.
  • Field Details

    • shape

      public final BoardShape shape
    • width

      public final int width
    • height

      public final int height
    • pieces

      public final int[] pieces
      The 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

      public FastSimpleBoard(BoardShape shape)
  • Method Details

    • clear

      public void clear()
    • copyFrom

      public void copyFrom(FastSimpleBoard other)
    • copyFrom

      public void copyFrom(Board board)
    • 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

      public String toString(String linePrefix)
    • toString

      public String toString()
      Overrides:
      toString in class Object