class Player: def __init__(self, colour): self.state = State(colour, None, None, None) def action(self): target_state = random.choice(self.state.subsequent_states()) return self.state.action_to_target_state(target_state) def update(self, colour, action): self.state.update(colour, action)
def __init__(self, colour): """ This method is called once at the beginning of the game to initialise your player. You should use this opportunity to set up your own internal representation of the game state, and any other information about the game state you would like to maintain for the duration of the game. The parameter colour will be a string representing the player your program will play as (Red, Green or Blue). The value will be one of the strings "red", "green", or "blue" correspondingly. """ self.state = State(colour, None, None)
class Player: def __init__(self, colour): self.state = State(colour, None, None, None) def action(self): depth = 3 _, target_state = best_reply_search(self.state, depth, float('-inf'), float('inf'), True) return self.state.action_to_target_state(target_state) def update(self, colour, action): self.state.update(colour, action)
class Player: def __init__(self, colour): self.state = State(colour, None, None, None) def action(self): depth = 3 _, target_state = maxn(self.state, depth) return self.state.action_to_target_state(target_state) def update(self, colour, action): self.state.update(colour, action)
class Player: def __init__(self, colour): self.state = State(colour, None, None, None) def action(self): depth = 3 _, target_state = paranoid(self.state, depth, float('-inf'), float('inf'), self.state.colour) return self.state.action_to_target_state(target_state) def update(self, colour, action): self.state.update(colour, action)
class ExamplePlayer: def __init__(self, colour): """ This method is called once at the beginning of the game to initialise your player. You should use this opportunity to set up your own internal representation of the game state, and any other information about the game state you would like to maintain for the duration of the game. The parameter colour will be a string representing the player your program will play as (Red, Green or Blue). The value will be one of the strings "red", "green", or "blue" correspondingly. """ self.state = State(colour, None, None) def action(self): """ This method is called at the beginning of each of your turns to request a choice of action from your program. Based on the current state of the game, your player should select and return an allowed action to play on this turn. If there are no allowed actions, your player must return a pass instead. The action (or pass) must be represented based on the above instructions for representing actions. """ # TODO: Decide what action to take. # Use external files to choose state target_state = self.state.subsequent_states()[0] return self.state.action_to_target_state(target_state) def update(self, colour, action): """ This method is called at the end of every turn (including your player’s turns) to inform your player about the most recent action. You should use this opportunity to maintain your internal representation of the game state and any other information about the game you are storing. The parameter colour will be a string representing the player whose turn it is (Red, Green or Blue). The value will be one of the strings "red", "green", or "blue" correspondingly. The parameter action is a representation of the most recent action (or pass) conforming to the above in- structions for representing actions. You may assume that action will always correspond to an allowed action (or pass) for the player colour (your method does not need to validate the action/pass against the game rules). """ self.state.update(colour, action)
class Player: def __init__(self, colour): self.state = State(colour, None, None, None) def action(self): best_score = float('-inf') for sub_state in self.state.subsequent_states(): sub_state.colour = self.state.colour if evaluate(sub_state) > best_score: best_score = evaluate(sub_state) target_state = sub_state target_state.colour = const.NEXT_COLOUR[self.state.colour] return self.state.action_to_target_state(target_state) def update(self, colour, action): self.state.update(colour, action)
class Player: def __init__(self, colour): # Uses wrap initial position self.state = State(colour, None, None, None) self.opening_moves = opening_moves.WRAP[self.state.colour] def action(self): while self.opening_moves: return self.opening_moves.pop(0) depth = 3 _, target_state = maxn(self.state, depth) return self.state.action_to_target_state(target_state) def update(self, colour, action): self.state.update(colour, action)
def __init__(self, colour): self.state = State(colour, None, None, None)
def __init__(self, colour): # Uses wrap initial position self.state = State(colour, None, None, None) self.opening_moves = opening_moves.WRAP[self.state.colour]