Player module
- class Player.Player(playerType, playerValue)
Bases:
object
This class encompases the Player object which handles the logic of automated player actions.
- Parameters
playerType (int) – type of Player (1: Random, 2: Minimax)
playerValue – number of Player (1 or 2)
- Attributes
- type (int)
Player type (1: Random, 2: Minimax)
- playerValue (int)
number of Player (1 or 2)
- oppValue (int)
number of opposing Player (1 or 2)
- get_best_move(state)
A function to return the player’s best move for a given state.
- Parameters
state (
State.State
) – State instance- Returns
column index of best move
- Return type
int
- get_col_move(state)
A function to choose a column for next move depending on the type of player.
- Parameters
state (
State.State
) – State instance- Returns
column for next move to be made
- Return type
int
- minimax(board, depth, alpha, beta, maximizingPlayer)
A function to get the best move for minimax player.
- Parameters
self (
Player.Player
) – Player instanceboard (
Board.Board
) – Board instancealpha (int) – alpha value
beta (int) – beta value
maximizingPlayer (bool) – True if player is maximizing player, False if player is minimizing player
- Returns
column - int location of best column move for minimax player value - score of board for move in returned column
- Return type
(column,value) tuple
- playerTypeStrings = {0: 'User Input', 1: 'Random', 2: 'Minimax', 3: '{ToBeImplimentedLater}'}
- random_col(state)
A function to return a random column in the given state’s board.
- Parameters
state (
State.State
) – State instance- Returns
random column on board
- Return type
int