Answers.Body: <p>Keras/Tensorflow are mostly used of developing/training/deploying neural networks. For descision making problems, if you want to use machine learning, reinforcement learning is in most cases applied. Some reinforcement learning methods use neural networks (and therfore tensorflow) internally. You can check baseline implementations of different methods <a href="https://github.com/openai/baselines" rel="nofollow noreferrer">here</a>. </p>
  
  <p>When using reinfocement learnig, for most of the reinforcement learning methods, you do not need and preexisting data, but you need and environment (esentially a simulations of your game). If you interface your game to one of the baseline agents you can start the agents playing ant training ocurs during they play. You can find a tutorial to start an agent <a href="https://towardsdatascience.com/reinforcement-learning-with-openai-d445c2c687d2" rel="nofollow noreferrer">here</a>. </p>
  
  <p>If you only have a feedback (a reward) after a full game of 20 decisions, it will be really hard to train the agents, as you are facing a good example for what is called the problem of spare reward. </p>
  
  <p>There are some ways to deal with sparse reward, like <a href="https://arxiv.org/abs/1707.01495" rel="nofollow noreferrer">Hindsight Experience</a> Replay and maybe <a href="https://towardsdatascience.com/curiosity-driven-learning-made-easy-part-i-d3e5a2263359" rel="nofollow noreferrer">Curiosity</a>, but improving the density of the reward would be very beneficial.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-16T17:44:59.837Z
Answers.LastActivityDate: 2018-12-16T17:44:59.837Z
Answers.UserDisplayName: 50k4
Body: <p>I am trying to use tensorflow / keras to play a text based game. The game opposes two players that play by answering questions by choosing an answer among the proposed ones.</p>
  
  <p>Game resembles this:</p>
  
  <ol>
  <li>Questions asked from player 1, choose value {0, 1, 2}<br/></li>
  <li>Player 1 chooses answer 1<br/></li>
  <li>Questions asked from player 2, choose value {0, 1}<br/></li>
  <li>Player 2 chooses answer 0<br/>
  ( and so on )<br/></li>
  </ol>
  
  <p>The issue is that I do not have any data to use for training the agents and it not possible to evaluate each actions of the agent individually.<br /></p>
  
  <p>My idea is to get 2 agents to play against each other and evaluate them depending on who won / lost ( the games are very short with about 20 to 30 decisions made for each player ).</p>
  
  <p>The issue I have is that I do not know where to start. </p>
  
  <p>I normalized my input, but I do not know how to get the 2 agents to compete, as I do not have any training data as shown in the tutorials and the agents have to complete a full game in order to evaluate their performance.</p>
  
Tags: <tensorflow><keras><self-play>
Title: How can I oppose two AI agents with keras / tensoflow?
UserDisplayName: Matthieu Raynaud de Fitte
ThreadText: # How can I oppose two AI agents with keras / tensoflow?
  
  (Asked by: username_0 on 2018-12-14)
  
  I am trying to use tensorflow / keras to play a text based game. The game opposes two players that play by answering questions by choosing an answer among the proposed ones.
  
  Game resembles this:
  
  1. Questions asked from player 1, choose value {0, 1, 2}
  2. Player 1 chooses answer 1
  3. Questions asked from player 2, choose value {0, 1}
  4. Player 2 chooses answer 0  
     ( and so on )
  
  The issue is that I do not have any data to use for training the agents and it not possible to evaluate each actions of the agent individually.
  
  My idea is to get 2 agents to play against each other and evaluate them depending on who won / lost ( the games are very short with about 20 to 30 decisions made for each player ).
  
  The issue I have is that I do not know where to start.
  
  I normalized my input, but I do not know how to get the 2 agents to compete, as I do not have any training data as shown in the tutorials and the agents have to complete a full game in order to evaluate their performance.
  
  **Tags:** tensorflow, keras, self-play
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-12-16. Score: 1 | Accepted answer
  
  Keras/Tensorflow are mostly used of developing/training/deploying neural networks. For descision making problems, if you want to use machine learning, reinforcement learning is in most cases applied. Some reinforcement learning methods use neural networks (and therfore tensorflow) internally. You can check baseline implementations of different methods [here](https://github.com/openai/baselines).
  
  When using reinfocement learnig, for most of the reinforcement learning methods, you do not need and preexisting data, but you need and environment (esentially a simulations of your game). If you interface your game to one of the baseline agents you can start the agents playing ant training ocurs during they play. You can find a tutorial to start an agent [here](https://towardsdatascience.com/reinforcement-learning-with-openai-d445c2c687d2).
  
  If you only have a feedback (a reward) after a full game of 20 decisions, it will be really hard to train the agents, as you are facing a good example for what is called the problem of spare reward.
  
  There are some ways to deal with sparse reward, like [Hindsight Experience](https://arxiv.org/abs/1707.01495) Replay and maybe [Curiosity](https://towardsdatascience.com/curiosity-driven-learning-made-easy-part-i-d3e5a2263359), but improving the density of the reward would be very beneficial.
  
  
  ---
  
  