Package Phase1

Class Search

java.lang.Object
Phase1.Search

public class Search
extends java.lang.Object
Class starting the execution of the main program
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static int area
    It holds the value of the area of the grid (horizontal size * vertical size)
    static int chosenAlgorithm
    A flag that holds the value that corresponds to the algorithm used to solve the puzzle
    static boolean flag
    Flag checking if a solution has already been found
    static int horizontalGridSize
    It holds the value of the horizontal size of the grid
    static char[] input
    Input values for the search() method
    static boolean lpdone
    Flag checking if the Phase1.LandingPage and Phase1.ChoosePieces classes have already been terminated.
    static java.util.ArrayList<java.lang.String> solArr  
    static java.util.ArrayList<java.util.ArrayList<java.lang.Boolean>> solRows  
    static java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> supMat  
    static java.util.ArrayList<java.lang.String> tempArr  
    static UI ui
    Static Phase1.UI class to display the board
    static int verticalGridSize
    It holds the value of the vertical size of the grid
  • Constructor Summary

    Constructors 
    Constructor Description
    Search()  
  • Method Summary

    Modifier and Type Method Description
    static int[][] addPiece​(int[][] field, int[][] piece, int pieceID, int x, int y)
    Adds a pentomino to the position on the field (overriding current board at that position) - non-burte-force method
    static int algorithmX​(java.util.ArrayList<java.util.ArrayList<java.lang.Boolean>> matrix, int row, int col, java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> suppMat)
    Takes the possibilities matrix and outputs a solution for that matrix
    static int algorithmX​(java.util.ArrayList<java.util.ArrayList<java.lang.Boolean>> matrix, java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> suppMat)
    Turns the pentomino problem into an exact cover problem and solves it by iterating over the matrix of possible position of any pentomino
    static java.util.ArrayList<java.util.ArrayList<java.lang.Boolean>> buildMatrix​(int[][] field)
    Builds the matrix
    static void createWindow()
    A method responsible for creating the window with the game solver, that is being displayed after all settings are inputted by the user
    static void deleteColumn​(int index, java.util.ArrayList<java.util.ArrayList<java.lang.Boolean>> m)  
    static void deleteRow​(int index, java.util.ArrayList<java.util.ArrayList<java.lang.Boolean>> m)  
    static void main​(java.lang.String[] args)
    Main function.
    static void search()
    Helper function that starts the solving process with the user-chosen algorithm
    static void wipeField​(int[][] field)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • horizontalGridSize

      public static int horizontalGridSize
      It holds the value of the horizontal size of the grid
    • verticalGridSize

      public static int verticalGridSize
      It holds the value of the vertical size of the grid
    • area

      public static int area
      It holds the value of the area of the grid (horizontal size * vertical size)
    • input

      public static char[] input
      Input values for the search() method
    • supMat

      public static java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> supMat
    • solRows

      public static java.util.ArrayList<java.util.ArrayList<java.lang.Boolean>> solRows
    • tempArr

      public static java.util.ArrayList<java.lang.String> tempArr
    • solArr

      public static java.util.ArrayList<java.lang.String> solArr
    • ui

      public static UI ui
      Static Phase1.UI class to display the board
    • flag

      public static boolean flag
      Flag checking if a solution has already been found
    • chosenAlgorithm

      public static int chosenAlgorithm
      A flag that holds the value that corresponds to the algorithm used to solve the puzzle
    • lpdone

      public static boolean lpdone
      Flag checking if the Phase1.LandingPage and Phase1.ChoosePieces classes have already been terminated.
      Until it is the case, the Phase1.Search class waits for their termination.
  • Constructor Details

  • Method Details

    • createWindow

      public static void createWindow()
      A method responsible for creating the window with the game solver, that is being displayed after all settings are inputted by the user
    • search

      public static void search()
      Helper function that starts the solving process with the user-chosen algorithm
    • addPiece

      public static int[][] addPiece​(int[][] field, int[][] piece, int pieceID, int x, int y)
      Adds a pentomino to the position on the field (overriding current board at that position) - non-burte-force method
      Parameters:
      field - the field to put the game piece on
      piece - array holding the currently considered piece's state
      pieceID - the ID of piece currently looked at
      x - helper variable keeping track of the position in the field array
      y - helper variable keeping track of the position in the field array
    • algorithmX

      public static int algorithmX​(java.util.ArrayList<java.util.ArrayList<java.lang.Boolean>> matrix, java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> suppMat)
      Turns the pentomino problem into an exact cover problem and solves it by iterating over the matrix of possible position of any pentomino
    • algorithmX

      public static int algorithmX​(java.util.ArrayList<java.util.ArrayList<java.lang.Boolean>> matrix, int row, int col, java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> suppMat)
      Takes the possibilities matrix and outputs a solution for that matrix
      Parameters:
      matrix - the possibilities matrix
      row - currently considered row
      col - currently considered column
      suppMat - support matrix
      Returns:
      integer
    • deleteRow

      public static void deleteRow​(int index, java.util.ArrayList<java.util.ArrayList<java.lang.Boolean>> m)
      Parameters:
      index - : index of the row to be deleted
      m - : the array to delete the row from
    • deleteColumn

      public static void deleteColumn​(int index, java.util.ArrayList<java.util.ArrayList<java.lang.Boolean>> m)
      Parameters:
      index - : index of the column to be deleted
      m - : the array to delete the column from
    • wipeField

      public static void wipeField​(int[][] field)
    • buildMatrix

      public static java.util.ArrayList<java.util.ArrayList<java.lang.Boolean>> buildMatrix​(int[][] field)
      Builds the matrix
      Parameters:
      field - : the field to build the base matrix for
      Returns:
      matrix with all possible placements of all chosen pentominoes
    • main

      public static void main​(java.lang.String[] args)
      Main function. Needs to be executed to start any algorithm
      Parameters:
      args - default parameter, not used by the program