Package sudoku

Class PlayerMemory


  • public class PlayerMemory
    extends Object
    • Field Detail

      • _rewards

        private final float[][] _rewards
        Array of reward values. The first index is for field and the second for digit.
      • _collisions

        private final boolean[][] _collisions
        Array of collisions. The first index is for field and the second for digit. If true, collision occurs.
      • _digitVector

        private final int[] _digitVector
        Vector of current sudoku digits
      • _digitPriorities

        private final int[][] _digitPriorities
        Array of digits ordered from highest to lowest priority for a specific Table. The first index is for field and the second for priority.
      • _tablePriorities

        private final int[] _tablePriorities
        Array of Table internal indices ordered from highest to lowest priority.
      • _accepted

        private final int[] _accepted
        Array of digits that Player accepted on a Table. Zero means the offer was not accepted.
      • _finished

        private final boolean[] _finished
        Array of flags indicating that a Table linked to a certain field ended negotiations.
      • _iterationId

        private int _iterationId
        Id of current iteration.
    • Constructor Detail

      • PlayerMemory

        public PlayerMemory​(int sudokuSize)
    • Method Detail

      • getSudokuSize

        public int getSudokuSize()
      • getAccepted

        public int getAccepted​(int n)
      • setAccepted

        public void setAccepted​(int n,
                                int value)
      • isFinished

        public boolean isFinished​(int n,
                                  int iterationId)
      • finish

        public void finish​(int n)
      • alreadyAccepted

        public boolean alreadyAccepted​(int digit)
      • rewardCurrentDigits

        public void rewardCurrentDigits​(float amount)
        Add reward for current combination of digits.
        Parameters:
        amount - reward added for each non-empty, mutable sudoku field
      • setDigit

        public void setDigit​(int n,
                             int digit)
        Set digit of mutable sudoku field. This should be called after accepting a digit by the Table. If the sudoku field is hard-coded (immutable), DigitImmutableException is thrown. If the digit is out of range (0 is acceptable - means the field is empty), DigitOutOfRangeException is thrown.
        Parameters:
        n - internal index of sudoku field
        digit - digit to be inserted
      • setField

        public void setField​(int n,
                             int digit,
                             boolean mask)
        Set properties of a sudoku field. Should be called only at the initialization phase. Sets both digit and mask of a field indexed internally.
        Parameters:
        n - internal index of the field
        digit - digit value to be set
        mask - mask value to be set
      • getDigit

        public int getDigit​(int n)
      • getMask

        public boolean getMask​(int n)
      • getAward

        public float getAward​(int n,
                              int digit)
      • getCollision

        public boolean getCollision​(int n,
                                    int digit)
      • setCollision

        public void setCollision​(int n,
                                 int digit)
      • setDigitColliding

        public void setDigitColliding​(int digit)
      • getTablePriority

        public int getTablePriority​(int p)
      • getDigitPriority

        public int getDigitPriority​(int n,
                                    int p)
      • prioritizeTables

        public void prioritizeTables()
      • hardReset

        public void hardReset()
        Reset memory values that are not retained between "big" iterations. Should be called each time before starting solving original sudoku (before every "big" iteration). Digit vector and mask have to be initialized for this to work.
      • softReset

        public void softReset()
        Reset memory values that are not retained between "small" iterations. Should be called each time before starting solving sudoku (before every "small" iteration). Digit vector and mask have to be initialized for this to work.
      • getIterationId

        public int getIterationId()