Build a Reinforcement Learning Terran Agent with PySC2 2.0 framework

USEFUL LINKS FOR THE TUTORIAL

BEFORE STARTING

  • PySC2 2.0 framework installed
  • Pandas python library
  • Numpy python library
  • Basic python programming skills

1.- IMPORTS

2.- CREATE A QTABLE FOR REINFORCMENT LEARNING

Choose Action Method

Learn Method

  • s refers to the previous state
  • a is that action that was performed in that state
  • r is the reward that was received after taking the action
  • s_ is the state the bot landed in after taking the action

3.- DEFINE A BASE AGENT

Helper Functions

Returns a specific set of units of the army (applies for buildings and troops)
Returns the units that are finished and not the ones that are being created (applies for buildings and troops)
Calculate the distances between a list of units and a specified point

Specific Actions

The method that will send an idle SCV back to a mineral patch
Generate buildings (for further and deep reinforcement learning you can consider to add more type of buildings)
Create an army of marines and sending them to attack
Step method to know where our base is placed and do nothing (no operation to perform)

4.- RANDOM AGENT

5.- SMART AGENT

New Game Method

Get State Method

If you want to add more type of units or buildings and store its value, you can check the links at the top to find its function related

Step Action Method

6.- MAIN METHOD

CONCLUSIONS

References

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store