Answers.Body: <p>StarCraft II is a real time strategy game that combines fast paced micro actions with the need for high level planning and execution. StarCraft II being a popular game with millions of users it proceeds that defeating top players becomes a meaningful and measurable long term objective in AI research. </p>
  
  <p>Computer games provide a compelling solution to the issue of evaluating and comparing different learning and planning approaches on standardized tasks. They are an important source of challenges for research in AI. </p>
  
  <p>Game playing AI agents i.e. deepmind's Atarinet and DQN alongside Open AI's Dota 2 bot represent the first demonstration of a General Purpose Agent that is able to continually adapt behavior without any human intervention, a major technical step forward in the quest for general AI (Source deepmind blog).</p>
  
  <p>Computer games offer numerous advantages in AI research i.e:</p>
  
  <ol>
  <li>They have clear objective measures of success.</li>
  <li>Computer games typically output rich streams of observational data, which are ideal inputs for deep networks.</li>
  <li>They are externally defined to be difficult and interesting for a human to play. Therefore they provide an excellent test for intelligence. </li>
  <li>Games are designed to be able to run anywhere with the same interface and game dynamics. This enables running many simulations in parallel. Sharing and updating the same table throughout training.</li>
  <li>In some cases pools of superb human players exist, making it possible to benchmark against highly skilled humans.  </li>
  </ol>
  
  <p>The Starcraft challenge for reinforcement learning, introduces a taxing set of problems because it is a multi-agent problem with multiple players interacting. There is imperfect information due to a partially observed map, it has a large state space, it has delayed credit assignment requiring long term strategies. </p>
  
  <p><strong>Tools</strong></p>
  
  <p>The SC2LE Environment</p>
  
  <p>DeepMind and Blizard games have collaborated to release the SC2LE, which exposes StarCraft II as a research environment. </p>
  
  <p>The SC2LE consists of three sub-components.</p>
  
  <ol>
  <li><p>A Linux Starcraft II binary.</p></li>
  <li><p>StarCraft II API which allows programmatic control of StarCraft II. The API can be used to start the game, get observations, take actions and review replays.</p></li>
  <li><p>PySC25 which is an open source environment written in Python. It includes some mini-games and visualization tools</p></li>
  </ol>
  
  <p><strong>Open source Open AI RL environments</strong></p>
  
  <p>Universe - Universe is a software platform by Open AI for measuring and training an AI's general intelligence across games, websites and other applications. </p>
  
  <p>Gym - Open AI Gym is a toolkit for developing and comparing reinforcement learning algorithms. It makes no assumptions about the structure of your agent and is compatible with any numerical computation library such as Tensorflow or Theano. </p>
  
  <p><strong>Supervised Classification Approach</strong></p>
  
  <p>Consider this, we could decide to screen capture game sessions from expert players and use it as input to a model. The output could be the direction in which the AI agent could move. This would be a supervised classification approach. </p>
  
  <p>However, this is not an elegant solution because we are training a model not on a static dataset but a dynamic one (game environment). The training data from a game environment is stochastic/continuous meaning any number of events can occur. 
  Furthermore, humans learn most effectively by interacting with the environment. Not by watching others interact with the environment.  </p>
  
  <p><strong>Markov Decision Process</strong></p>
  
  <p>Markov Decision Processes (MDPs) provide a mathematical framework for modeling decision making in situations where outcomes are partly random and partly under the control of a decision maker i.e. game environments.</p>
  
  <p><strong>Reinforcement Learning with Deep Q-Learning</strong></p>
  
  <p>Q-Learning is a strategy that has been proven to find an optimal action selection policy for any Markov Decision Process (MDP). In Q-Learning we choose an action that maximizes future reward. The further in the future we go, the further the rewards can diverge, we resolve this by adding a discount in future rewards. </p>
  
  <blockquote>
    <p>Unlike policy gradient methods, which attempt to learn functions which directly map an observation to an action, Q-Learning attempts to learn the value of being in a given state, and taking a specific action there. (Arthur J 2016)</p>
  </blockquote>
  
  <p>The formula for Q-Learning is:</p>
  
  <blockquote>
    <p><img src="https://latex.codecogs.com/gif.latex?%5C&space;Q(s,a)&space;=&space;%5Csum_%7Bs%27%7D&space;P_a(s,s%27)&space;(R_a(s,s%27)&space;&plus;&space;%5Cgamma&space;V(s%27))" title="\ Q(s,a) = \sum_{s'} P_a(s,s') (R_a(s,s') + \gamma V(s'))" /></p>
    
    <p>Where:</p>
    
    <p><em>R</em> = Reward</p>
    
    <p><em>s</em> = State</p>
    
    <p><em>a</em> = Action</p>
    
    <p>Experience during learning is based on <em>(s, a)</em> pairs</p>
    
    <p>One has an array <em>Q</em> and uses experience to update it directly </p>
    
    <p>(Source wikipedia <a href="https://en.wikipedia.org/wiki/Markov_decision_process" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Markov_decision_process</a>)</p>
  </blockquote>
  
  <p>One of the strengths of Q-learning is that it is able to compare the expected utility of the available actions without requiring a model of the environment.</p>
  
  <p>For further reference, I recommend you look at Siraj Ravals tutorial on Deep Q-Learning </p>
  
  <p><a href="https://www.youtube.com/watch?v=79pmNdyxEGo" rel="nofollow noreferrer">https://www.youtube.com/watch?v=79pmNdyxEGo</a> and source code for the same available here <a href="https://github.com/llSourcell/deep_q_learning" rel="nofollow noreferrer">https://github.com/llSourcell/deep_q_learning</a></p>
  
  <p>Additionally I recommend the following references for more information on computer game playing AI agents. </p>
  
  <p>StarCraft II: A New Challenge for Reinforcement Learning <a href="https://arxiv.org/abs/1708.04782" rel="nofollow noreferrer">https://arxiv.org/abs/1708.04782</a></p>
  
  <p>Playing Atari with Deep Reinforcement Learning <a href="https://www.cs.toronto.edu/~vmnih/docs/dqn.pdf" rel="nofollow noreferrer">https://www.cs.toronto.edu/~vmnih/docs/dqn.pdf</a></p>
  
  <p>Human-level control through deep reinforcement learning  <a href="https://web.stanford.edu/class/psych209/Readings/MnihEtAlHassibis15NatureControlDeepRL.pdf" rel="nofollow noreferrer">https://web.stanford.edu/class/psych209/Readings/MnihEtAlHassibis15NatureControlDeepRL.pdf</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-17T18:42:24.097Z
Answers.LastActivityDate: 2018-02-20T07:37:32.120Z
Answers.LastEditDate: 2018-02-20T07:37:32.120Z
Answers.UserDisplayName: Seth Simba
Answers.Body: <p>Good to have a Starcraft question.  The game has been the subject of growing interest re: AI in recent years, possibly due to its status as king of RTS, which has led to a professional player class no doubt useful for evaluation of AI strength.</p>
  
  <p>Because, last time I checked, <a href="https://www.technologyreview.com/s/609242/humans-are-still-better-than-ai-at-starcraftfor-now/" rel="nofollow noreferrer">Humans Are Still Better Than AI at StarCraft—for Now...</a></p>
  
  <p>It's highly likely there will soon be an algorithm that can beat humans at the game, probably an extension of DeepMind's Alphas, so the clock is ticking...</p>
  
  <p>I'm personally interested in classical, generalized approaches to strategy game AI, which is archaic from the standpoint of pure strength, but interesting from a game solving perspective.  <em>(Motivations here are from a game product perspective, under the assumption that most humans don't like losing every game with no possibility of ever winning;)</em> The way I'd personally go about it would be to start thinking about how to abstract the game, generalize the map, unit densities, etc., and try to determine though AI testing if there are sound axioms. </p>
  
  <p>For superhuman strength, Deep Learning is clearly the way to go.  The recent results in Go and Chess are just the beginning of the validation of the technique.</p>
  
  <p>Speaking generally, the way I see it, you have a few ways to go: (1) bootstrap existing NN and tweak until it can beat you every time.  But I'm sure many people are already doing this; (2) try to reinvent the wheel and write your own better NN from the ground up.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-15T20:59:11.620Z
Answers.LastActivityDate: 2018-02-15T22:15:00.077Z
Answers.LastEditDate: 2018-02-15T22:15:00.077Z
Answers.UserDisplayName: DukeZhou
Body: <p>I'm interested in working on challenging AI problems, and after reading this article (<a href="https://deepmind.com/blog/deepmind-and-blizzard-open-starcraft-ii-ai-research-environment/" rel="nofollow noreferrer">https://deepmind.com/blog/deepmind-and-blizzard-open-starcraft-ii-ai-research-environment/</a>) by DeepMind and Blizzard, I think that developing a robust AI capable of learning to play Starcraft 2 with superhuman level of performance (without prior knowledge or human hard-coded heuristics) would imply a huge breakthrough in AI research.</p>
  
  <p>Sure I know this is an extremely challenging problem, and by no means I pretend to be the one solving it, but I think it's a challenge worth taking on nonetheless because the complexity of the decision making required is much closer to the real world and so this forces you to come up with much more robust, generalizable AI algorithms that could potentially be applied to other domains.</p>
  
  <p>For instance, an AI that plays Starcraft 2 would have to be able to watch the screen, identify objects, positions, identify units moving and their trajectories, update its current knowledge of the world, make predictions, make decisions, have short term and long term goals, listen to sounds (because the game includes sounds), understand natural language (to read and understand text descriptions appearing in the screen as well), it should probably be endowed also with some sort of attention mechanism to be able to pay attention to certain regions of interest of the screen, etc. So it becomes obvious that at least one would need to know about Computer Vision, Object Recognition, Knowledge Bases, Short Term / Long Term Planning, Audio Recognition, Natural Language Processing, Visual Attention Models, etc. And obviously it would not be enough to just study each area independently, it would also be necessary to come up with ways to integrate everything into a single system.</p>
  
  <p>So, does anybody know good resources with content relevant to this problem? I would appreciate any suggestions of papers, books, blogs, whatever useful resource out there (ideally state-of-the-art) which would be helpful for somebody interested in this problem.</p>
  
  <p>Thanks in advance.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-12-25T18:58:47.433Z
Comments.Text: It's not clear to me whether the question was about ways to intergrate ML, CV, knowledge bases, etc., in order to build some kind of general-purpose AI to play Starcraft, or if the question was about resources to get you started with solving Starcraft. It seems that people have tried to answer the second question, but it seems to me that you were interested in the first.
Comments.UserDisplayName: nbro
Tags: <machine-learning><ai-design><computer-vision><knowledge-representation><reasoning>
Title: Training an AI to play Starcraft 2 with superhuman level of performance?
UserDisplayName: Pablo Messina
ThreadText: # Training an AI to play Starcraft 2 with superhuman level of performance?
  
  (Asked by: username_0 on 2018-02-14)
  
  I'm interested in working on challenging AI problems, and after reading this article (<https://deepmind.com/blog/deepmind-and-blizzard-open-starcraft-ii-ai-research-environment/>) by DeepMind and Blizzard, I think that developing a robust AI capable of learning to play Starcraft 2 with superhuman level of performance (without prior knowledge or human hard-coded heuristics) would imply a huge breakthrough in AI research.
  
  Sure I know this is an extremely challenging problem, and by no means I pretend to be the one solving it, but I think it's a challenge worth taking on nonetheless because the complexity of the decision making required is much closer to the real world and so this forces you to come up with much more robust, generalizable AI algorithms that could potentially be applied to other domains.
  
  For instance, an AI that plays Starcraft 2 would have to be able to watch the screen, identify objects, positions, identify units moving and their trajectories, update its current knowledge of the world, make predictions, make decisions, have short term and long term goals, listen to sounds (because the game includes sounds), understand natural language (to read and understand text descriptions appearing in the screen as well), it should probably be endowed also with some sort of attention mechanism to be able to pay attention to certain regions of interest of the screen, etc. So it becomes obvious that at least one would need to know about Computer Vision, Object Recognition, Knowledge Bases, Short Term / Long Term Planning, Audio Recognition, Natural Language Processing, Visual Attention Models, etc. And obviously it would not be enough to just study each area independently, it would also be necessary to come up with ways to integrate everything into a single system.
  
  So, does anybody know good resources with content relevant to this problem? I would appreciate any suggestions of papers, books, blogs, whatever useful resource out there (ideally state-of-the-art) which would be helpful for somebody interested in this problem.
  
  Thanks in advance.
  
  **Tags:** machine-learning, ai-design, computer-vision, knowledge-representation, reasoning
  
  > **Comments:**
  > **username_1**: It's not clear to me whether the question was about ways to intergrate ML, CV, knowledge bases, etc., in order to build some kind of general-purpose AI to play Starcraft, or if the question was about resources to get you started with solving Starcraft. It seems that people have tried to answer the second question, but it seems to me that you were interested in the first.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2018-02-17. Score: 2
  
  StarCraft II is a real time strategy game that combines fast paced micro actions with the need for high level planning and execution. StarCraft II being a popular game with millions of users it proceeds that defeating top players becomes a meaningful and measurable long term objective in AI research.
  
  Computer games provide a compelling solution to the issue of evaluating and comparing different learning and planning approaches on standardized tasks. They are an important source of challenges for research in AI.
  
  Game playing AI agents i.e. deepmind's Atarinet and DQN alongside Open AI's Dota 2 bot represent the first demonstration of a General Purpose Agent that is able to continually adapt behavior without any human intervention, a major technical step forward in the quest for general AI (Source deepmind blog).
  
  Computer games offer numerous advantages in AI research i.e:
  
  1. They have clear objective measures of success.
  2. Computer games typically output rich streams of observational data, which are ideal inputs for deep networks.
  3. They are externally defined to be difficult and interesting for a human to play. Therefore they provide an excellent test for intelligence.
  4. Games are designed to be able to run anywhere with the same interface and game dynamics. This enables running many simulations in parallel. Sharing and updating the same table throughout training.
  5. In some cases pools of superb human players exist, making it possible to benchmark against highly skilled humans.
  
  The Starcraft challenge for reinforcement learning, introduces a taxing set of problems because it is a multi-agent problem with multiple players interacting. There is imperfect information due to a partially observed map, it has a large state space, it has delayed credit assignment requiring long term strategies.
  
  **Tools**
  
  The SC2LE Environment
  
  DeepMind and Blizard games have collaborated to release the SC2LE, which exposes StarCraft II as a research environment.
  
  The SC2LE consists of three sub-components.
  
  1. A Linux Starcraft II binary.
  2. StarCraft II API which allows programmatic control of StarCraft II. The API can be used to start the game, get observations, take actions and review replays.
  3. PySC25 which is an open source environment written in Python. It includes some mini-games and visualization tools
  
  **Open source Open AI RL environments**
  
  Universe - Universe is a software platform by Open AI for measuring and training an AI's general intelligence across games, websites and other applications.
  
  Gym - Open AI Gym is a toolkit for developing and comparing reinforcement learning algorithms. It makes no assumptions about the structure of your agent and is compatible with any numerical computation library such as Tensorflow or Theano.
  
  **Supervised Classification Approach**
  
  Consider this, we could decide to screen capture game sessions from expert players and use it as input to a model. The output could be the direction in which the AI agent could move. This would be a supervised classification approach.
  
  However, this is not an elegant solution because we are training a model not on a static dataset but a dynamic one (game environment). The training data from a game environment is stochastic/continuous meaning any number of events can occur.
  Furthermore, humans learn most effectively by interacting with the environment. Not by watching others interact with the environment.
  
  **Markov Decision Process**
  
  Markov Decision Processes (MDPs) provide a mathematical framework for modeling decision making in situations where outcomes are partly random and partly under the control of a decision maker i.e. game environments.
  
  **Reinforcement Learning with Deep Q-Learning**
  
  Q-Learning is a strategy that has been proven to find an optimal action selection policy for any Markov Decision Process (MDP). In Q-Learning we choose an action that maximizes future reward. The further in the future we go, the further the rewards can diverge, we resolve this by adding a discount in future rewards.
  
  > Unlike policy gradient methods, which attempt to learn functions which directly map an observation to an action, Q-Learning attempts to learn the value of being in a given state, and taking a specific action there. (Arthur J 2016)
  
  The formula for Q-Learning is:
  
  > ![](https://latex.codecogs.com/gif.latex?%5C&space;Q(s,a)&space;=&space;%5Csum_%7Bs%27%7D&space;P_a(s,s%27)&space;(R_a(s,s%27)&space;&plus;&space;%5Cgamma&space;V(s%27)) "\ Q(s,a) = \sum_{s'} P_a(s,s') (R_a(s,s') + \gamma V(s'))")
  >
  > Where:
  >
  > *R* = Reward
  >
  > *s* = State
  >
  > *a* = Action
  >
  > Experience during learning is based on *(s, a)* pairs
  >
  > One has an array *Q* and uses experience to update it directly
  >
  > (Source wikipedia <https://en.wikipedia.org/wiki/Markov_decision_process>)
  
  One of the strengths of Q-learning is that it is able to compare the expected utility of the available actions without requiring a model of the environment.
  
  For further reference, I recommend you look at Siraj Ravals tutorial on Deep Q-Learning
  
  <https://www.youtube.com/watch?v=79pmNdyxEGo> and source code for the same available here <https://github.com/llSourcell/deep_q_learning>
  
  Additionally I recommend the following references for more information on computer game playing AI agents.
  
  StarCraft II: A New Challenge for Reinforcement Learning <https://arxiv.org/abs/1708.04782>
  
  Playing Atari with Deep Reinforcement Learning <https://www.cs.toronto.edu/~vmnih/docs/dqn.pdf>
  
  Human-level control through deep reinforcement learning <https://web.stanford.edu/class/psych209/Readings/MnihEtAlHassibis15NatureControlDeepRL.pdf>
  
  
  ---
  
  ### Answer by username_3 on 2018-02-15. Score: 0
  
  Good to have a Starcraft question. The game has been the subject of growing interest re: AI in recent years, possibly due to its status as king of RTS, which has led to a professional player class no doubt useful for evaluation of AI strength.
  
  Because, last time I checked, [Humans Are Still Better Than AI at StarCraft—for Now...](https://www.technologyreview.com/s/609242/humans-are-still-better-than-ai-at-starcraftfor-now/)
  
  It's highly likely there will soon be an algorithm that can beat humans at the game, probably an extension of DeepMind's Alphas, so the clock is ticking...
  
  I'm personally interested in classical, generalized approaches to strategy game AI, which is archaic from the standpoint of pure strength, but interesting from a game solving perspective. *(Motivations here are from a game product perspective, under the assumption that most humans don't like losing every game with no possibility of ever winning;)* The way I'd personally go about it would be to start thinking about how to abstract the game, generalize the map, unit densities, etc., and try to determine though AI testing if there are sound axioms.
  
  For superhuman strength, Deep Learning is clearly the way to go. The recent results in Go and Chess are just the beginning of the validation of the technique.
  
  Speaking generally, the way I see it, you have a few ways to go: (1) bootstrap existing NN and tweak until it can beat you every time. But I'm sure many people are already doing this; (2) try to reinvent the wheel and write your own better NN from the ground up.
  
  
  ---
  
  