Saturday, April 18, 2015

The meaning behind BWAPI region priority

It occurred to me after viewing this image how the Broodwar built-in region priority system works.


In this visualization, the yellow colored regions have a priority of 2, and the blue ones are priority 3. There are no dividing lines between the yellow regions, just note that the larger ones are actually made up of multiples.

Priority works just like the number in Minesweeper: it is the number of distinct impassable terrain areas that a region touches. That is why there are random yellow regions everywhere in this map, as there many little doodads scattered around that will make a region in the middle of a clear area have priority of 2. The built-in analysis system thinks that it is a choke.

Unfortunately this discovery means that the BWAPI regions are not very valuable for choke detection. They are still a good alternative to implementing a map-grid system, as they are approximately grid-like, but conform to impassable regions so you won't have a grid square which is split by a cliff.

Wednesday, April 15, 2015

La Mancha

Now I finally see why the map is named La Mancha.


That is clearly a windmill in the center of the map!

Wednesday, March 25, 2015

Worker Payoff Time

In Broodwar, you spend 50 minerals to train a worker. How long does it take the increased mining speed from that additional worker to pay back the investment.

We need to account for the build time of the worker, as well as the time required for it to mine 50 minerals.

Here is the equation


According to BWAPI, SCVs take 300 frames to make:


Workers in BW gather at ~1 mineral/second, so as on fastest there are 24 frames a second:


The cost of a worker is 50 minerals


Finally we get


So from this math it takes 1550 frames, or about 65 seconds on fastest for a worker to be built and then make back its cost. In a build order that is trying to reach a certain amount of minerals the fastest, it would be optimal to stop building workers about a minute before completion.

The following are simulation results for time to gather 1000 minerals starting with 1 worker, and controlling the number of workers built. The fastest time was with 10 workers built, 11 in total.

INFO: pred: 22223, cur: 0 work_time:22223
simulated 0 worker time: 22223
INFO: pred: 12373, cur: 1412 work_time:10961
simulated 1 worker time: 12373
INFO: pred: 9325, cur: 2118 work_time:7207
simulated 2 worker time: 9325
INFO: pred: 7919, cur: 2588 work_time:5331
simulated 3 worker time: 7919
INFO: pred: 7146, cur: 2941 work_time:4205
simulated 4 worker time: 7146
INFO: pred: 6680, cur: 3241 work_time:3439
simulated 5 worker time: 6680
INFO: pred: 6390, cur: 3541 work_time:2849
simulated 6 worker time: 6390
INFO: pred: 6211, cur: 3841 work_time:2370
simulated 7 worker time: 6211
INFO: pred: 6104, cur: 4141 work_time:1963
simulated 8 worker time: 6104
INFO: pred: 6049, cur: 4441 work_time:1608
simulated 9 worker time: 6049
INFO: pred: 6031, cur: 4741 work_time:1290
simulated 10 worker time: 6031

The final work time of 1290 frames, adding the 300 for train time, yields 1590, just above the cutoff for breakeven time to build a worker. Building another worker after that time resulted in a longer time to reach the mineral goal of 1000.