Melee maps: layout and balance
Three commands say whether a melee map is fair to every start, from the quickest to the most thorough:
| Command | What it does | Takes | Needs |
|---|---|---|---|
map analyze |
Reads the layout without running the game: mains, naturals, walks and chokes | About a second | Your copy of StarCraft |
map rush |
Has the game walk a unit between every pair of starts | A few seconds | StarCraft and the game engine |
map balance |
Plays bots against each other from every start | Minutes | StarCraft, the engine and a bot |
scmjs map generate makes a map to try them on (A melee map from a
seed), and scmjs map heatmap shows where the fighting was in
games people played on the map (Where things happened across many
games).
A map's layout#
scmjs map analyze reads a melee map's layout without running the game, in about a
second: where each start is, its main and its natural, how far every pair of starts is
apart on foot beside the straight line, the narrowest points on the way, and how much of
the map is walkable, buildable and raised ground. It needs your copy of
StarCraft for the map's tileset, which says which ground
is walkable and at what height, but not the game engine.
$ scmjs map analyze "(4)Crossing.scx" --out crossing.png
✔ (4)Crossing 128 × 128 · desert · 4 start locations · 10 bases · StarCraft: Remastered 1.23.10.13515 · 0.7 s
Start Main Natural Way out Height
1 top left, 11 o'clock 9 fields + gas 33 (air 31) 7 fields + gas 3.5 at 35, 23 on mid, raised 86%
2 bottom right, 4 o'clock 9 fields + gas 33 (air 31) 7 fields + gas 3.5 at 92, 103 on mid, raised 87%
3 top right, 1 o'clock 9 fields + gas 33 (air 31) 7 fields + gas 3.5 at 92, 23 on mid, raised 87%
4 bottom left, 8 o'clock 9 fields + gas 33 (air 31) 7 fields + gas 3.5 at 35, 103 on mid, raised 87%
Pair Ground Ratio Zergling Marine Zealot Narrowest
1 ↔ 2 141 tiles air 119 1.18× 33.9 s 47.2 s 47.2 s 3.5 at 35, 23, 1's way out
1 ↔ 3 93 tiles air 88 1.06× 22.5 s 31.3 s 31.3 s 3.5 at 36, 22, 1's way out
1 ↔ 4 123 tiles air 80 1.54× 29.6 s 41.3 s 41.3 s 3.5 at 35, 23, 1's way out
2 ↔ 3 124 tiles air 80 1.54× 29.8 s 41.5 s 41.5 s 3.5 at 91, 102, 2's way out
2 ↔ 4 92 tiles air 88 1.04× 22.1 s 30.8 s 30.8 s 3.5 at 91, 102, 2's way out
3 ↔ 4 141 tiles air 119 1.18× 33.9 s 47.2 s 47.2 s 3.5 at 92, 23, 3's way out
Shortest 2 ↔ 4, longest 1 ↔ 2: 53% apart
Terrain walkable 93.3% (high 0%, mid 12.4%, low 87.6%) · buildable 91.7% · unwalkable 6.7%
✔ Every start's walks to its opponents match the others', nearest to farthest, within 2%; near and far pairs differ by 53%.
✔ Every main has 9 mineral fields and 1 geyser, 13,500 minerals and 5,000 gas.
✔ Naturals 33 tiles from their mains by ground.
✔ Every main's way out is 3.5 tiles at its narrowest.
Picture: 512 × 512 PNG, 4 pixels a tile, written to crossing.png · 93 KB
Distances are in tiles (32 pixels) and places are tile coordinates from the top left.
| Column | Means |
|---|---|
| Start | The player, which third of the map the start is in, and its place as a clock face from the middle, as map rush gives it |
| Main | The mineral fields and geysers nearest this start and within 12 tiles of it, as map balance counts them |
| Natural | The nearest other base on foot that is nobody's main: how far it is walked from the start location and in a straight line, and what it holds. A base is a group of resources close together that a unit walks between directly (a main and a natural below its cliff stay two bases); fields holding fewer than 100 minerals are a wall, not a base |
| Way out | The narrowest point on the walk from the start to its natural, in tiles across, and where it is: the main's ramp, as a rule |
| Height | The start's own ground height, and how much of the walkable ground within 12 tiles of it is raised (mid or high). In some tilesets the "high" terrain is the middle level, so raised ground is what is compared |
| Ground, air, ratio | The walk between two starts, the straight line, and the one over the other |
| Zergling, Marine, Zealot | The walk's time at Fastest for each, at the unit's speed in your copy's game data, without upgrades |
| Narrowest | The narrowest point on that walk, and whose way out it is when it is one |
With more than four starts, a table of the ground distances takes the place of the pairs,
followed by the shortest and longest pair; --all lists every pair, and every base on the
map with whose main or natural it is. --json gives everything as data: the starts, every
pair with both distances and the seconds, the narrowest points with their places, the
bases, the terrain shares and the verdicts.
How the ground is walked. The map is read as a grid of minitiles, sixteen to a tile, each walkable or not by the tileset, the way the game's own pathing reads it; a grid of whole tiles would close one-tile passages and open cliffs a unit cannot climb. Buildings and resources the map places, pre-placed neutral buildings and the units a doodad brings (doors, traps) stand in the way; units that move do not. A walk keeps one minitile off every wall, about the room a Zergling or a Marine needs, and goes straight or diagonally from minitile to minitile (a diagonal step costing 1.4 straight ones), never across a wall's corner. Walks are measured from start location to start location.
What narrow means. At each point of a walk, the passage is as wide as the shortest straight line through it from wall to wall, across, down or along either diagonal. The narrowest such point on a walk, leaving out the first and last three tiles, is its narrowest point. A patch of unwalkable ground standing on its own and smaller than 16 tiles (a rock, a doodad, a lone geyser) is not counted as a wall, since a unit walks round it on either side; a cliff, a mineral line against it, or a building is.
The verdicts are facts with their numbers, marked ▲ when they pass a line:
| Verdict | Marked when |
|---|---|
| Ground distances | The pairs differ by more than 8% (the tolerance map generate holds its maps to). With three or more starts, each start's walks to the others are also compared nearest first: a square of four starts has near and far pairs by design, and is fair when every start's nearest, second and third opponents are as far as everyone else's |
| Islands | No ground joins two starts |
| Mains | A start's main has another number of fields or geysers, or other amounts |
| Naturals | A start has none, shares its natural with another start, has one 5 tiles or more farther or nearer than the starts' middle (than the other start's, with two), or has no gas there while others do |
| Way out | A start's way out is a tile or more wider or narrower than the starts' middle |
| Chokes | A walk between two starts goes through a passage under 2 tiles wide, where a Dragoon or a Siege Tank barely gets through |
| Height | A start has 15 points more or less raised ground round it than the starts' middle |
The picture. --out writes the map as map preview draws it,
at --scale pixels a tile (4 by default), with the analysis over it. It has no words, so
here is what it shows:
| Drawn | Means |
|---|---|
| White lines | The walk between every pair of starts |
| Yellow lines | Each start's walk to its natural |
| Circles in a player's colour | That player's natural |
| Orange squares | Each main's way out, as wide as the passage |
| Red squares | The narrowest point of a walk between starts, where it is not a way out |

scmjs map analyze "(4)Crossing.scx" --out layout.png --scale 8. This map has no red
squares: its only narrow points are the mains' ramps.
Against the game. These walks are not the game's: the game's pathfinder goes from
region to region and turns as a unit turns, which map rush measures
by walking a unit in the game. Over nine maps (seven of Blizzard's and two from
map generate, 103 walks with a Zergling), the ground distance here was within 2.5% of
the game's walk on average and 8% at most. The game's walk is usually a little longer, so
the seconds here are a few percent quicker than map rush's. Use this command to see a
layout in a second while you work, and map rush to time it in the game.
The command exits with 2 for a map with fewer than two start locations, and with 1 when no copy of the game is found.
Rush distances#
scmjs map rush measures how long a rush takes between each pair of start locations. The
game walks a unit from each start location to every other, along the path a unit sent
there in a game would take, and times each walk. An SCV walks unless you name another unit
with --unit: by its name in the editor ("Zerg Zergling"), without the race
(Zergling, Dragoon), or by its number in units.dat. The rows of the table are the
starts walked from and the columns the starts walked to, each with its place on the map as
a clock face from the middle:
$ scmjs map rush "(4)Crossing.scx" --unit Zergling
(4)Crossing.scx 128 × 128, desert · 4 start locations · a Zergling walked 12 times · Remastered files
1 → 2 4,376 px, 34.6 s
…
✔ (4)Crossing.scx: a Zergling walked between 4 start locations by the game · 12 walks · 3.4 s
from ╲ to 1 2 3 4
1 11 o'clock – 4,376 px, 34.6 s 2,957 px, 23.5 s 3,826 px, 30.5 s
2 4 o'clock 4,408 px, 34.9 s – 3,847 px, 30.9 s 2,871 px, 22.3 s
3 1 o'clock 2,858 px, 22.7 s 3,847 px, 30.9 s – 4,535 px, 36.4 s
4 8 o'clock 3,857 px, 30.7 s 2,937 px, 23.1 s 4,576 px, 36.8 s –
Shortest 2 → 4: 2,871 px (90 tiles), 22.3 s · air 2,816 px, 1.02× the straight line
Longest 4 → 3: 4,576 px (143 tiles), 36.8 s · air 3,806 px, 1.20× the straight line
The pixels are the distance the unit walked (32 to a tile) and the seconds are game time at Fastest. The unit sets out five tiles from its start toward the middle of the map and stops at the edge of the town hall at the other start: a neutral Nexus stands on every start while the walks run, so the walk ends where a real rush ends, at the base. The two directions between a pair can differ by a second or so, because the way out of each base is not the same. The shortest and longest walks, by the pixels walked, are compared with the straight line between the two starts, the distance a flyer goes. When the terminal is too narrow for both figures, the seconds and the pixels come as two tables.
A walk that does not arrive is a finding too. Two starts with no ground between them, on an island map or where the terrain walls one off, are reported as having no way; on a map where no two starts are joined, the report says so under a warning and lists the straight lines instead. On a map that places units of its own for player 1, the game walks those beside the unit asked for, and only the unit asked for is reported; where the game did not walk it at all, the pair is reported as not walked, with why. A unit that stops short (at a wall of minerals or buildings the map places, say), gets stuck, or is still walking after seven minutes of game time is named with how far from the base it ended.
The walks run in one game with nobody else in it: about four seconds for a four-player map
and fifteen for an eight-player map of 256 × 256. --seed changes the game's luck, such
as a unit stepping round another; the default is the one the editor's Walkability plugin
uses, so the two agree. --json gives every walk and the table as data. A building or a
flyer is refused (exit 2), as is a map with fewer than two start locations, before the
game starts. map analyze gives the same distances in a second without
the game, within a few percent, beside the map's naturals and narrow points.
Is the map fair to every start#
scmjs map balance is a melee map's report card. The same two sides play game after game
on the map, and the report has a row for each start location: how often the side that
started there won, how long its games lasted and how soon it met the enemy, beside the
numbers that need no game. The sides are your bots: one bot plays the game's own
computer, or two bots play each other, as bot ladder plays them.
scmjs map balance "(4)Crossing.scx" --bots out/mybot.scmbot:p --races p --games 12 --parallel 4
scmjs map balance "(4)Crossing.scx" --bots mybot.scmbot,mybot.scmbot --games 12
$ scmjs map balance "(4)Test4.scx" --bots ualbertabot.scmbot:p,ualbertabot.scmbot:p --games 12 --parallel 4
12 games · UAlbertaBot vs UAlbertaBot (ualbertabot-2) · 4 start locations · 1248410ad2a0 · 4 at once
2/12 ✔ UAlbertaBot (ualbertabot-2) P (start 4, 8 o'clock) beat UAlbertaBot P (start 3, 1 o'clock) · 9:39 · first contact 2:32 · seed 2
…
(4)Test4.scx 128 × 128 · 12 games played · UAlbertaBot 8-4 vs UAlbertaBot (ualbertabot-2) 4-8 · 176 s
Start Games Won Lost Win rate Expected Length Contact Rush Minerals Gas
1 11 o'clock 8 1 7 13% 50% 8:10 2:22 32.0 s 9 × 1,500 · 6.4 t 1 × 5,000 · 7.8 t
2 4 o'clock 3 2 1 67% 33% 11:05 2:16 32.7 s 9 × 1,500 · 6.4 t 1 × 5,000 · 7.8 t
3 1 o'clock 9 7 2 78% 59% 7:40 2:26 32.0 s 9 × 1,500 · 6.4 t 1 × 5,000 · 7.8 t
4 8 o'clock 4 2 2 50% 42% 9:13 2:27 32.8 s 9 × 1,500 · 6.4 t 1 × 5,000 · 7.8 t
Pairs met: 1–2 ×3, 1–3 ×5, 3–4 ×4 · never: 1–4, 2–3, 2–4
▲ Start 1 (11 o'clock) wins only 13% where 50% was expected — its resources and distances are within 10% of the others', so the difference is in the ground or in how the games went.
The map above was made by map generate with its four quarters mirrored, so its starts
differ only in where they face. Twelve games of one bot against itself are enough to see
that this bot does worse from the top left; they are not enough to say why. A verdict to
act on wants more games, and more than one bot.
| Column | Means |
|---|---|
| Games, Won, Lost | The games a side started at this start location, and how they went. A game stopped at --frames is counted in Games only |
| Win rate | Won out of won and lost |
| Expected | What the two sides' own records predict for those games. With two sides of a strength it is 50%; when one side is stronger, a start it was dealt more often is expected to win more |
| Length, Contact | The average game, and the average time the first unit was lost to the other side |
| Rush | The average walk to the other starts, as map rush measures it; --no-rush leaves it out |
| Minerals, Gas | The main's fields and geysers: those nearest this start and within 12 tiles of it, the amount each holds and their average distance in tiles |
The verdict compares each start's win rate with what was expected. Within 10 points everywhere, the map is called balanced within the largest difference. A start further off is named, with the number that sets it apart from the others when one does (less gas, a mineral line further away, shorter walks to the enemy, earlier fights). When the games are too few to tell the difference from chance, the verdict says so and how far chance alone would move that start. When one side won every game, the games say nothing about the starts, and the verdict asks for two sides of a strength: the same bot twice does that.
The game deals the start locations itself, as it does in any melee game, and there is no way yet to ask for a particular one. So each game's replay is played back afterwards to see which start each side was dealt, and the rows are filled from those. Enough games give every start its turn; the line under the table lists the pairs of starts that met and those that never did. A bot playing itself plays each seed once, since the other lobby order deals the same starts and gives nearly the same game.
A game takes from ten seconds to a minute or so, depending on the bots and how long it
lasts; --parallel plays several at once (by default up to four, as the computer's cores
and memory allow; a game takes about 1.5 GB for each bot in it). The replays are deleted
afterwards unless --out names a folder to keep them in, for scmjs replay watch.
--json gives every row, every game with the starts dealt, and the verdict as data. The
command exits with 1 when a game could not be played, and with 2 for a map with fewer than
two start locations.