skjb / pysc2-tutorial

Tutorials for building a PySC2 bot
https://medium.com/@skjb/building-a-basic-pysc2-agent-b109cde1477c
MIT License
287 stars 85 forks source link

Army rallies aren't working correctly for me #9

Open Unclevinny opened 6 years ago

Unclevinny commented 6 years ago

When I used the latest code from https://github.com/skjb/pysc2-tutorial/blob/master/Building%20a%20Basic%20Agent/simple_agent.py, the first Marine would rally across the map alone. Then a few extra Marines would get built, but never attack. I fixed this by changing a single line:

elif obs.observation["player"][_SUPPLY_USED] == obs.observation["player"][_SUPPLY_MAX] and not self.army_rallied:

It's possible I have an error, but I can't see what it might be. Before I made the change, I noticed that the barracks often gets deselected, and Marines sometimes wouldn't build until I selected it manually. My understanding was/is that "train_marine_quick" should appear in obs.observation["available_actions"] even if the rax isn't selected. Is that correct?

skjb commented 6 years ago

It sounds like the issue is that your barracks are being deselected for some reason. You can only train marines when the barracks is selected. I would suggest continuing with the next few tutorials as they have ways to deal with deselection.