Package b2p.state.bitboard.bitset
Class BitSetState
- java.lang.Object
-
- b2p.state.bitboard.bitset.BitSetState
-
-
Field Summary
-
Fields inherited from interface b2p.model.IState
boardDimension
-
-
Constructor Summary
Constructors Constructor Description BitSetState()
Default constructor method.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 argumentsBitSetState(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
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
blackHasWon()
Checks if the black has won the gameIState
clone()
java.util.List<IAction>
getAvailableKingMoves()
Gets all the available moves for the kingjava.util.List<IAction>
getAvailablePawnMoves()
Gets all the available moves for the pawnsB2PBitSet
getBlackPawns()
Accesses the private field black pawnsB2PBitSet
getBoard()
Accesses the private field boardint
getHeuristicValue()
Returns the heuristic value for a player in the current turnint
getHeuristicValueForPlayer(it.unibo.ai.didattica.competition.tablut.domain.State.Turn player)
Returns the heuristic value for a given player in the current turnB2PBitSet
getKing()
Accesses the private field kingit.unibo.ai.didattica.competition.tablut.domain.State.Turn
getTurn()
Accesses the private field turnB2PBitSet
getWhitePawns()
Accesses the private field white pawnsboolean
isWinningState()
Checks if the current state is a winning statevoid
performMove(int from, int to)
Performs a given action using a specified from and a specified tovoid
performMove(IAction action)
Performs a given action usingBitSetPosition
from andBitSetPosition
tovoid
performMove(java.lang.String from, java.lang.String to)
Performs a given action using a specifiedBitSetPosition
from and a specifiedBitSetPosition
tovoid
setTurn(it.unibo.ai.didattica.competition.tablut.domain.State.Turn turn)
Method to set the private field turn valueIState
simulateMove(IAction action)
Simulates a specified move from a givenIAction
boolean
whiteHasWon()
Checks if the white has won the game
-
-
-
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 pawnswhitePawns
- the white pawnsking
- the kingturn
- 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 pawnswhitePawns
- the white pawnsking
- the kingturn
- the boardturnAmt
- 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 interfaceIState
- Returns:
true
if it is a winning state
-
blackHasWon
public boolean blackHasWon()
Checks if the black has won the game- Specified by:
blackHasWon
in interfaceIState
- Returns:
true
if black has won
-
whiteHasWon
public boolean whiteHasWon()
Checks if the white has won the game- Specified by:
whiteHasWon
in interfaceIState
- Returns:
true
if white has won
-
performMove
public void performMove(IAction action)
Performs a given action usingBitSetPosition
from andBitSetPosition
to- Specified by:
performMove
in interfaceIState
- Parameters:
action
- the action to perform- See Also:
IAction
,BitSetPosition
-
performMove
public void performMove(java.lang.String from, java.lang.String to)
Performs a given action using a specifiedBitSetPosition
from and a specifiedBitSetPosition
to- Specified by:
performMove
in interfaceIState
- Parameters:
from
- the starting positionto
- 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 interfaceIState
- Parameters:
from
- the starting positionto
- the final position
-
simulateMove
public IState simulateMove(IAction action)
Simulates a specified move from a givenIAction
- Specified by:
simulateMove
in interfaceIState
- 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 interfaceIState
- 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 interfaceIState
- 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 interfaceIState
- 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 interfaceIState
- 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()
-
getBlackPawns
public B2PBitSet getBlackPawns()
Accesses the private field black pawns- Specified by:
getBlackPawns
in interfaceIState
- Returns:
B2PBitSet
containing black pawns- See Also:
B2PBitSet
-
getWhitePawns
public B2PBitSet getWhitePawns()
Accesses the private field white pawns- Specified by:
getWhitePawns
in interfaceIState
- Returns:
B2PBitSet
containing white pawns- See Also:
B2PBitSet
-
getKing
public B2PBitSet getKing()
Accesses the private field king
-
getBoard
public B2PBitSet getBoard()
Accesses the private field board
-
getTurn
public it.unibo.ai.didattica.competition.tablut.domain.State.Turn getTurn()
Accesses the private field turn
-
-