Skip to content

Commit

Permalink
manage illegal move
Browse files Browse the repository at this point in the history
  • Loading branch information
DHDev0 authored Jan 19, 2023
1 parent af43deb commit d930293
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ Core Muzero feature:
* [x] MCTS with 0 simulation (use of prior) or any number of simulation.
* [x] Model weights automatically saved at best selfplay average reward.
* [x] Priority or Uniform for sampling in replay buffer.
* [X] Manage illegal move with negative reward.
* [X] Scale the loss using the importance sampling ratio.
* [x] Custom "Loss function" class to apply transformation and loss on label/prediction.
* [X] Load your pretrained model from tag number.
Expand Down
14 changes: 12 additions & 2 deletions game.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,19 @@ def observation(self,observation_shape=None,
#manage feedback observation
else:
state = feedback[0]
self.feedback_state = state
return state

def step(self,action):
try:
next_step = (self.env.step(action))
except:
obs = self.feedback_state
reward = min(-len(self.rewards),-self.limit_of_game_play,-1)
done = self.done
next_step = (obs,reward,done)
return next_step

def close(self):
return self.env.close()

Expand Down Expand Up @@ -229,7 +239,7 @@ def policy_step(self, root = None , temperature = 0 , feedback = None, iteration
# # # apply mouve and return variable of the env
# # # save game variable to a list to return them
#contain [observation, reward, done, info] + [meta_data for som gym env]
step_output = (self.env.step(self.action_map[selected_action]))
step_output = self.step(self.action_map[selected_action])

#Get the new observation generate by step
if self.rgb_observation :
Expand Down

0 comments on commit d930293

Please sign in to comment.