### Getting Started ###
There are a number a libraries you can select to begin writing your bot. [Click here to get started](https://aiarena.net/wiki/bot-development/getting-started/).

### Set up Bot vs Bot locally
You can also play against publicly available bots for testing or personal amusement by using the following application [attachment:1 title:"LadderManager.zip" size]. Developed by Cryptious for SC2ai, you can load bots from various sources (see Downloadable Bots). Follow the ReadMe for instructions and troubleshooting. May requirement additional setup for bots outside of your framework.

### Downloadable Bots
- **AI Arena**  
-- [House Bots](https://aiarena.net/authors/133/): Most of the house bots were originally written by Infy & Merfolk for testing their own bots. They have kindly donated them to the community for use in testing.  
-- [Authors](https://aiarena.net/authors/): You can search bots by author and check if their bots are downloadable or by searching by
[Bots](https://aiarena.net/bots/) directly.

- **Starcraft 2 AI**  
-- You can find and check for downloadable bots within their links from [home page](https://sc2ai.net/) or by [recent matches](https://sc2ai.net/RecentMatches.php)

- **ProBots**  
-- [2020 Season 3](https://www.dropbox.com/s/d4qnw2oyp75kajr/ProBots%20Vs%20Humans%202020%20S3.zip?dl=0&file_subpath=%2Fsc2aiapp%2FBots)  
-- [2020 Season 2](https://www.dropbox.com/s/7pjvve74oq9bohk/ProBots%20Vs%20Humas%202020%20S2.zip?dl=0&file_subpath=%2Fsc2aiapp%2FBots)

### Viewing Bot matches
* **Replays**
    * [**Latest AI Arena results**](https://aiarena.net/results/?page=1)  
    * [**Latest Starcraft 2 AI matches**](https://sc2ai.net/RecentMatches.php)
* **VoDs**
    * [**AI Arena 24/7 ladder and Community Streams**](https://www.youtube.com/channel/UCMlH43XHsq1TacKm5n4Wbiw)
    * [**Starcraft 2 AI Season Tournaments**](https://www.youtube.com/channel/UCbXFERumlL7bvXxkdRrdLXQ)
    * [**Probots tournaments by ESChamp**](https://www.youtube.com/c/Eschamp/search?query=Probots)
    * [**Casting by LaughNgamez **](https://www.youtube.com/playlist?list=PLVRQoOk_ltE03RFVAbCT7eutBTz_cmQyv)

### Machine Learning
* **Reinforcement Learning**  
    * [Gym](https://gym.openai.com/): Toolkit for developing and comparing reinforcement learning algorithms  
[**An Introduction to Q-Learning** (Video)](https://www.youtube.com/watch?v=wN3rxIKmMgE)   
[**Reinforcement Learning Course - Full Machine Learning Tutorial** (Video)](https://www.youtube.com/watch?v=ELE2_Mftqoc)  
    * **Frameworks for PySC2**  
[**adept** (Repo)](https://github.com/heronsystems/adeptRL): Reinforcement Learning Framework  
[**Reaver** (Repo)](https://github.com/inoryy/reaver): Modular Deep Reinforcement Learning Framework (No longer maintained)  
    * [**SCC: an efficient deep reinforcement learning agent
mastering the game of StarCraft II** (Paper)](https://arxiv.org/pdf/2012.13169.pdf)
* [**Deep Learning with SC2** (Video)](https://pythonprogramming.net/deep-learning-starcraft-ii-ai-python-sc2-tutorial/): Deep Learning tutorial by Sentdex using the older python-sc2 framework.

# Extra resources

### [SC2MapAnalysis](https://github.com/eladyaniv01/SC2MapAnalysis)

A standalone plugin for python SC2 api maintained by EladYaniv.

### Bot Memory - The Data folder

Bots can save files to a local `data` folder and these files will persist between matches.
This is a good way to remember what worked and what didn't.

### Recognizing opponents - The Opponent ID

A unique ID for each opponent is provided as a way for bots to recognize opponents. The ID is specified when starting the bot as a command-line argument after a `--OpponentId` flag.  
`bot.exe --OpponentId 29381a9a-d299-4fb6-b225-cd455c9cc38b`  
This ID can be saved in your bot's data folder if desired.

### Sc2AI.net wiki
### ESChamp - Bits of Code

# Misc notes below - yet to be structured

## How do I know which of my units has been targeted by a Cyclone/Widowmine/etc?  
The targeted unit will gain the relevant buff.
e.g. for the Cyclone lock, it will gain the `LOCKON` buff as is listed here: <https://github.com/BurnySc2/python-sc2/blob/develop/sc2/ids/buff_id.py#L124>

## Increasing mineral gathering rates

Copy-paste, as written by ImpulseCloud (Holtan) in the sc2ai discord, starting at this message: <https://discordapp.com/channels/350289306763657218/350289306763657220/630252706023342100>  

To see how to get the fastest minerals: https://dke.maastrichtuniversity.nl/m.winands/documents/CIG2017_resourcegathering.pdf
He made one for SC2 too also, and I made some improvements to it, but haven't made any stats visualization for it
can get a 10% speedup doing sock-folding and a couple of other tricks  
I gave up before publishing anything. I did work with @yanntm(YoBot) to try to merge them into his bot. You can see some of that in https://github.com/yanntm/YoBot/blob/master/HarvesterStrategy.cpp
It does manual ReturnCargo and Harvest actions to avoid the builtin 4-5 frame delay after the actions are done before the next action is queued. It also takes advantage of the trick of "exiting" mineral-walk will 'bump' the workers away from each other due to collision-physics, so if you have two workers that are mineral-walking thru each other, you have them exit mineral-walk as they pass their center-points, and then they get 'pushed' in their path-directions faster.
and then also the 'magic-spot' trick where you have the worker sprinting to a point right in front of the mineral, so it doesn't take 2-3 extra frames to slow down before reaching (if in 'Harvest' action)  
the one problem is that since it exits mineral-walk often, it will get screwed up by units (yours or enemy) walking thru the mineral-line, so you'd want to check for non-mineral-workers closeby whenever exiting mineral-walk.
oh, using these tricks, you can also get that last load from a MULE
the speedups actually 'oversaturate' close-minerals with just 2 workers, so if you don't force-pair on the mineral, one of the two will eventually end up waiting too long and leave the mineral
you can even saturate far-minerals with just 2 workers if you use 2 speedlings to push/escort the workers back and forth (like pushing a merging-archon)
but that would get too-crowded to do for all workers, especially with the other tricks, there'd be too many collisions  
but it would immensely speedup long-distance-mining, at speedling speed
( the push/escort only works if the pushed/escorted unit doesn't have a Move command tho)