Exemple #1
0
    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 (White or Black). The value will be one of the strings "white" or
        "black" correspondingly.

        The parameter action is a representation of the most recent action
        conforming to the spec's instructions for representing actions.

        You may assume that action will always correspond to an allowed action
        for the player colour (your method does not need to validate the action
        against the game rules).
        """
        # TODO: Update state representation in response to action.
        self.player_prev = deepcopy(self.player)
        self.opponent_prev = deepcopy(self.opponent)

        # Implementing suitable action update
        if action[0]=="MOVE":
            current_player, current_opponent = update_move(self, colour, action)
        else:
            current_player, current_opponent = update_boom(self, colour, action)

        self.turn += 1
        self.player = current_player
        self.opponent = current_opponent
Exemple #2
0
def get_direct_cost(player,action):
    """Greedy cost: player_loss_tokens - opponent_loss_tokens"""
    if action[0] == 'BOOM':
        player_copy = deepcopy(player)
        boom_player, boom_opponent = f.update_boom(player_copy, player.color, action)
        #boom_player, boom_opponent = f.update_boom(player, player.color, action)
        total_token_player, total_token_opponent = f.get_total_tokens(boom_player), f.get_total_tokens(boom_opponent)
        #print(total_token_player,total_token_opponent)
        total_past_player, total_past_opponent = f.get_total_tokens(player.player), f.get_total_tokens(player.opponent)
        #print(total_past_player,total_past_opponent)
        delta_player = total_token_player - total_past_player
        delta_opponent = total_token_opponent - total_past_opponent
        return delta_opponent - delta_player
    else:
        return 0
Exemple #3
0
import utils.functionality as f

player = Player('white')
available = f.get_available_action(player)
clusters = f.get_clusters(player)
print(*available, sep='\n')
print(*clusters, sep='\n')

boom = ('BOOM', (0, 0))

move1 = ("MOVE", 1, (3, 1), (4, 1))
move2 = ("MOVE", 2, (4, 1), (4, 3))
move3 = ("MOVE", 1, (4, 3), (4, 5))
boom4 = ('BOOM', (4, 5))

f.update_move(player, 'white', move1)
f.update_move(player, 'white', move2)
f.update_move(player, 'white', move3)

print(player)

available = f.get_available_action(player)
opponent = f.get_opponent_action(player)

print(*available, sep='\n')
#print(*opponent,  sep='\n')

f.update_boom(player, 'white', boom4)

print(player)