How Silk Board’s computer plays
A companion to the game: where tokens land, a hand-made judge and a network that corrects it, every action tried with the real rules, trades weighed from both sides, and win chances checked against thousands of games
1 A game of Silk Board
Silk Board is played on a ring of 40 spaces. Each player starts at Majestic, space 0, with ₹15 Cr, rolls two dice and moves clockwise. A player who passes Majestic collects a salary of ₹2 Cr. Most spaces can be owned: 22 localities in 8 groups, 4 metro lines and 2 utilities. A player who lands on one that nobody owns may buy it at its price. If they do not, it goes to auction among all the players. A player who lands on someone else’s property pays that owner rent.
Rent is what makes the game. A locality’s rent is small on its own and doubles when one player owns its whole group. An owner of a whole group may then build flats on it, up to four on each locality and then a tower. Each flat raises the rent many times over. Players can also mortgage a property for half its price, sell buildings back for half their cost, and trade properties and cash with one another. A player who owes more than they can raise goes bankrupt and leaves the game. The other spaces are taxes, two card decks (Kismat and Lottery), Silk Board, where a token waits like the jail of other property games, Cubbon Park and “Stuck in traffic”, which sends a token to Silk Board.
Every one of these choices is a decision for the computer, and they are of different kinds:
Leaving Silk Board is one more choice. A token there can pay a fine of ₹50 L, use a pass from the card decks, or try to roll a double.
The setup screen adds another layer. A game has two to six players. It can end when one player is left, after a set number of minutes, or after a set number of rounds. Cubbon Park can pay nothing, a fixed bonus or the taxes collected there. The bank can hold the classic 32 flats and 12 towers, any other stock or an unlimited supply. Two rules decide what happens to a bankrupt player’s property. One computer has to play well in every combination, including ones it never trained on.
The example in this companion is one seeded game between four Hard computers with classic rules. Figure 1 shows it at turn 24, when red is about to offer green a trade. Red owns Yelahanka and Devanahalli, two of the three North localities. Green owns the third, KR Puram. The rest of this companion works out how red values that position, how it finds the offer, and why green accepts.
2 Where tokens land
The value of a property is the rent it collects, and rent is collected only when someone lands there. So the first thing the computer needs is how often each space is landed on.
2.1 Two dice
A double, two dice showing the same number, lets the player roll again after their move. Three doubles in a row send the token to Silk Board instead.
odds.ts counts each of these rolls as one move, MOVES_PER_TURN. A third double moves the token to Silk Board without landing anywhere that charges rent, so this overcounts by a small amount, of a move per turn.
2.2 The board as a Markov chain
Where a token goes next depends only on where it is now, the dice and the cards. It does not depend on how the token got there. A process with this property is a Markov chain, and its long-run behaviour can be computed exactly.
odds.ts builds in three steps. Each roll total moves the token that many spaces. On a card space, each card in the deck is drawn with equal chance, and the card may move the token again or send it to Silk Board. “Stuck in traffic” and the cards that say so send it to Silk Board. Three simplifications keep the chain small, and each is small next to the dice. Cards are drawn uniformly rather than in the deck’s shuffled order, which no player knows anyway. Doubles count through the average number of moves per turn (Proposition 1). A token at Silk Board is taken to leave on its next roll.
figures.ts multiplies by itself and finds that every entry of is positive. So within 3 moves, any space can lead to any other. Let be the smallest entry of and the number of states. Then , where is the matrix with every entry and is another stochastic matrix. For two distributions and , , so , which is at most in total variation distance. So shrinks every distance by the factor , and by Banach’s fixed point theorem it has one fixed distribution, which is , with . Since never increases total variation distance, the same bound holds for with . This is the argument of Doeblin’s condition, as in Levin, Peres and Wilmer, Markov Chains and Mixing Times, Theorem 4.9. ∎odds.ts finds by starting from the uniform distribution and multiplying by two hundred times, which Theorem 1 guarantees converges. Rent, though, is paid on landings, not on where a move ends. A card space is landed on, and so is the space a card then sends the token to. So LANDINGS is pushed through a second matrix that counts every landing of a move. Its entries add up to 1.047, a little over 1, because about one move in twenty lands twice.
The differences are real but modest. The most visited property is landed on about 1.47 times as often as the least visited. Whitefield is the most landed-on property. It is six spaces past Silk Board, where tokens collect, and a Kismat card sends tokens straight there. Majestic and the metro lines also gain from cards that send tokens to them. Ash and Bishop computed the same kind of distribution for the classic board in 1972.
The chain is a model, so it is worth checking against play. In 80 games between Medium computers, the game counted 14,961 landings. Each space’s share of them is within 0.5 points of the chain’s share. The largest gap, 0.42 points, is at Kismat (22), well within what so few landings per space leave to chance.
odds.ts’s own matrix.3 Rent and the value of a group
Every locality’s rent table follows the same pattern, from its price. A tower rents for about 4.8 times the price, and the flats rent for 11%, 33%, 75% and 88% of the tower. So the rent is convex in the number of flats. Each of the first three flats adds more than the one before.
With four players, each player sees three opponents move about 3.58 times per round. That makes rent per opponent move the natural unit for comparing a flat’s cost with what it brings in.
figures.ts computes the gain of each step for every group from the rent tables and the landing shares, and the third step is the largest in all 8 groups (Figure 4). It follows from the shape of the tables. The third flat takes a locality from 33% to 75% of its tower rent, the largest jump, and every flat costs the same. ∎So a group is worth far more than the sum of its parts, and most of that worth is unlocked at three flats. For the North group, owning it whole with three flats on each locality earns 37.8 lakhs per opponent move, against 1.24 for owning it whole with none. This is why red, holding two of the North localities, pays well for the third (Section 7). The analyses of the classic board by Ash and Bishop, and later ones of return on investment per group, reach the same conclusion, that returns jump at three buildings.
4 The hand-made judge
The Medium computer judges a position with evaluate.ts. The formula gives each player a strength in lakhs, a rough measure of what that player is worth over the rest of the game. It then turns the strengths into chances that add up to 1.
parts in evaluate.ts computes for each player, in lakhs or lakhs per opponent move.| In words | In symbols |
|---|---|
| worth: cash, property at its price (half if mortgaged), buildings at half their cost | |
| rent per opponent move from everything owned (Definition 2) | |
| what partly owned groups would earn whole with three flats, times the share owned squared, halved if a rival holds part | |
| what whole groups would still gain by building to three flats, and what that costs | , |
| rent expected on the next roll, and the shortfall of cash against the worst rent it could bring | , |
| the price of unowned property within reach of the next roll |
strengths in evaluate.ts weighs the parts into a strength, for players still in.| In words | In symbols |
|---|---|
| the horizon: 18 rounds, or the rounds left if fewer | |
| opponent moves the rent is counted over | |
| what building would still add, if positive | |
| worth and rent to come | |
| plus the promise of groups and of building | |
| minus the risk of the next roll, plus buying chances |
With four players and no end in sight, : rent counts for 18 rounds of everyone else’s moves. The weights are , , and , tuned by playing the evaluator against itself across setups. At the example position nobody owns a whole group, so the building term is zero for everyone. Blue’s lead comes from its groups term, since it owns two of the three South localities.
The strengths become chances through a softmax.
Definition 3 (Softmax with a temperature). Given strengths of the players still in and a temperature , player ’s chance of winning is
Medium sets in lakhs, where is the mean strength of the players still in.
The second property is why the temperature follows the money. Early in a game every player is worth about ₹15 Cr, and later the totals grow with rent and building. A fixed temperature would make the same relative lead look decisive late in a game and negligible early. At the example position , and red’s chance is 18.5%.
The formula had to be written with care for one property of rent. It once credited a whole group with its future three-flat rent at the average gain per flat. Rent is convex, so the first flat added less rent than that credit, and every flat looked like a loss, so the evaluator never built. It now counts what is left to gain from each locality’s current rent, and only a share of it.
Proposition 4 (A flat raises the strength). Let a whole group have no mortgages, room to build, and a remaining building gain larger than its cost (). Building one flat costing on a locality with landing share , where it raises the rent by , changes the strength by
with the building weight. So a flat raises the strength when its rent over the horizon exceeds about 0.23 times its cost.
5 Deciding by trying actions
The computer never needs to know what an action does. It asks the rules. For each action it could take, it copies the game, applies the action with the same function that runs the real game, act in rules.ts, and asks the judge for every player’s chance of winning in the result. It plays the action that leaves its own chance highest. A position judged just after an action, before any dice, is called an afterstate. TD-Gammon judged backgammon moves the same way, and Sutton and Barto’s Reinforcement Learning describes the method.
This design is what lets one computer play every setup. A shortage auction, a tax on worth, Cubbon Park’s pot or a bankruptcy rule changes what act does, and the judge sees the result. Nothing about the rules has to be learned or written twice.
decide in src/games/silk-board/decide.ts; the computer calls it again after every action, so a turn of several builds is several calls.The margin keeps the computer from acting on differences smaller than the judge can tell apart. Without it, the computer could mortgage a property on one call and redeem it on the next as the judge’s numbers wobble, paying 10% interest each time.
5.1 Why a shortlist
The network costs more than the evaluator. On the example position one network judgement of every player takes about 15 times as long as the evaluator’s, on the machine that built this companion. Hard therefore lets the evaluator shortlist the owner actions and asks the network only about the best 5. This works because the network is a correction to the evaluator (Section 9), so the two mostly agree on which options are good.
figures.ts checked the shortlist over 16 games between Hard computers, at every owner decision with more than 5 options, 3,068 of them. The network’s favourite option was in the shortlist in 80% of them. More to the point, rating every option instead would have changed what Hard did in only 102 decisions, 3.3%. Most of the network’s favourites that the shortlist misses are not worth doing anyway, because they do not beat ending the turn by the margin.
Offers are the exception. Hard searches for offers with the network itself (Section 7). Searching them with the evaluator and only confirming the result with the network made Hard weaker, because an evaluator’s search finds the trades the evaluator likes, and most of the network’s advantage over Medium is in which trades it offers.
6 Buying and bidding
When a player lands on an unowned property, buying it is not the only alternative to leaving it. If they decline, everyone bids for it, and a rival may get it for less than its price. So the computer compares owning it at its price with the most likely result of an auction, which it takes to be the richest other player owning it at 70% of its price. It buys only if owning it is worth at least as much.
At turn 36, red landed on the Pink Line, priced at ₹2 Cr, with ₹8.02 Cr in hand, and declined. In red’s judgement, paying full price for a single metro line left it worse off than letting the richest rival have it cheaply.
6.1 The reservation price
The computer works out by playing the rest of the auction out on a copy. If it drops out, the current leader takes the lot at the current bid, or, if nobody has bid yet, the next bidder takes it at a discount. It then finds the reservation price by bisection: it keeps a price where winning is worth it and a price where it is not, tries the price halfway between, and keeps whichever half still has one of each.
The first part holds whatever the judge says. The computer never bids a price at which its own judge says winning is worse than dropping out. The computer does not bid its reservation price at once. It raises by a twentieth of the lot’s price, at least 10 lakhs, while the next bid is still below its reservation price. Auctions between computers then take a few rounds instead of hundreds.
In Figure 6, the reservation prices at the first round of bidding were red ₹1.01 Cr, blue ₹1.22 Cr, green ₹3.93 Cr and yellow ₹2.89 Cr. Green values the line most, because it already owns the Purple Line, and a second line doubles the fare at both. The bidding went up in steps of ₹10 L. After 27 bids, green won the line for ₹2.7 Cr. Red, which had declined to pay ₹2 Cr, dropped out first.
7 Trading
Trades are where a game of Silk Board is won. Most groups are split between players after the first laps, and only a trade can complete one. A trade must leave the other player better off too, or they will not accept it. So the computer has to judge the trade from both sides.
The judge already does this. It gives every player’s chance, so the computer can ask how a trade changes its partner’s chance as easily as its own. It assumes the partner judges the way it does, which is exactly true when the partner is another Hard computer.
So when both sides of a trade gain, the other players pay for it. A trade that completes a group for one player is bad news for everyone the group’s rent will come from.
7.1 Searching for an offer
The computer looks for an offer once a turn, after its move. For each other player it lists what it might ask for, which is that player’s pieces of groups the computer already has part of. It lists what it might give: nothing, that player’s missing pieces of their own groups, or a lone property of its own. For each pair of asks and gives, the cash is the unknown. More cash to the partner raises the partner’s gain, so bisection finds the least cash that gives the partner the trade margin of 0.01, in their own judgement. Of all these offers, the computer keeps the one that gains it the most, if that gain is also at least the margin.
The trade completes the North group for red, and its chance rises by +14.8 points to 37.3%. Green gains +1.0 points, just over the margin, as the search intended. Blue and yellow pay for both, as Proposition 6 requires, with changes of −10.1 and −5.8 points.
7.2 Answering
A computer offered a trade accepts it when its chance after accepting beats its chance after declining by the margin. Both are judged at the same point of the game, with play back with the proposer, so only the trade differs. Green’s chance after accepting is 24.78%, and after declining 23.73%, a gain of +1.05 points, just over the margin of 0.01, so green accepts. If an offer falls short, the computer may counter with the same properties and its own price for them, found by bisection the same way. An exchange allows 3 counter-offers.
Two Hard computers judge a trade identically, so an offer one makes is an offer the other accepts. In 16 games between Hard computers, all 82 offers were accepted. A person is under no such obligation. The computer then offers what a player who judges like its network would accept, and a person may decline. Two rules keep it from pestering: one offer a turn, and the same request to the same player at most twice a game.
8 Building and the bank
Building follows three rules from the classic game. A player builds only on a whole group with no mortgages. Building is even. No locality may get more than one flat ahead of the rest of its group, and selling is even the same way. Buildings come from the bank’s stock, by default 32 flats and 12 towers. A tower takes the place of four flats, which go back to the bank, and breaking a tower back into flats needs four flats in the bank.
Since the third flat is the most profitable step (Section 3), the bank’s stock decides how many groups can reach it, about three groups’ worth. Towers ease the limit, since each one returns four flats. So does holding the stock, which is a classic tactic. Four flats on each locality and no towers keep the bank’s flats from everyone else.
When the bank cannot supply everyone who could build, the classic rule auctions each of its last flats or towers among them, opening at the building’s price. Setup can choose instead to let whoever builds first have it. A computer that tries a build which starts such an auction judges it as winning that auction at the opening price, the best case, and the bidding then tests it. It also tries each such build only once a turn. Without that rule a computer could build, start the auction, find that winning was worth less than its judge had hoped, pass, and then build again, forever.
Mortgages are the other source of money. A mortgage raises half a property’s price, and paying it back costs the loan plus 10% interest. A property traded while mortgaged costs its new owner 10% of the loan at once. When a player owes more than their cash, the computer sells or mortgages whatever costs it the least chance, one step at a time, until it can pay, and goes bankrupt only when nothing is left. Every one of these is an action act applies, so Algorithm 1 handles them all without special rules.
9 The value network
The Medium evaluator is a reasonable judge, but its weights are guesses tuned by hand, and it knows nothing its formula does not say. Hard judges with a neural network that learned from 432,480 games of self-play (Section 10). The network does not replace the evaluator. It adds a learned correction to the evaluator’s judgement of each player.
9.1 What it sees
features.ts defines them.| In words | In symbols |
|---|---|
| per ownable space (28): which slot owns it; flats as a thermometer (at least 1, 2, 3, 4, a tower) and mortgaged, split by whether the viewer owns it | |
| per player slot (6): in the game; cash as a thermometer and a number; position (40); at Silk Board; holds a pass; whole groups; Medium’s eight parts and its judgement of the player | |
| the game: whose decision, whose turn, the phase, flats and towers left in the bank, the park’s pot, players left, rounds left | |
| the setup: how the game ends, the park, the shortage rule and both bankruptcy rules |
A thermometer turns a number into on-off inputs, one per threshold it passes. Cash of ₹6 Cr switches on the inputs for at least ₹50 L, ₹1 Cr, ₹2 Cr, ₹3 Cr and ₹5 Cr. Most inputs are on-off, and only about 95 of the 959 are non-zero for a position, so the network adds up the weights of those few. It also sees Medium’s own parts and judgement of every player, so it never has to rediscover what the formula already knows.
9.2 What it computes
A new network starts with , so it plays exactly like Medium before it has learned anything. Training then penalises large corrections, so where the network has seen few positions it stays close to Medium.
At the example position the network disagrees with Medium in a clear direction. It raises red by 0.18 and lowers blue by 0.12. Most of blue’s lead in Medium’s judgement came from its groups term (Figure 5), and the network, trained on how games like this one ended, trusts that term less. Red’s chance rises from 18.5% to 22.5%, and blue’s falls from 35.9% to 32.6%.
Here that is 6,144 per view, four views a position. The weights are stored by input, each input’s 64 weights side by side, so the sum reads memory in order. They ship as 16-bit integers with one scale per input, which keeps every output within 0.0001 of the trained network’s and makes the file 178 kilobytes.
9.3 Why not learn from scratch
The first networks had no evaluator underneath. They learned the whole judgement, starting from a copy of Medium’s. They reached about Medium’s strength and stopped there. Two reasons fit. First, the decision layer asks about dozens of positions that never occur in play, a bid at every price, every mortgage, every trade. A network is never corrected on those, and choosing the option it rates highest picks out its overestimates. Thrun and Schwartz described this bias of choosing by an approximate value in 1993. Second, a network learning from scratch could not easily see what Medium values most, groups one short of whole and the gain still to come from building.
The correction design answers both. Where the network has learned nothing, it is Medium, which is sound. It only has to learn where Medium is wrong. Johannink and colleagues, and Silver and colleagues, both in 2018, called this residual learning on top of a hand-made controller. The first corrections beat Medium within a few rounds of training.
10 Learning by self-play
tools/train.ts trains the network in rounds, each a few hundred games long:
10.1 Targets
At the end of a game the winner is known. A game stopped at the turn cap shares the win by a softmax over net worth, since being a little behind at an arbitrary stopping point is not a clear loss. Each recorded position then gets a target, worked backwards from the end, that blends what the network said at the next recorded position with the target there.
In Figure 11 the targets run ahead of the network’s values towards the result. A target turns before the end gives the real result a weight of , so with the result still counts 11% ten turns out and 0.1% thirty out. Further back the targets follow the network’s own later values. This smooths away the luck of later dice while still tying every target to how games really end.
10.2 Fitting
So each player’s correction moves in proportion to how far its chance is from the target, and the anchor pulls it back towards zero, towards Medium. The gradient reaches every weight of the network through the chain rule, and Adam, an optimiser that scales each weight’s step by a running measure of its gradient’s size, takes the steps. Every worker thread fits its own positions on the same shared weights at once, without locks. With sparse inputs two threads rarely touch the same weight at the same moment.
10.3 What training needs
Training this network taught several lessons, each now part of how it is trained:
The shipped network is round 1802 of training, after 432,480 games.
11 Measuring strength
A single game says almost nothing. tools/arena.ts uses two arrangements that make every game count for more. A seed fixes the dice and both card decks’ shuffles, so two games with the same seed have the same luck. And each seed is played once per seat, with the computer under test in that seat and the other computer in all the rest, so good dice and the advantage of a seat fall on each player in turn.
The Hard computer against itself scored exactly 1.00 over 12 games, as the proposition requires. This checks that the arena is fair.
Hard wins about 1.5 times its even share against three Medium computers. Medium is far stronger than Easy. The “random” player is not as weak as its name. It buys almost everything it can afford, bids up to a little over the price, and builds now and then. Easy is no better than it. Neither builds well, so their games are long, 810 player turns on average, against 161 when Hard plays Medium. Many reach the turn cap and are decided by net worth.
The arena runs a whole suite of setups, from two to six players, with every bank, park and bankruptcy rule and timed games, including two setups that training never draws. It stops a setup early once its score is clearly above or below level.
12 Three ways to end
A game of Silk Board ends in one of three ways, chosen at setup:
In the last two, net worth at the end decides everything, so rent that will come in after the end is worth nothing. A computer must know how much of the game is left. Both read it as rounds left, roundsLeft in ai.ts.
Doubles do not count as extra turns. A player who rolls a double plays again within the same turn.
Rounds left enter both judges. Medium counts rent over at most 18 rounds, or the rounds left if fewer. The network sees whether the game ends on worth, a thermometer of the rounds left (at most 20, 10, 5 and 2), and the rounds left divided by 40. Timed games and games of so many rounds share these inputs, so to the network they are the same kind of ending.
Figure 13 shows what this does. With 40 rounds left the network judges the example position almost as it does with no end in sight. As the end nears, green, the richest player, becomes the favourite, at 51% with a quarter of a round left. Medium’s evaluator moves much less, to 29%. Its softmax temperature follows the money in play (Definition 3), so a lead of ₹1.25 Cr in worth looks small to it even when there is no time left to overturn it. The network learned the endgame from games that ended this way.
13 The win predictor
The game page shows each player’s chance of winning on their chip, with the change since their last turn, and a strip split by the players’ colours. A trade offer shows what accepting it would do to every player’s chance, as Figure 7 does. At the end of the game, a chart replays the chances over the whole game, as Figure 11 does. All of these come from winChances in outlook.ts: Hard’s network, with one adjustment.
The chances assume that every player plays equally well from here. The network judges the position, not the people. A beginner holding the best groups is given the chance a Hard computer would have with them.
13.1 Calibration
A forecaster is calibrated if, among all the times it says 30%, the event happens 30% of the time, and likewise for every other number. A reliability diagram checks this. It sorts every chance given into bins, 10% to 20%, 20% to 30% and so on, and plots each bin’s mean chance said against the share of those players who went on to win. A calibrated forecaster’s points lie on the diagonal.
npm run silk-board:calibrate measures this. It played 3,600 games on setups drawn from everything the setup screen offers, half with every seat Hard and half with each seat Easy, Medium or Hard at random. At the end of every turn it recorded both judges’ chances for every player still in, 677,228 positions in all.
Definition 9 (Scoring forecasts). For a position with chances and winner :
- the Brier score is , from 0 for certainty about the right player to 2;
- the log loss is , 0 for certainty about the right player, and for even chances;
- the calibration error is the gap between chance said and share won in each bin of the reliability diagram, averaged with each bin weighted by how many chances it holds.
A score with this property is called proper: a forecaster cannot improve it by saying anything other than what it believes. Log loss is proper too. Both reward two things at once, calibration and sharpness, telling the eventual winner apart early.
The network is better than Medium’s evaluator on every score but one. Its log loss is 0.559 against 0.585, and its favourite wins 76.4% of the time against 75.1%. Even chances, the forecast that knows nothing, have a log loss of 1.085. Yet the raw network is less calibrated than the evaluator, with 1.70 points of calibration error against 0.98. The network tells winners apart better, but says it with too little confidence. That can be fixed after the fact, and the evaluator’s weaker sharpness cannot.
How sure anyone can be depends on how far a game has gone. In the first quarter of a game the network’s favourite wins 51.5% of the time. In the middle half 79.0%, and in the last quarter 95.8%.
13.2 Temperature scaling
Definition 10 (Temperature scaling). Given chances and a temperature , the scaled chances are
makes them sharper, flatter, and leaves them unchanged.
So temperature scaling changes how far apart the network’s strengths are, not their order. The favourite stays the favourite, and only the confidence changes. Guo and colleagues found in 2017 that this single number calibrates modern neural classifiers well. outlook.ts applies it after the network, as sharpen, with . The calibration run chose by trying every value from 0.50 to 4.00 in steps of 0.05 and keeping the one with the lowest log loss.
The best temperature is not the same everywhere. It is 1.00 in the first quarter of a game, 0.90 in the middle and 0.50 in the last quarter, where the network is right most often and most underconfident. One temperature for every position is a compromise, weighted towards the middle of games, where most positions are. Games of so many rounds were checked separately, 1,200 of them with 10 to 80 rounds. Their best temperature is 0.80, which brings the error from 1.50 to 0.38 points, close enough to share the value.
Why is the raw network underconfident? One possible reason, not tested here, is how it was trained. Its targets blend its own later chances with the result (Definition 6), and in a game where luck moves the lead, those blends are less extreme than the eventual outcomes. A judge trained towards them may learn to hedge.
13.3 The position, not the player
At mixed tables the network gave Easy computers 17% on average, and they won 10% of the time. It gave Hard computers 42%, and they won 46%. The network cannot tell who is playing. It sees the position, and over the following turns the stronger player’s positions improve. This is the right behaviour for the page, where the chances are meant to describe the board and not to judge the people at it.
14 Easy, Medium and Hard
All three levels run the same decision layer (Algorithm 1). They differ in the judge, the noise on its values, and whether they offer trades.
Easy’s noise is the sum of two random numbers, so values near zero are more likely than values near 0.04. On the owner decision of Section 5, where the options are a few points apart, Easy builds on Rajajinagar in only 31% of 20,000 tries, and ends its turn without building in 6%. It never mortgages the South group there, because those options are worse by far more than the noise.