def __init__(self, board, playerToMove, fruit_life, fruit_taken, penalty_taken): self.playerToMove = playerToMove self.pos = utils.getPlayerPos(board, playerToMove) self.rival_pos = utils.getPlayerPos(board, utils.nextTurn(playerToMove)) self.fruit_life = fruit_life self.fruit_taken = fruit_taken self.penalty_taken = penalty_taken
def set_rival_move(self, pos): """Update your info, given the new position of the rival. input: - pos: tuple, the new position of the rival. No output is expected """ rival_prev_pos = utils.getPlayerPos(self.board, 2) self.board[rival_prev_pos] = -1 # assert self.board[pos] not in [-1, 1, 2] self.board[pos] = 2
def set_game_params(self, board): """Set the game parameters needed for this player. This function is called before the game starts. (See GameWrapper.py for more info where it is called) input: - board: np.array, a 2D matrix of the board. No output is expected. """ self.board = board self.pos = utils.getPlayerPos(board, 1) self.fruit_life = 2 * min(len(self.board), len(self.board[0]))