Answers.Body: <p>Both of the solutions you suggest seem to be built around the intuition that it's good to ensure that there is sufficient variety in the experiences that you provide to your RL algorithm.</p>
  
  <p>That intuition is good, but it should not come at (too much of) a cost in playing strength of the opponent. I'm afraid that your first solution may break down because of this; Tic Tac Toe is such a simple game, any agent that doesn't play optimally can really be viewed as a very poor agent... and I think minimax agents with very low limits on search depth may end up playing suboptimally. Your second solution seems better in this regard, that could help.</p>
  
  <p>For this particular case of Tic Tac Toe, I suspect you should be able to train just fine against only optimal minimax agents, as long as you make sure that those optimal minimax agents break ties randomly. In some situations, there may be multiple different actions that are all "equally optimal". Then, you'll want to make sure that your minimax agents break ties randomly, rather than always deterministically picking the same action. This can be done, for example, by making sure to always shuffle your lists of legal moves in minimax after they are generated.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-05T18:20:58.863Z
Answers.Text: Thank you for your reply. Excluding these two approaches do you have any other hint?
Answers.UserDisplayName: aprospero
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-05T18:46:31.143Z
Answers.Text: @aprospero Hmm nope don't think I got any other ideas now. By far the most common approach is still randomization of opponents selected for training - but, importantly, not **complete** randomization. Typically, in a self-play learning setting, they randomly sample one agent from a set of relatively recent "checkpoints" (the assumption being that all those relatively recent agents are still somewhat similar in strength, not going all the way back to agents in the earliest stages of a learning process).
Answers.UserDisplayName: Dennis Soemers
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-03T17:01:24.127Z
Answers.LastActivityDate: 2018-11-03T17:01:24.127Z
Answers.UserDisplayName: Dennis Soemers
Body: <p>I am implementing an actor-critic reinforcement learning algorithm for winning a two player tic-tac-toe like game. The agent is trained against a min-max player and after a number of episodes is able to learn a set of rules which lead it to winning a good majority of games.</p>
  
  <p>However, as soon as I play against the trained agent by using even a slightly different playing style, it looses miserably. In other words, it is evident the agent overfitted with respect to the deterministic behaviour of the min-max player. It is clear to me what are <a href="https://ai.stackexchange.com/questions/7963/how-can-a-reinforcement-learning-agent-generalize-if-it-is-trained-against-only">the roots of the problem</a>, but I would like to get an overview of the different methodologies which can be applied to overcome (or mitigate) this issue. </p>
  
  <p>The two solutions I would like to try are the following:<br>
  1. Training the agent with different opponents for fixed amounts of episodes (or time) each. So that for example I train the agent by using a depth 2 min-max player for the first 10000 episodes, then I use a random playing agent for the next 10000 episodes, then I use a depth 4 min-max player for other 10000 episodes and repeat the process.<br>
  2. Starting episodes from different initial configurations. In this way the agents will play a much wider set of sampled games and will be more difficult for the agent to overfit.  </p>
  
  <p>Are these two reasonable approaches? Are there other tricks/good practices to try out?</p>
  
Tags: <reinforcement-learning><overfitting>
Title: How to overcome overfitting to single player styles in reinforcement learning?
UserDisplayName: aprospero
ThreadText: # How to overcome overfitting to single player styles in reinforcement learning?
  
  (Asked by: username_0 on 2018-11-03)
  
  I am implementing an actor-critic reinforcement learning algorithm for winning a two player tic-tac-toe like game. The agent is trained against a min-max player and after a number of episodes is able to learn a set of rules which lead it to winning a good majority of games.
  
  However, as soon as I play against the trained agent by using even a slightly different playing style, it looses miserably. In other words, it is evident the agent overfitted with respect to the deterministic behaviour of the min-max player. It is clear to me what are [the roots of the problem](https://ai.stackexchange.com/questions/7963/how-can-a-reinforcement-learning-agent-generalize-if-it-is-trained-against-only), but I would like to get an overview of the different methodologies which can be applied to overcome (or mitigate) this issue.
  
  The two solutions I would like to try are the following:  
  1. Training the agent with different opponents for fixed amounts of episodes (or time) each. So that for example I train the agent by using a depth 2 min-max player for the first 10000 episodes, then I use a random playing agent for the next 10000 episodes, then I use a depth 4 min-max player for other 10000 episodes and repeat the process.  
  2. Starting episodes from different initial configurations. In this way the agents will play a much wider set of sampled games and will be more difficult for the agent to overfit.
  
  Are these two reasonable approaches? Are there other tricks/good practices to try out?
  
  **Tags:** reinforcement-learning, overfitting
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-11-03. Score: 3 | Accepted answer
  
  Both of the solutions you suggest seem to be built around the intuition that it's good to ensure that there is sufficient variety in the experiences that you provide to your RL algorithm.
  
  That intuition is good, but it should not come at (too much of) a cost in playing strength of the opponent. I'm afraid that your first solution may break down because of this; Tic Tac Toe is such a simple game, any agent that doesn't play optimally can really be viewed as a very poor agent... and I think minimax agents with very low limits on search depth may end up playing suboptimally. Your second solution seems better in this regard, that could help.
  
  For this particular case of Tic Tac Toe, I suspect you should be able to train just fine against only optimal minimax agents, as long as you make sure that those optimal minimax agents break ties randomly. In some situations, there may be multiple different actions that are all "equally optimal". Then, you'll want to make sure that your minimax agents break ties randomly, rather than always deterministically picking the same action. This can be done, for example, by making sure to always shuffle your lists of legal moves in minimax after they are generated.
  
  > **Comments:**
  > **username_0**: Thank you for your reply. Excluding these two approaches do you have any other hint?  
  > **username_1**: @aprospero Hmm nope don't think I got any other ideas now. By far the most common approach is still randomization of opponents selected for training - but, importantly, not **complete** randomization. Typically, in a self-play learning setting, they randomly sample one agent from a set of relatively recent "checkpoints" (the assumption being that all those relatively recent agents are still somewhat similar in strength, not going all the way back to agents in the earliest stages of a learning process).  
  
  ---
  
  