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 booleanblackHasWon()Checks if the black has won the gameIStateclone()java.util.List<IAction>getAvailableKingMoves()Gets all the available moves for the kingjava.util.List<IAction>getAvailablePawnMoves()Gets all the available moves for the pawnsB2PBitSetgetBlackPawns()Accesses the private field black pawnsB2PBitSetgetBoard()Accesses the private field boardintgetHeuristicValue()Returns the heuristic value for a player in the current turnintgetHeuristicValueForPlayer(it.unibo.ai.didattica.competition.tablut.domain.State.Turn player)Returns the heuristic value for a given player in the current turnB2PBitSetgetKing()Accesses the private field kingit.unibo.ai.didattica.competition.tablut.domain.State.TurngetTurn()Accesses the private field turnB2PBitSetgetWhitePawns()Accesses the private field white pawnsbooleanisWinningState()Checks if the current state is a winning statevoidperformMove(int from, int to)Performs a given action using a specified from and a specified tovoidperformMove(IAction action)Performs a given action usingBitSetPositionfrom andBitSetPositiontovoidperformMove(java.lang.String from, java.lang.String to)Performs a given action using a specifiedBitSetPositionfrom and a specifiedBitSetPositiontovoidsetTurn(it.unibo.ai.didattica.competition.tablut.domain.State.Turn turn)Method to set the private field turn valueIStatesimulateMove(IAction action)Simulates a specified move from a givenIActionbooleanwhiteHasWon()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:
isWinningStatein interfaceIState- Returns:
trueif it is a winning state
-
blackHasWon
public boolean blackHasWon()
Checks if the black has won the game- Specified by:
blackHasWonin interfaceIState- Returns:
trueif black has won
-
whiteHasWon
public boolean whiteHasWon()
Checks if the white has won the game- Specified by:
whiteHasWonin interfaceIState- Returns:
trueif white has won
-
performMove
public void performMove(IAction action)
Performs a given action usingBitSetPositionfrom andBitSetPositionto- Specified by:
performMovein 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 specifiedBitSetPositionfrom and a specifiedBitSetPositionto- Specified by:
performMovein 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:
performMovein interfaceIState- Parameters:
from- the starting positionto- the final position
-
simulateMove
public IState simulateMove(IAction action)
Simulates a specified move from a givenIAction- Specified by:
simulateMovein interfaceIState- Parameters:
action- the action to simulate- Returns:
- A copy of the
BitSetStateafter the move is performed - See Also:
IAction
-
getAvailablePawnMoves
public java.util.List<IAction> getAvailablePawnMoves()
Gets all the available moves for the pawns- Specified by:
getAvailablePawnMovesin interfaceIState- Returns:
- A
Listof possible actions - See Also:
IAction
-
getAvailableKingMoves
public java.util.List<IAction> getAvailableKingMoves()
Gets all the available moves for the king- Specified by:
getAvailableKingMovesin interfaceIState- Returns:
- A
Listof possible actions - See Also:
IAction
-
getHeuristicValue
public int getHeuristicValue()
Returns the heuristic value for a player in the current turn- Specified by:
getHeuristicValuein 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:
getHeuristicValueForPlayerin 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:
getBlackPawnsin interfaceIState- Returns:
B2PBitSetcontaining black pawns- See Also:
B2PBitSet
-
getWhitePawns
public B2PBitSet getWhitePawns()
Accesses the private field white pawns- Specified by:
getWhitePawnsin interfaceIState- Returns:
B2PBitSetcontaining 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
-
-