Answers.Body: <blockquote>
    <p>What aspects of AI would be most applicable to creating a self learning game AI for a racing game (Q-Learning, NEAT etc)</p>
  </blockquote>
  
  <p>In general, you are looking at a problem that involves <a href="https://en.wikipedia.org/wiki/Sequential_decision_making" rel="nofollow noreferrer">sequential decision making</a>, in a <a href="https://en.wikipedia.org/wiki/Machine_learning" rel="nofollow noreferrer">machine learning</a> context. </p>
  
  <p>If you are wanting to build an agent that can learn by receiving screen images, then NEAT cannot scale to that complexity directly. Although there might be clever combinations of deep learning and evolutionary algorithms you could apply, the most heavily explored and likely successful solution will be found in Deep Reinforcement Learning. Algorithms like DQN, A3C, A2C, PPO . . . there are dozens to consider, but all are based around agents using samples of experience to update functions that measure either the "value" of acting in a certain way (a policy) or estimate the best policy directly.</p>
  
  <blockquote>
    <p>Could a ANN or NEAT that has learned to play Mario Kart 64 be used to learn to play another racing game?</p>
  </blockquote>
  
  <p>Within limits, yes. You will have built a system that takes pixel inputs, and outputs controller messages. If you re-start training from scratch on any compatible N64 game (with same screen resolution and same controller outputs) there is a chance it could learn to play that new game well. As other driving games on the N64 are a subset of all games, and more similar to each other than, say, a scrolling shooter or adventure game, then an agent that can successfully learn one will likely learn another too.</p>
  
  <p>It is unlikely that a Mario Kart agent will immediately be good at another game without re-training. The visual and control differences will probably be too much. You could try though. An interesting experiment would be to take your trained agent, or some part of it, and see if starting with that improves learning time on a new game. This is called Transfer Learning.</p>
  
  <blockquote>
    <p>What books/material should i read up on to undertake this project?</p>
  </blockquote>
  
  <p>You will need at least the first parts of an introduction to Reinforcement Learning. If your goal is to aim to just make the agent, then you can skip theory-heavy parts, but within limits the more theory you understand, the easier it will be to change code features towards getting something working. I can suggest the following:</p>
  
  <ul>
  <li><p>The book <a href="http://incompleteideas.net/book/the-book-2nd.html" rel="nofollow noreferrer">Sutton &amp; Barto, Reinforcement Learning: An Introduction</a> - this covers theory behind basic RL, and the online draft is free</p></li>
  <li><p><a href="http://www0.cs.ucl.ac.uk/staff/d.silver/web/Teaching.html" rel="nofollow noreferrer">A course of lectures on Reinforcement Learning from UCL</a>, by David Silver. The video lectures cover same topics as the Sutton &amp; Barto book.</p></li>
  <li><p>The book <a href="https://www.amazon.co.uk/Deep-Reinforcement-Learning-Hands-Q-networks-ebook/dp/B076H9VQH6" rel="nofollow noreferrer">Deep Reinforcement Learning Hands-On</a>, which you will need to buy. As the title suggests, it covers more practical aspects of building RL systems. It uses Python and PyTorch. As RL has become more popular in recent years, there are plenty of other similar books - I have no reason to recommend this one over them, but I am reading it at the moment, and the quality is adequate.</p></li>
  </ul>
  
  <blockquote>
    <p>What other considerations should i take throughout this project?</p>
  </blockquote>
  
  <p>Before you get started, you should know this could be an ambitious project, requiring a lot of compute time using currently-available toolkits. You need to think ahead a little, as you will be faced with these decisions:</p>
  
  <ul>
  <li>Is it more important to you to make a working bot on this problem, or more important to understand the underlying theories so that you understand what is going on. You will need to do at least a little of both, but you can go strongly in either direction:
  
  <ul>
  <li>There are enough pre-built learning agents available on the internet that you <em>might</em> have a successful project by learning just enough to wire up a copy of the game, and then letting the learning agent do its job. Would this be enough for you, would you feel that you had solved your problem?</li>
  <li>There is plenty of educational material about RL and how the maths behind it works. If you are interested in understanding that, and perhaps generating your own ideas for improvements to current algorithms, then you need to study that material harder. However, this may lead you away from your Mario Kart player goal, and you may never actually solve it, because far simpler problems that require less computing power are still actually interesting academically.</li>
  </ul></li>
  </ul>
  
  <p>In addition, I can think of the following:</p>
  
  <ul>
  <li><p>Building your Mario Kart player is a long-term goal. You will need to start with simpler agents in order to understand the techniques that you hope to apply to Mario Kart.</p></li>
  <li><p>You may need more compute power to solve this game than you have available.</p></li>
  <li><p>You will need to solve the issue of automating control of a N64 emulator. There is at least an existing emulator <a href="http://www.mupen64plus.org/" rel="nofollow noreferrer">Mupen64Plus</a> - I do not know whether it will be adequate for you, but at least one person has attempted to wrap this for automated learning, <a href="https://github.com/bzier/gym-mupen64plus" rel="nofollow noreferrer">in the gym-mupen64plus project</a>.</p></li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-05T08:46:23.937Z
Answers.LastActivityDate: 2018-10-05T08:54:33.797Z
Answers.LastEditDate: 2018-10-05T08:54:33.797Z
Answers.UserDisplayName: Neil Slater
Body: <p>I will be undertaking a project over the next year to create a self learning AI to play a racing game, currently the game will be Mario Kart 64.</p>
  
  <p>I have a few questions which will hopefully help me get started: </p>
  
  <ol>
  <li>What aspects of AI would be most applicable to creating a self learning game AI for a racing game (Q-Learning, NEAT etc)</li>
  <li>Could a ANN or NEAT that has learned to play Mario Kart 64 be used to learn to play another racing game? </li>
  <li>What books/material should i read up on to undertake this project? </li>
  <li>What other considerations should i take throughout this project? </li>
  </ol>
  
  <p>Thank you for your help! </p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-02T13:09:13.613Z
Comments.Text: Do you have access to a programmable environment for Mario Kart? Regardless of approach to AI/learning, you will need to have a system that can start the game, control it and receive feedback.
Comments.UserDisplayName: Neil Slater
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-02T13:14:28.447Z
Comments.Text: I can read the game screen in using OpenCV, apply preprocessing to produce an input for the NN and then use a python module to simulate keypresses for the game, does that sound reasonable?
Comments.UserDisplayName: Ryan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-02T13:25:05.280Z
Comments.Text: If you use the game screen as input, I guess your model won't be able to play other game than Mario Kart (but I am not an expert so maybe I am wrong...)
Comments.UserDisplayName: Jérémy Blain
Tags: <neural-networks><game-ai><python><autonomous-vehicles><neat>
Title: Creating a self learning Mario Kart game AI?
UserDisplayName: Ryan
ThreadText: # Creating a self learning Mario Kart game AI?
  
  (Asked by: username_0 on 2018-10-02)
  
  I will be undertaking a project over the next year to create a self learning AI to play a racing game, currently the game will be Mario Kart 64.
  
  I have a few questions which will hopefully help me get started:
  
  1. What aspects of AI would be most applicable to creating a self learning game AI for a racing game (Q-Learning, NEAT etc)
  2. Could a ANN or NEAT that has learned to play Mario Kart 64 be used to learn to play another racing game?
  3. What books/material should i read up on to undertake this project?
  4. What other considerations should i take throughout this project?
  
  Thank you for your help!
  
  **Tags:** neural-networks, game-ai, python, autonomous-vehicles, neat
  > **Comments:**
  > **username_1**: Do you have access to a programmable environment for Mario Kart? Regardless of approach to AI/learning, you will need to have a system that can start the game, control it and receive feedback.  
  > **username_0**: I can read the game screen in using OpenCV, apply preprocessing to produce an input for the NN and then use a python module to simulate keypresses for the game, does that sound reasonable?  
  > **username_2**: If you use the game screen as input, I guess your model won't be able to play other game than Mario Kart (but I am not an expert so maybe I am wrong...)  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-10-05. Score: 4 | Accepted answer
  
  > What aspects of AI would be most applicable to creating a self learning game AI for a racing game (Q-Learning, NEAT etc)
  
  In general, you are looking at a problem that involves [sequential decision making](https://en.wikipedia.org/wiki/Sequential_decision_making), in a [machine learning](https://en.wikipedia.org/wiki/Machine_learning) context.
  
  If you are wanting to build an agent that can learn by receiving screen images, then NEAT cannot scale to that complexity directly. Although there might be clever combinations of deep learning and evolutionary algorithms you could apply, the most heavily explored and likely successful solution will be found in Deep Reinforcement Learning. Algorithms like DQN, A3C, A2C, PPO . . . there are dozens to consider, but all are based around agents using samples of experience to update functions that measure either the "value" of acting in a certain way (a policy) or estimate the best policy directly.
  
  > Could a ANN or NEAT that has learned to play Mario Kart 64 be used to learn to play another racing game?
  
  Within limits, yes. You will have built a system that takes pixel inputs, and outputs controller messages. If you re-start training from scratch on any compatible N64 game (with same screen resolution and same controller outputs) there is a chance it could learn to play that new game well. As other driving games on the N64 are a subset of all games, and more similar to each other than, say, a scrolling shooter or adventure game, then an agent that can successfully learn one will likely learn another too.
  
  It is unlikely that a Mario Kart agent will immediately be good at another game without re-training. The visual and control differences will probably be too much. You could try though. An interesting experiment would be to take your trained agent, or some part of it, and see if starting with that improves learning time on a new game. This is called Transfer Learning.
  
  > What books/material should i read up on to undertake this project?
  
  You will need at least the first parts of an introduction to Reinforcement Learning. If your goal is to aim to just make the agent, then you can skip theory-heavy parts, but within limits the more theory you understand, the easier it will be to change code features towards getting something working. I can suggest the following:
  
  * The book [Sutton & Barto, Reinforcement Learning: An Introduction](http://incompleteideas.net/book/the-book-2nd.html) - this covers theory behind basic RL, and the online draft is free
  * [A course of lectures on Reinforcement Learning from UCL](http://www0.cs.ucl.ac.uk/staff/d.silver/web/Teaching.html), by David Silver. The video lectures cover same topics as the Sutton & Barto book.
  * The book [Deep Reinforcement Learning Hands-On](https://www.amazon.co.uk/Deep-Reinforcement-Learning-Hands-Q-networks-ebook/dp/B076H9VQH6), which you will need to buy. As the title suggests, it covers more practical aspects of building RL systems. It uses Python and PyTorch. As RL has become more popular in recent years, there are plenty of other similar books - I have no reason to recommend this one over them, but I am reading it at the moment, and the quality is adequate.
  
  > What other considerations should i take throughout this project?
  
  Before you get started, you should know this could be an ambitious project, requiring a lot of compute time using currently-available toolkits. You need to think ahead a little, as you will be faced with these decisions:
  
  * Is it more important to you to make a working bot on this problem, or more important to understand the underlying theories so that you understand what is going on. You will need to do at least a little of both, but you can go strongly in either direction:
    + There are enough pre-built learning agents available on the internet that you *might* have a successful project by learning just enough to wire up a copy of the game, and then letting the learning agent do its job. Would this be enough for you, would you feel that you had solved your problem?
    + There is plenty of educational material about RL and how the maths behind it works. If you are interested in understanding that, and perhaps generating your own ideas for improvements to current algorithms, then you need to study that material harder. However, this may lead you away from your Mario Kart player goal, and you may never actually solve it, because far simpler problems that require less computing power are still actually interesting academically.
  
  In addition, I can think of the following:
  
  * Building your Mario Kart player is a long-term goal. You will need to start with simpler agents in order to understand the techniques that you hope to apply to Mario Kart.
  * You may need more compute power to solve this game than you have available.
  * You will need to solve the issue of automating control of a N64 emulator. There is at least an existing emulator [Mupen64Plus](http://www.mupen64plus.org/) - I do not know whether it will be adequate for you, but at least one person has attempted to wrap this for automated learning, [in the gym-mupen64plus project](https://github.com/bzier/gym-mupen64plus).
  
  
  ---
  
  