Ghost Leg Picker

The Amidakuji ladder, drawn in your browser. Put in up to twelve names and up to twelve results, and the ladder pairs each name with exactly one result. Nobody can land on the same result twice.

Try one:

What is Ghost Leg (Amidakuji)?

A ghost leg is a drawing that pairs a list of people with a list of results. You draw one vertical line per person, write a name at the top of each line and a result at the bottom of each line, then scatter short horizontal rungs between neighbouring lines while the results are covered up. To read your answer you start on your own name and walk downwards, and every time a rung touches the line you are standing on you cross it to the neighbouring line and keep going down. Whatever sits at the bottom of the line you arrive on is yours.

It is called Amidakuji in Japan, sadaritagi, meaning ladder climbing, in Korea, and ghost leg in English, which is a translation of the Chinese name gui jiao tu. In all three places it is the ordinary way a group settles who does what: who buys the coffee, who takes which chore, who sits where, who has whom for secret santa. The name Amidakuji comes from the shape of the very old version, in which lines radiated from a centre like the halo of the Amida Buddha and each person pulled one; the ladder of vertical lines and rungs came later and is what everyone draws now.

Why does everyone get a different result?

Because a rung can only ever swap two neighbours. Look at one row of the ladder: every rung in it takes two neighbouring lines and exchanges them, and no line is touched twice in the same row. A row is therefore a rearrangement of the lines with nothing added and nothing lost. Stack the rows and you compose those rearrangements one after another, and a composition of swaps is still a rearrangement, which mathematics calls a permutation.

Two consequences follow, and they are the whole reason the game works. The first is that the path is reversible: start at the bottom of any line and walk upwards under the same rule and you arrive back at exactly one name. The second is that two players can never land on the same result, because that would require one bottom line to be reachable from two different top lines, which reversibility forbids. This is a property of the diagram, not of any particular software, and it holds however many rungs you draw and wherever you draw them.

Is this draw fair?

Fair means every possible pairing is equally likely, and that is a stricter demand than simply scattering rungs. A hand drawn ladder with only three or four rungs is not fair at all: most players end up on the line they started on, because there is nothing to move them. Adding more rungs improves it, and a ladder with a large number of random rungs gets close to even, but close is not the same as even.

This page therefore works the other way round. It first draws a uniformly random pairing of the names with the results, using a shuffle in which each remaining choice is picked with equal probability and the range is taken by rejection rather than by a remainder, so no result is quietly favoured. Only then does it build a ladder that produces exactly that pairing, by laying down a stretch of random rungs and following it with the rungs needed to finish on the drawn answer. Every outcome has the same probability by construction, and the ladder you see is an honest picture of it: trace any line by hand and you will get the answer the page gives.

The randomness itself comes from the browser cryptographic generator, crypto.getRandomValues, and not from Math.random, which is fast but is not required to be unpredictable. What that generator produces is a seed, printed under every ladder. The seed is the only thing the share link carries besides the names and the results, which is why the same link always redraws the identical ladder.

Ghost leg or a spinning wheel?

A wheel answers who. One spin, one winner, and if you need a second winner you spin again and remember to take the first name out. A ghost leg answers who gets what, for everybody, in one draw, and duplicates are impossible rather than merely avoided. If your question is which of six people has to present first, spin a wheel. If it is which of six people takes which of six chores, draw a ladder.

Read more: reading a ladder by hand, what the seed is, and the limits of this page

Reading the ladder by hand

Put a finger on a name. Move it straight down until a rung meets your line from either side. Slide along that rung to the neighbouring line, then carry on downwards from there. Never take a rung that you have already passed and never move upwards. When you reach the bottom, the result printed under that line is the one you drew. The coloured line this page animates is doing precisely that and nothing more, which is why you can check it.

What the seed is

The seed is an eight character hexadecimal number that stands for one particular ladder. Given the same names, the same results and the same seed, the ladder is rebuilt rung for rung, so the share link is a record of a draw rather than an invitation to draw again. Change the seed and you get an unrelated ladder. If you want everyone to see the same result, send the link. If you want a fresh draw, use the new ladder button, which asks the cryptographic generator for a new seed.

Blank results and mismatched lists

The two lists are matched to the number of players. If you type fewer results than players, the shortfall is filled with Miss, which is how the game is usually played when only one person wins. If you type more results than players, the extra ones at the end are dropped. Either way the page says so above the ladder, so a mismatch is never silent.

What this page never does

There is no account, no upload and no server side storage. The names you type stay in this page and in the address bar of this tab, which is also how the share link is built. Nothing is sent anywhere, and nothing about a draw is recorded once the tab is closed.

Where it is not the right tool

This is a party and household randomiser. It is not an audited lottery, it holds no record of what was drawn, and anyone holding the share link can rebuild the same result, so do not use it where a draw has to be verifiable against tampering or has money riding on it.

Built by

This page is one of a small set of single purpose tools that run entirely in the browser with no account and no server side storage. One of the others counts the days to any date with the counting rule made explicit, one converts a grade point average from a 4.5 or 4.3 scale to the US 4.0 scale, and one works out an army ETS date, terminal leave and the last duty day.