0
$\begingroup$

I have some questions about strategy to adopt regarding illagal action handling in reinforcement learning (Stable Baselines 3 / SAC algo). First is about reward shaping, second is about terminating / truncating episode when performing an illegal action.

  1. What is the good practice for illegal action penality ? Game cumulates 1 if wins and -1 if loses. I apply a -100 penality for illegal action because the evaluation is done over 100 episodes so that an illegal action cannot be compensated by some wins. Is it the good way? Should i do illegal_rew = -100 or illegal_rew = -100 - episode_cumulated_rew?

  2. Should I stop the game when performs an illegal action ? If the answer is "yes", should i terminate or truncate the episode ?

$\endgroup$

1 Answer 1

-1
$\begingroup$

Penalty for Illegal Actions:

The penalty for illegal actions is an important aspect of reinforcement learning. In your case, applying a -100 penalty for illegal actions is a reasonable approach. This is because the evaluation is done over 100 episodes, and the significant penalty ensures that an illegal action cannot be compensated by some wins Therefore, setting the illegal action penalty as illegal_rew = -100 seems like a suitable choice in my opinion.

Stopping the Game for Illegal Actions:

Regarding whether to stop the game when an illegal action is performed, it's generally advisable to terminate the episode when an illegal action occurs. This ensures that the agent learns the consequences of illegal actions and avoids further exploration of illegal action spaces. Terminating the episode upon an illegal action is a common practice in reinforcement learning to enforce the agent's adherence to the rules of the environment.

Read this tips and tricks page if you haven't already for more info.

Hope this answers your question! :)

$\endgroup$
4
  • $\begingroup$ Thanks for this very clear answer ! So termination is is preferable to truncation ? I admit I don't understand very well difference between truncation and termination (in terms of algorithm behavioural). I just know that truncation is used as a kind of timeout termintation. $\endgroup$
    – GerardL
    Commented Feb 23 at 10:03
  • $\begingroup$ Allow me to clarify; Terminating the episode involves stopping the episode immediately. This means that the current episode ends, and the agent's learning from that episode is concluded. The environment is reset, and a new episode begins. Truncation involves setting a timeout termination for the episode. If an illegal action occurs, the episode is not immediately terminated. Instead, it continues for a predefined number of steps before being forcibly terminated. Terminating ensures that the agent learns the consequences of its actions and avoids further exploration of illegal action spaces. $\endgroup$
    – RegressIt
    Commented Feb 23 at 20:12
  • $\begingroup$ Thank you again for your efficient and concise explanation. It was not clear in my mind and API' docs were not very useful about that point... Best regards. $\endgroup$
    – GerardL
    Commented Feb 24 at 10:57
  • $\begingroup$ No problem! Please mark the question as answered / upvote if you're happy with my response :) $\endgroup$
    – RegressIt
    Commented Feb 25 at 4:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.