Class GomokuBoard

java.lang.Object
GomokuBoard

public class GomokuBoard extends Object
  • Field Details

    • firstCell

      private GomokuCell firstCell
      The firstcell in the board, at the top left of the board.
    • boardWidth

      private int boardWidth
      The width of the GomokuBoard.
    • boardHeight

      private int boardHeight
      The height of the GomokuBoard.
  • Constructor Details

    • GomokuBoard

      public GomokuBoard(int width, int height)
      This constructor take the width and the height to creat a board of gomoku.
      Parameters:
      width - Size of width.
      height - Size of height.
    • GomokuBoard

      public GomokuBoard(int width, int height, Color[][] colors)
      This constructor take the width and the height to creat a board of gomoku.
      Parameters:
      width - Size of width.
      height - Size of height.
      colors - Is colors of cells after load a game.
  • Method Details

    • main

      public static void main(String[] args)
    • genCells

      private void genCells(int width, int height, Color[][] colors)
      This method gen all cells in the board and link each other.
      Parameters:
      width - Size of width.
      height - Size of height.
      colors - Array of Color.
    • get

      public GomokuCell get(int x, int y)
      This method get a cell in specific position in the board.
      Parameters:
      x - The position x on the board.
      y - The position y on the board.
      Returns:
      GomokuCell in the position.
    • getAllsCells

      private GomokuCell[][] getAllsCells()
      This method return all cells in the board in the order.
      Returns:
      All cells with a array 2D.
    • getPlayableCells

      public List<GomokuCell> getPlayableCells()
      This method return a list of playable cell.
      Returns:
      List of GomokuCell wich all is playable.
    • countAlignedCells

      public Map<Cardinal,Integer> countAlignedCells(GomokuCell cell)
      This method return a Map of number aligned cells.
      Parameters:
      cell - A cell.
      Returns:
      Map of number aligned cells.
    • countMax

      public int countMax(Map<Cardinal,Integer> mapColor)
      This method return the number max of the aligned Cells.
      Parameters:
      mapColor - A map of number aligned cells.
      Returns:
      int, the number max of the aligned Cells.
    • toString

      public String toString()
      This method print the board cell by cell with change line when the line is finished.
      Overrides:
      toString in class Object