Class BitSetUtils


  • public class BitSetUtils
    extends java.lang.Object
    This class implements utility methods for the B2PBitSet and BitSetState classes.
    Author:
    Alessandro Buldini, Alessandro Pomponio, Federico Zanini
    • Constructor Detail

      • BitSetUtils

        public BitSetUtils()
    • Method Detail

      • newFromServer

        public static BitSetState newFromServer​(it.unibo.ai.didattica.competition.tablut.domain.StateTablut serverState,
                                                int turnAmt)
        Returns a BitSetState instance representing the argument state and turn number.
        Parameters:
        serverState - a server state representation
        turnAmt - the turn in which the state takes place
        Returns:
        a BitSetState instance representing the state and turn
        See Also:
        BitSetState, StateTablut
      • newFromPositions

        public static B2PBitSet newFromPositions​(int[] positions)
        Creates a B2PBitSet with bits in the input indexes set to true.
        Parameters:
        positions - the indexes of the bits to be set to true
        Returns:
        a B2PBitSet instance with bits in the input indexes set to true
      • newFromPositions

        public static B2PBitSet newFromPositions​(BitSetPosition[] positions)
        Creates a B2PBitSet with bits in the input indexes set to true.
        Parameters:
        positions - a BitSetPosition array representing the indexes of the bits to be set to true
        Returns:
        a B2PBitSet instance with bits in the input indexes set to true
      • newFromServerString

        public static BitSetState newFromServerString​(java.lang.String serverString,
                                                      it.unibo.ai.didattica.competition.tablut.domain.State.Turn turn,
                                                      int turnAmt)
        Creates a BitSetState from a string representation of the game board and the corresponding player turn and turn number.
        Parameters:
        serverString - a string representation of the server state
        turn - the current player
        turnAmt - the turn number
        Returns:
        a BitSetState representing the state of the game
      • toByteString

        public static java.lang.String toByteString​(B2PBitSet bitSet)
        Converts a B2PBitSet into a printable byte string
        Parameters:
        bitSet - the bit set to stringify
        Returns:
        a printable byte string
        See Also:
        B2PBitSet
      • toBitString

        public static java.lang.String toBitString​(B2PBitSet bitSet)
        Converts a B2PBitSet into a printable bit string
        Parameters:
        bitSet - the bit set to stringify
        Returns:
        a printable bit string
        See Also:
        B2PBitSet