gym_splendor_code/envs/splendor.py
def step(self, mode, action: Action, return_observation=True, ensure_correctness = False):
        """
        Executes action on the environment. Action is performed on the current state of the game.


        The are two modes for is_done: instant_end - the episode ends instantly when any player reaches the number of
        points equal POINTS_TO_WIN and let_all_move - when some player reaches POINTS_TO_WIN we allow all players to move
        (till the end of round) and then we end the episode. Reward: 1 if the action gives POINTS_TO_WIN to the player
        and episode is not yet ended (taking actions when episode ended is considered as loosing), -1 if episode ended,
        0 if episode is not yet ended and the action does not give enough points to the player.

        :param
        action: action to take
        ensure_correctness: True if you want the enivornment check if the action is legal, False if you are sure
        :return: observation, reward, is_done, info
        """
        """Performs one action on the current current_state of the game. """
        info = {}
        if action is not None:
            if ensure_correctness:
                self.update_actions()
                assert self.action_space.contains(action), '{} is not valid action'.format(action)
            action.execute(self.current_state_of_the_game)

        # We find the reward:
        reward = 0

        if action is None:
            info = {'Warning' : 'There was no action.'}
            self.is_done = True
            self.first_winner = self.current_state_of_the_game.previous_player_id()
            reward = -1


        #if self.first_winner is not None:
        if self.current_state_of_the_game.previous_player_id() == self.first_winner:
            reward = 1
        if self.current_state_of_the_game.previous_player_id() != self.first_winner:
            reward = -1

        if self.first_winner is None:
            if not self.is_done:
                if self.current_state_of_the_game.previous_players_hand().number_of_my_points() >= POINTS_TO_WIN:
                    reward = 1
                    self.first_winner = self.current_state_of_the_game.previous_player_id()
                    self.is_done = True

        if return_observation:
            if mode == 'deterministic':
                observation_to_show = DeterministicObservation(self.current_state_of_the_game)
            if mode == 'stochastic':
                observation_to_show = StochasticObservation(self.current_state_of_the_game)
            return observation_to_show, reward, self.is_done, {'winner_id' : self.first_winner}

        if return_observation == False:
            return None, reward, self.is_done, {'winner_id' : self.first_winner}

        Executes action on the environment. Action is performed on the current state of the game.


        The are two modes for is_done: instant_end - the episode ends instantly when any player reaches the number of
        points equal POINTS_TO_WIN and let_all_move - when some player reaches POINTS_TO_WIN we allow all players to move
        (till the end of round) and then we end the episode. Reward: 1 if the action gives POINTS_TO_WIN to the player
        and episode is not yet ended (taking actions when episode ended is considered as loosing), -1 if episode ended,
        0 if episode is not yet ended and the action does not give enough points to the player.

        :param
        action: action to take
        ensure_correctness: True if you want the enivornment check if the action is legal, False if you are sure
        :return: observation, reward, is_done, info
        
Executes action on the environment. Action is performed on the current state of the game.
The are two modes for is_done: instant_end - the episode ends instantly when any player reaches the number of
points equal POINTS_TO_WIN and let_all_move - when some player reaches POINTS_TO_WIN we allow all players to move
(till the end of round) and then we end the episode. Reward: 1 if the action gives POINTS_TO_WIN to the player
and episode is not yet ended (taking actions when episode ended is considered as loosing), -1 if episode ended,
0 if episode is not yet ended and the action does not give enough points to the player.
Executes action on the environment . Action is performed on the current state of the game . The are two modes for is_done : instant_end - the episode ends instantly when any player reaches the number of points equal POINTS_TO_WIN and let_all_move - when some player reaches POINTS_TO_WIN we allow all players to move ( till the end of round ) and then we end the episode . Reward : 1 if the action gives POINTS_TO_WIN to the player and episode is not yet ended ( taking actions when episode ended is considered as loosing ) - 1 if episode ended 0 if episode is not yet ended and the action does not give enough points to the player .
def step(self, mode, action: Action, return_observation=True, ensure_correctness = False):
        info = {}
        if action is not None:
            if ensure_correctness:
                self.update_actions()
                assert self.action_space.contains(action), '{} is not valid action'.format(action)
            action.execute(self.current_state_of_the_game)
        reward = 0
        if action is None:
            info = {'Warning' : 'There was no action.'}
            self.is_done = True
            self.first_winner = self.current_state_of_the_game.previous_player_id()
            reward = -1
        if self.current_state_of_the_game.previous_player_id() == self.first_winner:
            reward = 1
        if self.current_state_of_the_game.previous_player_id() != self.first_winner:
            reward = -1
        if self.first_winner is None:
            if not self.is_done:
                if self.current_state_of_the_game.previous_players_hand().number_of_my_points() >= POINTS_TO_WIN:
                    reward = 1
                    self.first_winner = self.current_state_of_the_game.previous_player_id()
                    self.is_done = True
        if return_observation:
            if mode == 'deterministic':
                observation_to_show = DeterministicObservation(self.current_state_of_the_game)
            if mode == 'stochastic':
                observation_to_show = StochasticObservation(self.current_state_of_the_game)
            return observation_to_show, reward, self.is_done, {'winner_id' : self.first_winner}
        if return_observation == False:
            return None, reward, self.is_done, {'winner_id' : self.first_winner}
def step ( self , mode , action : Action , return_observation = True , ensure_correctness = False ) : """Performs one action on the current current_state of the game. """ info = { } if action is not None : if ensure_correctness : self . update_actions ( ) assert self . action_space . contains ( action ) , '{} is not valid action' . format ( action ) action . execute ( self . current_state_of_the_game ) reward = 0 if action is None : info = { 'Warning' : 'There was no action.' } self . is_done = True self . first_winner = self . current_state_of_the_game . previous_player_id ( ) reward = - 1 if self . current_state_of_the_game . previous_player_id ( ) == self . first_winner : reward = 1 if self . current_state_of_the_game . previous_player_id ( ) != self . first_winner : reward = - 1 if self . first_winner is None : if not self . is_done : if self . current_state_of_the_game . previous_players_hand ( ) . number_of_my_points ( ) >= POINTS_TO_WIN : reward = 1 self . first_winner = self . current_state_of_the_game . previous_player_id ( ) self . is_done = True if return_observation : if mode == 'deterministic' : observation_to_show = DeterministicObservation ( self . current_state_of_the_game ) if mode == 'stochastic' : observation_to_show = StochasticObservation ( self . current_state_of_the_game ) return observation_to_show , reward , self . is_done , { 'winner_id' : self . first_winner } if return_observation == False : return None , reward , self . is_done , { 'winner_id' : self . first_winner }
Executes action on the environment.
Executes action on the environment .
"""
        Executes action on the environment. Action is performed on the current state of the game.


        The are two modes for is_done: instant_end - the episode ends instantly when any player reaches the number of
        points equal POINTS_TO_WIN and let_all_move - when some player reaches POINTS_TO_WIN we allow all players to move
        (till the end of round) and then we end the episode. Reward: 1 if the action gives POINTS_TO_WIN to the player
        and episode is not yet ended (taking actions when episode ended is considered as loosing), -1 if episode ended,
        0 if episode is not yet ended and the action does not give enough points to the player.

        :param
        action: action to take
        ensure_correctness: True if you want the enivornment check if the action is legal, False if you are sure
        :return: observation, reward, is_done, info
        """ """Performs one action on the current current_state of the game. """ # We find the reward: #if self.first_winner is not None:
observation, reward, is_done, info
observation reward is_done info
self
mode
action
Action
action to take
ensure_correctness: True if you want the enivornment check if the action is legal, False if you are sure
action to take ensure_correctness : True if you want the enivornment check if the action is legal False if you are sure
return_observation
ensure_correctness