colosseumrl.envs.blokus.board module¶
Author: Caleb Pitts Date: 3/15/19
Summary: Handles state of hte board, piece placements, and valid move driver methods.
COLOR ENCODINGS 0 - Blank 1 - Red 2 - Blue 3 - Green 4 - Yellow
-
colosseumrl.envs.blokus.board.
BOARD_TO_PLAYER_OBSERVATION_ROTATION_MATRICES
= array([[[ 1, 0], [ 0, 1]], [[ 0, -1], [ 1, 0]], [[-1, 0], [ 0, -1]], [[ 0, 1], [-1, 0]]], dtype=int32)¶
-
class
colosseumrl.envs.blokus.board.
Board
(copy_from_board=None)[source]¶ Bases:
object
-
check_orientation_shifts
(player_color, piece_type, index, orientation)[source]¶ - DESCRIPTION: Shifts piece N times where N is how large the piece is. Each piece shift
is then checked to see whether it is a valid move.
- PARAMETERS: player_color: int indicating current player color
piece_type: string mapping to set of default offsets (defined in global space) index: tuple representing index coords on board orientation: string specifying the current orientation being checked
RETURNS: List of all offset lists where a shift at that index and orientation is possible
-
check_valid_corner
(board_contents, player_color, row_num, col_num)[source]¶ Checks whether all adjacent pieces are a different color to the current player’s color. Checks if any corner piece is the same color as the current player.
-
decode_color
(player_color)[source]¶ Converts int representatio of player color to string representation.
-
gather_empty_corner_indexes
(player_color)[source]¶ Returns a list of tuples with the indexes of empty corner cells that connect to the player’s color. The corner_index is not adjecent/touching any same color tiles on its sides beside its corners.
-
get_all_valid_moves
(round_count, player_color, player_pieces)[source]¶ Gathers all valid moves on the board that meet the following criteria: - Index of selected piece touches same-colored corner of a piece - Player piece does not fall outside of the board - Player piece does not overlap any of their pieces or other opponent pieces - May lay adjacent to another piece as long as its another color
-
place_piece
(x, y)[source]¶ Places piece on board by filling board_contents with the current player color
-
-
colosseumrl.envs.blokus.board.
ORIENTATIONS
= ['north', 'northeast', 'east', 'southeast', 'south', 'southwest', 'west', 'northwest']¶
-
colosseumrl.envs.blokus.board.
PIECE_TYPES
= {'domino1': array([[0, 0], [1, 0]]), 'monomino1': array([[0, 0]]), 'pentominoe1': array([[ 0, 0], [ 0, -1], [ 1, 0], [ 2, 0], [ 3, 0]]), 'pentominoe10': array([[ 0, 0], [ 1, 0], [ 1, -1], [ 1, 1], [ 2, -1]]), 'pentominoe11': array([[ 0, 0], [-1, 0], [ 1, 0], [ 0, -1], [ 0, 1]]), 'pentominoe12': array([[ 0, 0], [ 1, 0], [ 1, -1], [ 2, 0], [ 3, 0]]), 'pentominoe2': array([[ 0, 0], [ 0, -1], [ 0, 1], [ 1, 0], [ 2, 0]]), 'pentominoe3': array([[ 0, 0], [ 0, -1], [ 0, -2], [ 1, -2], [ 2, -2]]), 'pentominoe4': array([[ 0, 0], [ 1, 0], [ 1, -1], [ 2, -1], [ 3, -1]]), 'pentominoe5': array([[ 0, 0], [ 0, 1], [ 1, 0], [ 2, 0], [ 2, -1]]), 'pentominoe6': array([[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]), 'pentominoe7': array([[ 0, 0], [ 1, 0], [ 2, 0], [ 1, -1], [ 2, -1]]), 'pentominoe8': array([[ 0, 0], [ 0, 1], [ 1, 0], [ 1, -1], [ 2, -1]]), 'pentominoe9': array([[0, 0], [1, 0], [0, 1], [0, 2], [1, 2]]), 'tetrominoes1': array([[0, 0], [1, 0], [0, 1], [1, 1]]), 'tetrominoes2': array([[ 0, 0], [ 1, -1], [ 1, 0], [ 2, 0]]), 'tetrominoes3': array([[0, 0], [1, 0], [2, 0], [3, 0]]), 'tetrominoes4': array([[ 0, 0], [ 1, 0], [ 2, 0], [ 2, -1]]), 'tetrominoes5': array([[ 0, 0], [ 1, 0], [ 1, -1], [ 2, -1]]), 'trominoe1': array([[0, 0], [1, 0], [1, 1]]), 'trominoe2': array([[0, 0], [1, 0], [2, 0]])}¶
-
colosseumrl.envs.blokus.board.
PLAYER_DEFAULT_CORNERS
= [(0, 0), (19, 0), (0, 19), (19, 19)]¶
-
colosseumrl.envs.blokus.board.
PLAYER_OBSERVATION_TO_BOARD_ROTATION_MATRICES
= array([[[ 1, 0], [ 0, 1]], [[ 0, 1], [-1, 0]], [[-1, 0], [ 0, -1]], [[ 0, -1], [ 1, 0]]], dtype=int32)¶