Audamir

part 40

What is in the source code of the original: the map, the dealing and the check

The official HTML5 version of Dice Wars was read on 2 November 2026. The map grows from a core and a ring, the territories and dice are dealt in the order of creation, and the human gets the first territory. What is certain and what is a guess.

· 22 min read

On 2 November 2026 two files that contain the official HTML5 version of Dice Wars by the label GAMEDESIGN were read in full and repeatedly: the rules, the map, the artificial intelligence, the course of the game, the fight and the drawing. The code had been looked at before too, in the first articles, but only for a few numbers (the line about the year 2001, the grid, the limit of a territory, the rule of two fifths). The rest came from reviews and from pictures. The article Twenty years said that whether the rules of the HTML5 version are the same as in the Flash one is "not verified", and the article Hexagon territories described the map of the original as a random patch of several small hexagons. A careful reading showed that the map is made differently and more interestingly: the territories grow one at a time from a core and a ring.

This article describes what is in the code and says for each thing whether it is certain (read, and confirmed by reading again) or a guess. The code of the original was not copied anywhere and it is not in this article, in the blog or in the repository of the game: everything is a description in our own words. The series about the original has three articles. This one is about the map, the dealing and how a copy can be checked when the original cannot be run. Tribes: a copy that can be measured says what a copy means in the game Audamir and why the Principalities did not change. The opponent of the original discusses the decisions of the opponent and its strength.

How it was read and what was not done

The game from GAMEDESIGN exists in two versions: a Flash one from 2006 and an HTML5 rewrite which, according to the author, was made in 2016 and refers to the Flash one as its predecessor. The second one was read. (The name of the author, Taro Ito, has not been confirmed from primary sources, as the first article of the series says, so it stays here as a label.)

The procedure was this:

  • Loading. Both addresses were loaded with a web tool: the file with the rules, the map and the artificial intelligence three times, the file with the course of the game, the fight and the drawing twice. The map, the limit of five cells, the core of eight cells and the ring, the highest number of territories, the filling of the seas and the absence of a seed were checked by repeated reading.
  • Writing in our own words. The code of the original is protected by copyright. It was not downloaded to the computer, not copied and is not stored anywhere; the reading produced only a description, in which every claim is marked as certain or as a guess. A copy in the game is made from the description, and whoever makes it does not read the code of the original.
  • Nothing was run. The original was not run and not played. The examples of wrong sorting from the description (in the article about the opponent) were recalculated by hand and independently checked by a script; while writing this article they were recalculated once more and came out the same.

One more limit: the version from 2016 was read, not the Flash one from 2006 that the first article writes about (three builds of the file, the last one from 31 August 2007). Whether the Flash game had the same map and the same artificial intelligence is not known; the Flash file was not analysed. The rules of the fight in the code match what the reviews of the game in 2006 wrote, and that is the whole evidence of their agreement.

The map: 896 cells and territories that grow one at a time

The map is a grid of 28 columns by 32 rows, that is 896 hexagonal cells. Odd rows are shifted half a cell to the right, every cell has six neighbours and the edge does not wrap around. The number of a cell is row × 28 + column. (Drawing uses spacings 27 and 18 in an area of 840 × 840, so the hexagons look squashed; this comes back below.)

Every cell gets a priority. The array of numbers from 0 to 895 is shuffled and a smaller number means an earlier choice. The shuffle is "naive": each index is swapped with an arbitrary index (not only with a later one), and this does not give a uniform permutation. It is a known way to go wrong when shuffling; what effect it has on the maps was not measured. The measuring tool repeated it exactly like that.

Then a random cell is chosen as the seed of the first territory. (The word "seed" is used here for the start of a territory, so that it is not mixed up with the seed of the random number generator.) Territories are made one at a time, each by three steps:

  1. Core. A free neighbour of any cell of the territory with the smallest priority is added again and again, until the core has 8 cells (or until there is nowhere to grow).
  2. Ring. All free neighbours of the core cells are added to the territory, also the neighbours of the last added cell.
  3. Candidates. Free neighbours of the ring cells are marked as candidates for the next seed. The next territory starts at the candidate with the smallest priority.
Growth of the first territory of the map of the originalThe territory grows from a core of eight cells (numbered in the order of adding); then the ring of all free neighbours of the core is added (19 cells). The free neighbours of the ring (24 cells) are candidates for the next seed, and the one with the smallest priority starts the second territory.123456782core (order of adding)ringcandidate for next seedseed of the second territory
The growth of the first territory of one simulated map (the stream of random numbers „OM-5“ of the tool original-map.js), all three steps in one picture. The strongly coloured cells are the core of 8 cells, numbered in the order of adding; the paler ones the ring of 19 cells; orange 24 candidates for the next seed and the fully coloured candidate with the smallest priority, from which the second territory grows. The diagram is drawn from the growth of the same map.

Growth ends when there are no more candidates, or when there are 31 territories (the constant in the code is 32, but the number 0 is the sea, so the highest territory has number 31). Two things follow from this. First, the size of a territory is not a parameter and nobody sets it: the core has eight cells and the ring adds the rest, depending on how many free neighbours it had. Second, the number of territories is not a parameter and has nothing to do with the number of players: two players and eight play on a map of the same kind.

After the growth come three steps, and their order matters:

  • Filling of the seas. A single-cell sea whose neighbours are all land is filled.
  • Dissolving of small territories. Only after that are territories with five cells or fewer dissolved and turned into sea. The minimum of a territory is therefore six cells. The comment in the code says ten, but five applies. Because the dissolving is done after the filling of the seas, the dissolved cells are not filled by anybody any more.
  • Neighbours and centres. The neighbours of the territories (by the borders of the cells) and the centres are counted. The centre, where the number of dice is drawn, is the cell nearest to the centre of the bounding rectangle of the territory, with a penalty for cells at the border.

And what the game does not do: it does not check whether the land is in one piece after the dissolving, and it never rejects a map by any criteria. The only repetition is the manual button "NO" in the dialogue that asks whether to play on this map. The territory itself is always connected, because it grows along neighbours. And the map and the game cannot be repeated: only the random number generator of the browser is used, no seed. In this the original is the opposite of what the article about tiles describes: there the seed is a contract with the past, here there is nothing that could be contractually kept.

The whole map of the original, OM-5Simulated map of the original with 30 territories. Each territory has a dark core and a light ring; the filled single-cell seas are green, and the only dissolved territory (5 cells) is grey with a dashed edge.123456789101112131415161718192021222324252627282930coreringfilled seadissolved territorysea
The whole map OM-5 after all three steps of the growth. The strongly coloured cells are cores, the paler ones rings, the green ones filled single-cell seas, the grey one with a dashed edge the only dissolved territory (5 cells). The numbers are the order of creation of the territories (dissolved ones are not numbered); with 7 players a human would get territories 1, 8, 15, 22 and 29 (see the section about dealing). The map is not average: it is the second of the streams „OM-k“, which has the median number of territories (30), one dissolved territory and at least three filled seas, so that the picture shows all steps.

What could be measured on the map the code describes

The description said what the map does, but not what it is like: how many territories it has, how big they are and whether it fills the grid. The description had only a guess here (a territory of 15 to 25 cells; whether the limit of 31 is always reached, it did not know). It could be measured by simulation with the tool original-map.js (2 Nov 2026, TUNING §44.2). That tool is written from the description and without the code of the game (see the check below). Results from 5,000 simulated maps:

Number from 5,000 mapsValue
territories on a map (mean; least; median; most)30.0; 25; 30; 31
cells in a territory (mean, standard deviation; 10th percentile / median / 90th percentile)20.5, 4.2; 15 / 21 / 25
the smallest and the largest territory on a map (mean)9.8 and 26.8 cells
land of the 896 cells0.69 (single-cell seas: 4.1 cells per map)
neighbours of a territory3.79
aspect ratio of the land: regular hexagons; spacings 27 : 18 as in drawing1.02; 1.32
holes (sea closed by land): per map, size3.9 holes of 7.7 cells; 0.9% of maps have none
land in more than one piece0 of 5,000 maps
map with fewer territories than players (7 players)0 of 5,000
Number of territories on a map of the originalOf 5,000 simulated maps, one has 25 territories, 13 have 26, 68 have 27, 281 have 28, 897 have 29, 1,950 have 30 and 1,790 have 31.05001,0001,5002,0001251326682728128897291,950301,79031territories on a map (small ones dissolved); height = maps out of 5,000
The distribution of the number of territories on 5,000 simulated maps (after the small territories are dissolved): 1, 13, 68, 281, 897, 1,950 and 1,790 maps for 25 to 31 territories. Three quarters of the maps have 30 or 31 territories.
Size of a territory in the originalShare of territories by number of cells, of 150,070 territories on 5,000 simulated maps: from 6 to 31 cells, most often 23 cells (11.3%), mean 20.5, median 21.0%3%6%9%12%681012141618202224262830mean 20.5cells in a territory (under 6 are dissolved); height = share of all territories
The distribution of the sizes of territories (150,070 territories from the same 5,000 maps). The most frequent size is 23 cells, mean 20.5, median 21. The orange columns (6 to 8 cells) are small territories that were probably squeezed by their neighbours (explained by the shape of the growth, not measured); territories of 5 cells and fewer are dissolved by the game.

Three things follow from these numbers.

The limit of 31 is always reached, and the land never fills the grid. The number of territories is always nearly the same (three quarters of the maps have 30 or 31) and the land takes 0.69 of the grid (30 territories of 20.5 cells is 615 of 896). The growth therefore ends not because the candidates run out, but because the limit is reached: on every one of the 5,000 maps, and on average 0.99 territory is then dissolved. The description had this as a guess ("with the limit of 31 territories the land would not have to fill the whole grid") and the measurement confirms it.

Land in more than one piece did not occur in the simulation. The growth attaches each new territory to the land that already exists, and small territories are dissolved only at the end. Therefore no two pieces of land arose on 5,000 simulated maps. The game does not check this, and the original does not refuse any map. Dissolving a territory in the middle of a map would split the land, so zero out of 5,000 maps is the result of the simulation, not a property that the game would guarantee.

The aspect ratio has a contradiction. From the constants of the drawing one gets about 1.3, and the simulation gives 1.32 at spacings 27 : 18, which agrees. But the pictures of the game, from which the field of the Principalities was drawn by eye on 29 October, showed 1.6 to 1.9. The difference was not explained, and none of the possible causes (for example pictures from another version of the game) was tested.

Dealing: territories, dice and the order of players

The game starts with dealing: who gets the territories and dice, and in what order they play. Territories are dealt in the order of their creation, not at random.

Why the human always gets the first territory

Territories are assigned to players in the order of their creation: player k of p gets the k-th, (k+p)-th, (k+2p)-th territory and so on, circularly. According to the shape of the expression this looks like an intended random choice (a random one of the unassigned territories is picked), but an expression with a random number computes the remainder after division where it should have multiplied. The result is always the same: the first unassigned territory in the order. That it was meant as a random choice is a guess from the shape of the expression; the intention of the author is not known.

The consequences are three, and all are certain:

  • The numbers of territories differ between players by at most one.
  • Player 0, that is the human, always gets the territory created first, the one with the first random seed.
  • The spatial mixing of colours is determined by the order of creation: each new territory grows next to the ring of the previous one and the next one goes to the next player, so neighbouring territories tend to belong to different players.

The last point was measured (TUNING §44.4, 5,000 maps, 7 players, the same command as above):

dealing of the originalrandom dealing with the same numbers
pairs of neighbouring territories with one owner (share)0.0570.114
groups of touching territories of one owner (map, all players)26.823.8
the numbers of players differ by (mean)0.940.94

The dealing of the original divides the colours twice better than random: with a random division a pair of neighbouring territories in the same colours is twice as frequent. An error in drawing therefore does not make the game unfair; on the contrary, it mixes the map better than the intended choice would. That is an interesting moment when reading foreign code: not every mistake does harm.

The order of players in the game is mixed similarly: the array 0 to 7 is shuffled by naive swaps, the game starts with the player in first place (not always the human) and eliminated players are skipped. The description says that the order forms the "first p items" of the array, and that is one of the places where the description cannot be read unambiguously (how the game decided it is in the article about Tribes).

Starting dice

Each territory gets 1 die. Then another 2 × N dice are dealt (N is the number of territories), so the average is 3 dice per territory. They are dealt in a circle over the players (player 0, 1, …, p−1 and again), each die onto a random territory of the given player with fewer than 8 dice. A peculiarity: if the player whose turn it is has no suitable territory, the whole dealing ends, not only his round. On ordinary maps this is rare; in the simulation of 5,000 maps it did not happen once and the average came out at 3.00 dice per territory.

The human with the first territory has no advantage

The human, who always has the first territory, has no advantage: even when seat 0 is played by the opponent of the original, it wins 50.3%, 26.3%, 16.3% and 12.0% with 2, 4, 7 and 8 players, while the fair share is 50, 25, 14.3 and 12.5%. Dealing by the order of creation therefore gives the human nothing that would show up in the wins.

Wins of seat 0 against the fair shareShare of wins of the player on seat 0 in Tribes when the opponent of the original plays it: 50.3% with 2 players, 26.3% with 4, 16.3% with 7 and 12.0% with 8. The fair share is 50, 25, 14.3 and 12.5%.0%10%20%30%40%50%60%50.050.32 players25.026.34 players14.316.37 players12.512.08 playersfair shareseat 0 plays the opponent of the original
Seat 0 is played by the opponent of the original, the other seats by the original too. Measured with 300 games for each number of players (Tribes calibrations, §44.5).

How a copy is checked when the original cannot be run

The check has four layers, and each says a different thing.

1. Two implementations of one description. The map is made by the generator in the game (the branch of the function buildBlob) and by the independent tool original-map.js. The tool reads nothing from js/ of the game: it has neither the grid nor the random number generator of the game. Its random numbers come from outside in a fixed order written in the header: 896 numbers for priorities, one for the first seed (897 in total; after that the map is deterministic) and, when dealing, eight for the order of players and one for each die.

2. The difference test. The same stream of random numbers is sent to the tool and to the generator of the game, and the results must agree: which territory each cell belongs to (300 streams), how many numbers were used (897), the neighbours and the outline of each territory as a set of vertices (40 streams), and the dealing for 2 to 8 players (140 streams). The first run found no difference. It also contains a map derived by hand: with identical priorities and first seed 0 the first territory is 0 to 8 and 28 to 35 (the core grows along the first row, the ring is the row below it and the cell behind it), and the next seed is 9.

3. The opponent point by point. The level original has 20 tests: six examples of the "leader" from the description (and also that the result is always a permutation, that the numbers of dice do not change and that it is not sorting by dice); each step of the procedure separately on hand-made maps (candidates, a dominant player at exactly two fifths and one die more, only pairs touching the dominant one, a target with more dice, equality decided by the "leader", by the owner of the target or by the draw, the number of numbers used, no candidate). The probability 0.9 for equality is tested on 20,000 decisions (to within one percentage point). And the decision does not look at the chance: it attacks from a territory with two dice onto a territory with two just as readily as from an eight onto a one.

4. Two tools, one map. The tables of §44.2 (the tool original-map.js, 5,000 maps) and §44.3 (the tool map-shape.js over the game, 150 maps) measure the same map with different codes. Territories came out 30.0 and 30.1, cells 20.5 and 20.6, land 0.69 and 0.68. Holes came out 7.7 and 9.1 cells: a check on 2 November showed that it is the same quantity on different maps. On 1,500 maps of the game the mean is 7.4 ± 0.2; the size of a hole has a heavy tail (median 4 cells, largest 224), so the mean of 150 maps has an error of about 0.6 and 9.1 is a high draw (TUNING §44.3). What is usable is 7.4 to 7.7.

Where the description is silent: agreements

The description of the original does not say everything. Where it is silent, the code takes one option, always in one place, and it is written down with the reason and also with the opposite answer (docs/TRIBES-OPEN-QUESTIONS.md, part A). For the reader the important ones are these:

QuestionChosenOpposite option
A1: are the candidates for a seed one list for the whole map?yes: a cell marked by an earlier territory stays a candidate until someone takes itonly the candidates of the last territory: the growth would end when a territory closes, and there would be fewer territories
A2: who owns a filled single-cell sea?the neighbour with the most cells around it, the older one on a tie; one passthe first neighbour in the grid; a loop until it settles
A4: the order of players ("the first p items of the shuffled array 0 to 7")a subsequence of the shuffled array that holds players 0 to p−1a literal reading would leave real players without a turn
A5: the tie "0 to 10 is more than 1"a real number, r × 10 > 1, probability exactly 0.9whole 0 to 10: 9 of 11 (0.82)
A6: the centre of a territory (where the dice are)the pole of the outline (where the dice stand in all maps of the game)the rule of the original (the cell nearest the centre of the rectangle); the dice of a thin territory would stand nearer the border
B5: the shape of the hexagonsregularsqueezed (spacing 27 and 18 in an area of 840 × 840)

What is certain and what is a guess

ClaimStatus
grid 28 × 32, priorities from the shuffled array, growth one at a time from a core of 8 and a ring, limit of 31 territories, filling of the seas, dissolving of 5 and fewercertain (repeated reading)
a human always gets the first territory, dealing of territories in the order of creationcertain; that the author meant a random choice is a guess
starting dice 1 + 2 × N, in a circle, the whole dealing ends at a player without a suitable territorycertain
fight, reinforcement, end of gamecertain; agreement with the Flash version of 2006 is not verified
artificial intelligence: steps 1 to 9, two fifths, 0.9 for a tie, the wrong sorting of the "leader"certain (six examples checked twice)
typical number and size of territories, fullness of the mapin the description a guess, measured by simulation from the description with agreement A1 (30.0 territories of 20.5 cells)
source and target are checked the other way round for a human and a computer with an asymmetric matrix of neighboursguess; the effect is small
a stalemate in practiceguess, rare (0.3 to 0.7%)
aspect ratiocontradiction (constants 1.3; pictures 1.6 to 1.9)
how the map and the artificial intelligence worked in the Flash version of 2006unknown
the author of the gamenot confirmed (the label GAMEDESIGN stays)

What follows for older text of the blog

Two older articles contain sentences that need to be made more precise. Twenty years says that the rules of the Principalities correspond to the original also in the "random irregular territories", and Hexagon territories describes the origin of the map of the original as patching. The rules of the fight agree; the assignment of territories, the map and the opponent do not. Both clarifications are added to the articles as Update of 2 November 2026, and the original text stays as it was.

Sources and notes

  • Source of the description: the official HTML5 version by GAMEDESIGN, the files game.js and main.js, read on 2 November 2026. The code was not copied or stored.
  • Numbers: simulation of 5,000 maps, node tools/realms/kastgard/games/stacks/original-map.js --maps 5000 --seed BIG (7 players), and docs/TUNING.md §44.2 and §44.4 in the repository of the game. The distributions in the pictures are from the same run. The win shares of seat 0 are from §44.5 (300 games per row, see the article about the opponent).
  • Rules in the game: docs/DESIGN.md §133 and docs/TRIBES.md in the repository of the game.