Class BitSetState

  • All Implemented Interfaces:
    IState

    public class BitSetState
    extends java.lang.Object
    implements IState
    This Class wraps the game state into a B2PBitSet object
    Author:
    Alessandro Buldini, Alessandro Pomponio, Federico Zanini
    • Constructor Detail

      • BitSetState

        public BitSetState​(B2PBitSet blackPawns,
                           B2PBitSet whitePawns,
                           B2PBitSet king,
                           it.unibo.ai.didattica.competition.tablut.domain.State.Turn turn)
        Constructor method to create an instance of BitSetState from the given arguments
        Parameters:
        blackPawns - the black pawns
        whitePawns - the white pawns
        king - the king
        turn - the board
        See Also:
        B2PBitSet
      • BitSetState

        public BitSetState​(B2PBitSet blackPawns,
                           B2PBitSet whitePawns,
                           B2PBitSet king,
                           it.unibo.ai.didattica.competition.tablut.domain.State.Turn turn,
                           int turnAmt)
        Constructor method to create an instance of BitSetState from the given arguments
        Parameters:
        blackPawns - the black pawns
        whitePawns - the white pawns
        king - the king
        turn - the board
        turnAmt - the turn number
        See Also:
        B2PBitSet
      • BitSetState

        public BitSetState()
        Default constructor method. White player plays first.
    • Method Detail

      • isWinningState

        public boolean isWinningState()
        Checks if the current state is a winning state
        Specified by:
        isWinningState in interface IState
        Returns:
        true if it is a winning state
      • blackHasWon

        public boolean blackHasWon()
        Checks if the black has won the game
        Specified by:
        blackHasWon in interface IState
        Returns:
        true if black has won
      • whiteHasWon

        public boolean whiteHasWon()
        Checks if the white has won the game
        Specified by:
        whiteHasWon in interface IState
        Returns:
        true if white has won
      • performMove

        public void performMove​(java.lang.String from,
                                java.lang.String to)
        Performs a given action using a specified BitSetPosition from and a specified BitSetPosition to
        Specified by:
        performMove in interface IState
        Parameters:
        from - the starting position
        to - the final position
        See Also:
        BitSetPosition
      • performMove

        public void performMove​(int from,
                                int to)
        Performs a given action using a specified from and a specified to
        Specified by:
        performMove in interface IState
        Parameters:
        from - the starting position
        to - the final position
      • simulateMove

        public IState simulateMove​(IAction action)
        Simulates a specified move from a given IAction
        Specified by:
        simulateMove in interface IState
        Parameters:
        action - the action to simulate
        Returns:
        A copy of the BitSetState after the move is performed
        See Also:
        IAction
      • getAvailablePawnMoves

        public java.util.List<IAction> getAvailablePawnMoves()
        Gets all the available moves for the pawns
        Specified by:
        getAvailablePawnMoves in interface IState
        Returns:
        A List of possible actions
        See Also:
        IAction
      • getAvailableKingMoves

        public java.util.List<IAction> getAvailableKingMoves()
        Gets all the available moves for the king
        Specified by:
        getAvailableKingMoves in interface IState
        Returns:
        A List of possible actions
        See Also:
        IAction
      • getHeuristicValue

        public int getHeuristicValue()
        Returns the heuristic value for a player in the current turn
        Specified by:
        getHeuristicValue in interface IState
        Returns:
        the heuristic value for a player in the current turn
        See Also:
        State.Turn
      • getHeuristicValueForPlayer

        public int getHeuristicValueForPlayer​(it.unibo.ai.didattica.competition.tablut.domain.State.Turn player)
        Returns the heuristic value for a given player in the current turn
        Specified by:
        getHeuristicValueForPlayer in interface IState
        Parameters:
        player - the player for which the heuristic value is evaluated
        Returns:
        the heuristic value for a given player in the current turn
        See Also:
        State.Turn
      • clone

        public IState clone()
        Specified by:
        clone in interface IState
        Overrides:
        clone in class java.lang.Object
      • getTurn

        public it.unibo.ai.didattica.competition.tablut.domain.State.Turn getTurn()
        Accesses the private field turn
        Specified by:
        getTurn in interface IState
        Returns:
        the current turn
        See Also:
        State.Turn
      • setTurn

        public void setTurn​(it.unibo.ai.didattica.competition.tablut.domain.State.Turn turn)
        Method to set the private field turn value
        Specified by:
        setTurn in interface IState
        Parameters:
        turn - the current turn
        See Also:
        State.Turn