Answers.Body: <p>OpenAI's Gym is a standardised API, useful for reinforcement learning, applied to a range of interesting environments many of which you can then access for free with little effort. It is very simple to use, and IMO worth learning if you want to practice RL using Python to any depth at all. You could use it to ensure you have good understanding of basic algorithms such as Q learning, independently of and before you look at using RL in a board game context.</p>
  
  <p>There are limitations for Gym and Universe when dealing with multiple agents. The API is not really designed with that in mind. For instance, there is no simple way to add two agents to an environment, you would have to write a new environment and attach an opposing agent inside of it. This is still possible, and not necessarily a terrible idea (it depends on the training setup you want to investigate).</p>
  
  <p>If you want to look into classic two-player games, and write bots like AlphaGo and Stockfish, then I would point out that:</p>
  
  <ul>
  <li><p>Game-playing bots often make extensive use of planning that can interrogate potential future game states. OpenAI's Gym doesn't prevent you doing that, but it doesn't help in any way.</p></li>
  <li><p>Algorithms for AlphaGo are public, with <a href="https://towardsdatascience.com/from-scratch-implementation-of-alphazero-for-connect4-f73d4554002a" rel="noreferrer">many nice tutorials</a>. It would be quicker to follow one of these and develop your own bot training code in most cases, than to try and adapt an OpenAI solution for single agent play.</p></li>
  <li><p>Probably the biggest time-saver you could find for any game is a rules engine that implements the board, pieces and game rules for you. If Gym already has a game environment for the game you want your bot to play, it might be worth checking the Gym code to see what it is integrating, then try to use the same library yourself, but not the Gym environment directly.</p></li>
  <li><p>Many decent game-playing algorithms don't use RL at all. You can frame most of them as <em>search</em> (finding best moves) plus <em>heuristics</em> (rating moves or positions), and can usually make independent choices for algorithms that perform each sub-task. You can apply RL so that a bot learns game heuristics, then use a more traditional search e.g. <a href="https://en.wikipedia.org/wiki/Negamax" rel="noreferrer">negamax</a> in order to make decisions during play. Or you can use any analysis of the game you like in order to generate heuristics. Very simple games usch as tic-tac-toe (noughts and crosses in UK) can just have heuristic of +1 if X has won, -1 if O has won and 0 otherwise, and still be quickly solved with a minimax search for perfect play.</p></li>
  <li><p>DeepMind's AlphaGo uses a variant of <a href="https://en.wikipedia.org/wiki/Monte_Carlo_tree_search" rel="noreferrer">MCTS</a> for the search algorithm, which can be considered a RL technique, but the lines are a bit blurry around definitions there - it is safer to say that AlphaGo incorporates MCTS as the chosen search technique for both self-play training and active play against any other opponent.</p></li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-26T16:05:13.903Z
Answers.Text: Thank you Neil. I would like to know, does the success of a strong bot creation depend mostly on hardware? Is a home laptop enough for this task?
Answers.UserDisplayName: Taissa
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-26T16:09:04.300Z
Answers.Text: @Taissa: I think that would be a completely different question. Feel free to ask on the site. However, in short if you intend to train your bot through self-learning approach similar to DeepMind's approach, then yes you will need significant hardware budget in order to compete with them. Cutting edge reinforcement learning as practiced today uses a *lot* of CPU/GPU processing
Answers.UserDisplayName: Neil Slater
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-26T11:02:41.597Z
Answers.LastActivityDate: 2020-01-26T11:42:08.760Z
Answers.LastEditDate: 2020-01-26T11:42:08.760Z
Answers.UserDisplayName: Neil Slater
Body: <p>I'm a big fan of computer board games and would like to make Python chess/go/shogi/mancala programs. Having heard of reinforcement learning, I decided to look at OpenAI Gym.</p>
  
  <p>But first of all, I would like to know, is it possible using OpenAI Gym/Universe to create a chess bot that will be nearly as strong as Stockfish and create a go bot that will play as good as AlphaGo?</p>
  
  <p>Is it worth learning OpenAI?</p>
  
Tags: <reinforcement-learning><open-ai><chess><gym><go>
Title: How powerful is OpenAI's Gym and Universe in board games area?
UserDisplayName: Taissa
ThreadText: # How powerful is OpenAI's Gym and Universe in board games area?
  
  (Asked by: username_0 on 2020-01-26)
  
  I'm a big fan of computer board games and would like to make Python chess/go/shogi/mancala programs. Having heard of reinforcement learning, I decided to look at OpenAI Gym.
  
  But first of all, I would like to know, is it possible using OpenAI Gym/Universe to create a chess bot that will be nearly as strong as Stockfish and create a go bot that will play as good as AlphaGo?
  
  Is it worth learning OpenAI?
  
  **Tags:** reinforcement-learning, open-ai, chess, gym, go
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-01-26. Score: 5 | Accepted answer
  
  OpenAI's Gym is a standardised API, useful for reinforcement learning, applied to a range of interesting environments many of which you can then access for free with little effort. It is very simple to use, and IMO worth learning if you want to practice RL using Python to any depth at all. You could use it to ensure you have good understanding of basic algorithms such as Q learning, independently of and before you look at using RL in a board game context.
  
  There are limitations for Gym and Universe when dealing with multiple agents. The API is not really designed with that in mind. For instance, there is no simple way to add two agents to an environment, you would have to write a new environment and attach an opposing agent inside of it. This is still possible, and not necessarily a terrible idea (it depends on the training setup you want to investigate).
  
  If you want to look into classic two-player games, and write bots like AlphaGo and Stockfish, then I would point out that:
  
  * Game-playing bots often make extensive use of planning that can interrogate potential future game states. OpenAI's Gym doesn't prevent you doing that, but it doesn't help in any way.
  * Algorithms for AlphaGo are public, with [many nice tutorials](https://towardsdatascience.com/from-scratch-implementation-of-alphazero-for-connect4-f73d4554002a). It would be quicker to follow one of these and develop your own bot training code in most cases, than to try and adapt an OpenAI solution for single agent play.
  * Probably the biggest time-saver you could find for any game is a rules engine that implements the board, pieces and game rules for you. If Gym already has a game environment for the game you want your bot to play, it might be worth checking the Gym code to see what it is integrating, then try to use the same library yourself, but not the Gym environment directly.
  * Many decent game-playing algorithms don't use RL at all. You can frame most of them as *search* (finding best moves) plus *heuristics* (rating moves or positions), and can usually make independent choices for algorithms that perform each sub-task. You can apply RL so that a bot learns game heuristics, then use a more traditional search e.g. [negamax](https://en.wikipedia.org/wiki/Negamax) in order to make decisions during play. Or you can use any analysis of the game you like in order to generate heuristics. Very simple games usch as tic-tac-toe (noughts and crosses in UK) can just have heuristic of +1 if X has won, -1 if O has won and 0 otherwise, and still be quickly solved with a minimax search for perfect play.
  * DeepMind's AlphaGo uses a variant of [MCTS](https://en.wikipedia.org/wiki/Monte_Carlo_tree_search) for the search algorithm, which can be considered a RL technique, but the lines are a bit blurry around definitions there - it is safer to say that AlphaGo incorporates MCTS as the chosen search technique for both self-play training and active play against any other opponent.
  
  > **Comments:**
  > **username_0**: Thank you username_1. I would like to know, does the success of a strong bot creation depend mostly on hardware? Is a home laptop enough for this task?  
  > **username_1**: @username_0: I think that would be a completely different question. Feel free to ask on the site. However, in short if you intend to train your bot through self-learning approach similar to DeepMind's approach, then yes you will need significant hardware budget in order to compete with them. Cutting edge reinforcement learning as practiced today uses a *lot* of CPU/GPU processing  
  
  ---
  
  