• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 18:57
CEST 00:57
KST 07:57
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
BGE Stara Zagora 2025: Info & Preview27Code S RO12 Preview: GuMiho, Bunny, SHIN, ByuN3The Memories We Share - Facing the Final(?) GSL46Code S RO12 Preview: Cure, Zoun, Solar, Creator4[ASL19] Finals Preview: Daunting Task30
Community News
[BSL20] ProLeague: Bracket Stage & Dates9GSL Ro4 and Finals moved to Sunday June 15th12Weekly Cups (May 27-June 1): ByuN goes back-to-back0EWC 2025 Regional Qualifier Results26Code S RO12 Results + RO8 Groups (2025 Season 2)3
StarCraft 2
General
The SCII GOAT: A statistical Evaluation what is flash bitcoin BGE Stara Zagora 2025: Info & Preview Magnus Carlsen and Fabi review Clem's chess game. Jim claims he and Firefly were involved in match-fixing
Tourneys
Bellum Gens Elite: Stara Zagora 2025 Sparkling Tuna Cup - Weekly Open Tournament SOOPer7s Showmatches 2025 Master Swan Open (Global Bronze-Master 2) $5,100+ SEL Season 2 Championship (SC: Evo)
Strategy
[G] Darkgrid Layout Simple Questions Simple Answers [G] PvT Cheese: 13 Gate Proxy Robo
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 477 Slow and Steady Mutation # 476 Charnel House Mutation # 475 Hard Target Mutation # 474 Futile Resistance
Brood War
General
Mihu vs Korea Players Statistics BGH auto balance -> http://bghmmr.eu/ BW General Discussion [BSL20] ProLeague: Bracket Stage & Dates Will foreigners ever be able to challenge Koreans?
Tourneys
[ASL19] Grand Finals NA Team League 6/8/2025 [Megathread] Daily Proleagues [BSL20] ProLeague Bracket Stage - Day 2
Strategy
I am doing this better than progamers do. [G] How to get started on ladder as a new Z player
Other Games
General Games
Armies of Exigo - YesYes? Nintendo Switch Thread Stormgate/Frost Giant Megathread What do you want from future RTS games? Path of Exile
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
LiquidLegends to reintegrate into TL.net
Heroes of the Storm
Heroes of the Storm 2.0 Simple Questions, Simple Answers
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread Vape Nation Thread European Politico-economics QA Mega-thread
Fan Clubs
Maru Fan Club Serral Fan Club
Media & Entertainment
Korean Music Discussion [Manga] One Piece
Sports
2024 - 2025 Football Thread Formula 1 Discussion NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread Cleaning My Mechanical Keyboard
TL Community
The Automated Ban List
Blogs
Cognitive styles x game perf…
TrAiDoS
StarCraft improvement
iopq
Heero Yuy & the Tax…
KrillinFromwales
I was completely wrong ab…
jameswatts
Need Your Help/Advice
Glider
Trip to the Zoo
micronesia
Poker
Nebuchad
Customize Sidebar...

Website Feedback

Closed Threads



Active: 20041 users

Improving mineral gathering rate in SC2

Forum Index > SC2 General
Post a Reply
LetaBot
Profile Blog Joined June 2014
Netherlands557 Posts
Last Edited: 2017-12-05 04:58:20
December 04 2017 03:46 GMT
#1
[image loading]
The mineral gathering algorithm(s) in action

Improving mineral gathering rate in StarCraft 2 (using the bot API)
EDIT: turns out that I set the experiment on RealTime mode (thus giving inaccurate frame count). New data below

As some of you may know, the default behavior of worker units is not optimal. This is the case in BW ( http://www.teamliquid.net/forum/brood-war/484849-improving-mineral-gathering-rate-in-brood-war ), but it is also true for StarCraft 2.


So for Brood War I implemented some algorithms to improve the gathering rate. I implemented those in SC2 as well and I now have some preliminary results already. It was quite interesting to see that even in SC2 there was still much gain from optimizing the mineral gathering rate.

Details of the algorithms can be found in the TL link above, I will mainly discuss results here

The following algorithms are used:


- Built-In
- Mineral Lock
- Queue System
- Co-operative Pathfinding
- Co-operative Pathfinding + Queue System


The research setup is as follows:
All algorithms start at the top left start location of InterloperLE and play for 4000 frames. Each algorithms builds 2 SCVs, then 1 supply depot, then SCVs until it has 16 SCVs (the recommended #workers).



Built-In:

The Built-In algorithm basically lets the internal worker management do its thing. In SC2 the internal worker management works more like the Mineral Lock system. So unlike BW there is not much difference between this and the Mineral Lock

Mineral Lock

Essentially making sure that each worker unit stays assigned to a certain mineral field. The frantic switching of mineral field in BW only rarely occurs in SC2, thus making this almost the same as the Built-In

Queue System

After some testing, it turns out that I cannot get accurate enough data from the API. Especially when exactly worker units are mining (and how much time they still need). This makes the results of the queue system worse than the more standard mineral lock.

Either way, the queue system uses a greedy scheduler, so the result can still be improved

Co-operative Pathfinding

The Co-operative wasn't really needed in SC2 due to how unit collisions work in SC2 compared to BW (in BW units are more like solid blocks whereas in SC2 units behave like a fluid). The optimized movement to the mineral fields was thus the main focus here.

I was surprised that it improved the #minerals at all, but I soon saw that just like in BW the worker units slow down when approaching a mineral field (just like in BW). The effect isn't as profound as in BW though.

Co-operative Pathfinding + Queue System

Combining the 2 systems will give even better results (as expected, scheduling and the pathfinding are not that interdependent). unfortunately result in sub-optimal scheduling. Compensated by the better pathfinding it will get around the same #minerals as the Mineral-Lock , but as it stands right now you are better off just using the better pathfinding.

Github source code

The preliminary source code is currently up on the github for LetaBotSC2. Now updated to not use realtime mode.

https://github.com/MartinRooijackers/LetaBotSC2/tree/master/Research/MineralAlgorithms

It still needs a better setup for gathering results (mainly adding Protoss and Zerg as well), but it should work for those willing to try it out themselves. A compiled .exe is available as well if you just want to see it in action (currently only for Terran).

Raw Data

Raw data from some of the tests that I have run can be seen by clicking on the spoiler.
Updated for the non-realtime mode.

+ Show Spoiler +


TopLeft Interloper LE:

Taken at intervals of 250 frames
So the first result is frame 250 , the last one when the #frames was at 4000


BuildIn:

Current Frames: 250 Total Minerals: 70
Current Frames: 500 Total Minerals: 55
Current Frames: 750 Total Minerals: 135
Current Frames: 1000 Total Minerals: 220
Current Frames: 1250 Total Minerals: 385
Current Frames: 1500 Total Minerals: 540
Current Frames: 1750 Total Minerals: 710
Current Frames: 2000 Total Minerals: 885
Current Frames: 2250 Total Minerals: 1055
Current Frames: 2500 Total Minerals: 1225
Current Frames: 2750 Total Minerals: 1400
Current Frames: 3000 Total Minerals: 1565
Current Frames: 3250 Total Minerals: 1730
Current Frames: 3500 Total Minerals: 1905
Current Frames: 3750 Total Minerals: 2080
Current Frames: 4000 Total Minerals: 2250

EvenSplit:

Current Frames: 250 Total Minerals: 85
Current Frames: 500 Total Minerals: 65
Current Frames: 750 Total Minerals: 145
Current Frames: 1000 Total Minerals: 240
Current Frames: 1250 Total Minerals: 405
Current Frames: 1500 Total Minerals: 575
Current Frames: 1750 Total Minerals: 740
Current Frames: 2000 Total Minerals: 920
Current Frames: 2250 Total Minerals: 1090
Current Frames: 2500 Total Minerals: 1265
Current Frames: 2750 Total Minerals: 1430
Current Frames: 3000 Total Minerals: 1600
Current Frames: 3250 Total Minerals: 1770
Current Frames: 3500 Total Minerals: 1935
Current Frames: 3750 Total Minerals: 2115
Current Frames: 4000 Total Minerals: 2280



Queue:

Current Frames: 250 Total Minerals: 90
Current Frames: 500 Total Minerals: 65
Current Frames: 750 Total Minerals: 150
Current Frames: 1000 Total Minerals: 245
Current Frames: 1250 Total Minerals: 400
Current Frames: 1500 Total Minerals: 570
Current Frames: 1750 Total Minerals: 745
Current Frames: 2000 Total Minerals: 915
Current Frames: 2250 Total Minerals: 1075
Current Frames: 2500 Total Minerals: 1245
Current Frames: 2750 Total Minerals: 1405
Current Frames: 3000 Total Minerals: 1580
Current Frames: 3250 Total Minerals: 1745
Current Frames: 3500 Total Minerals: 1915
Current Frames: 3750 Total Minerals: 2085
Current Frames: 4000 Total Minerals: 2255



Path:

Current Frames: 250 Total Minerals: 95
Current Frames: 500 Total Minerals: 75
Current Frames: 750 Total Minerals: 155
Current Frames: 1000 Total Minerals: 255
Current Frames: 1250 Total Minerals: 415
Current Frames: 1500 Total Minerals: 580
Current Frames: 1750 Total Minerals: 745
Current Frames: 2000 Total Minerals: 925
Current Frames: 2250 Total Minerals: 1105
Current Frames: 2500 Total Minerals: 1280
Current Frames: 2750 Total Minerals: 1445
Current Frames: 3000 Total Minerals: 1625
Current Frames: 3250 Total Minerals: 1805
Current Frames: 3500 Total Minerals: 1970
Current Frames: 3750 Total Minerals: 2130
Current Frames: 4000 Total Minerals: 2315



Path+Queue:

Current Frames: 250 Total Minerals: 90
Current Frames: 500 Total Minerals: 70
Current Frames: 750 Total Minerals: 155
Current Frames: 1000 Total Minerals: 255
Current Frames: 1250 Total Minerals: 415
Current Frames: 1500 Total Minerals: 580
Current Frames: 1750 Total Minerals: 740
Current Frames: 2000 Total Minerals: 920
Current Frames: 2250 Total Minerals: 1090
Current Frames: 2500 Total Minerals: 1260
Current Frames: 2750 Total Minerals: 1430
Current Frames: 3000 Total Minerals: 1595
Current Frames: 3250 Total Minerals: 1775
Current Frames: 3500 Total Minerals: 1935
Current Frames: 3750 Total Minerals: 2115
Current Frames: 4000 Total Minerals: 2280

If you cannot win with 100 apm, win with 100 cpm.
DrDevice
Profile Joined December 2010
Canada132 Posts
December 04 2017 03:56 GMT
#2
This is interesting, very cool. Thanks for posting
Argonauta
Profile Joined July 2016
Spain4906 Posts
December 04 2017 05:14 GMT
#3
Math and SC2 PogChamp. Really nice read.

User was warned for this post
Rogue | Maru | Scarlett | Trap
TL+ Member
Hadronsbecrazy
Profile Joined September 2013
United Kingdom551 Posts
December 04 2017 10:03 GMT
#4
On December 04 2017 14:14 Argonauta wrote:
Math and SC2 PogChamp. Really nice read.

User was warned for this post



yea its pretty Kreygasm am i rite :D

User was temp banned for this post.
No need Build Orders, Only Micro,Favourite Players: Maru, Zest, soOjwa , CJherO
Ej_
Profile Blog Joined January 2013
47656 Posts
December 04 2017 10:38 GMT
#5
I'd like to see your results put against a casual player and a progamer. Oh and I would love to see it a map with 4 close mineral patches too (Echo, Overgrowth).
"Technically the dictionary has zero authority on the meaning or words" - Rodya
Grumbels
Profile Blog Joined May 2009
Netherlands7031 Posts
December 04 2017 11:15 GMT
#6
This actually seems like it would be a fun bachelor thesis project for CS students.
Well, now I tell you, I never seen good come o' goodness yet. Him as strikes first is my fancy; dead men don't bite; them's my views--amen, so be it.
-Kyo-
Profile Blog Joined August 2010
Japan1926 Posts
December 04 2017 11:59 GMT
#7
This is something that has been needed for a long time. I mean, who forgets the old red tier gas on some of the WoL maps? Where if you spawned in one loc in mirrior matches you were literally behind just by virtue of placements huehuhe
Anime is cuter than you. Legacy of the Void GM Protoss Gameplay: twitch.tv/kyo7763 youtube.com/user/KyoStarcraft/
TL+ Member
LetaBot
Profile Blog Joined June 2014
Netherlands557 Posts
December 05 2017 04:57 GMT
#8
Turns out that I set the experiment up in Real-Time mode, which gives inaccurate frame counts. After re-running the experiment, it became clear that the queue system needs more accurate information than the API can currently provide. The new pathfinding does improve the #minerals a bit, but not so significant.

text above and github are updated.
If you cannot win with 100 apm, win with 100 cpm.
LDaVinci
Profile Joined May 2014
France130 Posts
December 05 2017 09:28 GMT
#9
It was known in WOL and HotS (not sure about LotV, never tried it) that you can slightly improve your mineral rate by right clicking your worker just before the mineral and shift clicking on the mineral. If you do that, you worker arrive a litle faster on the mineral and if you can repeat it each time, you can gain like a full cycle after 5 or 6 (or 10).
It is really apm demanding, and you need your mineral to be available, I guess that's why I've not heard about it in LotV with 12 SCV start.
Those who refuse to become better, already stop being good
LetaBot
Profile Blog Joined June 2014
Netherlands557 Posts
December 05 2017 15:20 GMT
#10
On December 05 2017 18:28 LDaVinci wrote:
It was known in WOL and HotS (not sure about LotV, never tried it) that you can slightly improve your mineral rate by right clicking your worker just before the mineral and shift clicking on the mineral. If you do that, you worker arrive a litle faster on the mineral and if you can repeat it each time, you can gain like a full cycle after 5 or 6 (or 10).
It is really apm demanding, and you need your mineral to be available, I guess that's why I've not heard about it in LotV with 12 SCV start.



My bot works on the same kind of principle. It has to do with worker units slowing down when approaching mineral field. Difference ofc being that with a computer you can calculate the right trajectory to take and having the apm to pull it off continuously.
If you cannot win with 100 apm, win with 100 cpm.
Please log in or register to reply.
Live Events Refresh
BSL: ProLeague
18:00
Bracket Stage: Day 2
HBO vs Doodle
spx vs Tech
DragOn vs Hawk
Dewalt vs TerrOr
ZZZero.O333
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
CosmosSc2 133
EnDerr 35
Livibee 10
StarCraft: Brood War
Calm 2782
Rain 1360
Artosis 603
Horang2 377
ZZZero.O 320
Dota 2
NeuroSwarm74
LuMiX1
League of Legends
tarik_tv11192
Dendi1376
Counter-Strike
Stewie2K1383
Super Smash Bros
C9.Mang013762
Mew2King96
Heroes of the Storm
Grubby3579
Liquid`Hasu466
Khaldor153
Other Games
summit1g7945
Mlord1403
FrodaN1049
JimRising 573
ViBE189
elazer120
Maynarde66
KnowMe31
Organizations
Dota 2
PGL Dota 2 - Secondary Stream7321
Other Games
gamesdonequick1341
BasetradeTV140
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 21 non-featured ]
StarCraft 2
• Berry_CruncH288
• Hupsaiya 80
• musti20045 58
• RyuSc2 48
• Adnapsc2 31
• Kozan
• Migwel
• sooper7s
• AfreecaTV YouTube
• intothetv
• IndyKCrew
• LaughNgamezSOOP
StarCraft: Brood War
• 3DClanTV 42
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• masondota22598
• Ler156
League of Legends
• Doublelift6724
• Shiphtur517
Other Games
• imaqtpie1850
Upcoming Events
Wardi Open
12h 4m
Replay Cast
1d 1h
Replay Cast
1d 11h
WardiTV Invitational
1d 12h
WardiTV Invitational
1d 12h
GSL Code S
2 days
Rogue vs GuMiho
Maru vs Solar
Online Event
3 days
Replay Cast
3 days
GSL Code S
3 days
herO vs Zoun
Classic vs Bunny
The PondCast
3 days
[ Show More ]
Replay Cast
4 days
WardiTV Invitational
4 days
Korean StarCraft League
5 days
CranKy Ducklings
5 days
WardiTV Invitational
5 days
Cheesadelphia
5 days
GSL Code S
6 days
Sparkling Tuna Cup
6 days
Liquipedia Results

Completed

Proleague 2025-06-05
BGE Stara Zagora 2025
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
BSL Season 20
KCM Race Survival 2025 Season 2
NPSL S3
Rose Open S1
CSL Season 17: Qualifier 2
2025 GSL S2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
ECL Season 49: Europe
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025
YaLLa Compass Qatar 2025
PGL Bucharest 2025
BLAST Open Spring 2025

Upcoming

CSL 17: 2025 SUMMER
Copa Latinoamericana 4
CSLPRO Last Chance 2025
CSLPRO Chat StarLAN 3
K-Championship
SEL Season 2 Championship
Esports World Cup 2025
HSC XXVII
Championship of Russia 2025
Murky Cup #2
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.