Ludomancy, all parts
Ludomancy, part 10 of 12 17 min read

Ludomancy 10: Clusters and control: design toward a feel

A session is a vector of 12 numbers. Clustering turns many sessions into a small number of typical sessions. Then the designer can change the mathematics and see which sessions change.

Part 10 of 12 in Ludomancy. Each part stands on its own: it explains the test game and defines the terms it uses.

In short

  • The mean session does not exist. Sessions fall into a small number of groups, and each group feels different.
  • e-means clustering finds these groups in 2 passes through the data. The centre of each group is a typical session that a designer can read.
  • At a fixed RTP, the price of each round is fixed. The design decides how much feel the player gets for this price.
  • A grid of designs at one RTP shows a frontier. A design that is not on the frontier wastes feel.

The test game. The examples use one test game. It is not a real product. It has 5 reels and 3 rows. Three scatters start 10 free spins, and a multiplier grows after each winning spin. The RTP is 96.1%.

The first 5 parts of this series measured one round. A player does not live one round. A player lives a session. This part measures many sessions, puts them into groups, and then changes the mathematics to move sessions from one group to a different group.

One session, 12 numbers

A session has a bankroll of 100 stakes and a limit of 30 minutes. Each round is an independent draw of a book. The session stops when the time ends or when the bankroll is less than 1 stake.

Twelve numbers describe one session. This series calls them the feel vector. Some numbers measure money and time. Other numbers measure belief. Belief is the fair value of a round at one moment, from the events that the player saw.

NumberMeaningMeanMedian
Minutes playedThe time in play, to a maximum of 30 minutes.18.1 min15.0 min
Net resultThe end balance minus the bankroll at the start.-16.2 ×-99.2 ×
Largest winThe largest payout of one round.95.3 ×45.4 ×
Thrill per minuteTravel for each minute. Travel is the total movement of belief.87.0 ×/min86.3 ×/min
Letdown per minuteLetdown for each minute. Letdown is the fall from the best belief to the payout.34.9 ×/min34.9 ×/min
Delight per minuteDelight for each minute. Delight is the rise of the payout above the best belief.6.6 ×/min6.6 ×/min
Blank teases per minuteTeases that pay less than the stake, for each minute.0.8 /min0.8 /min
Longest droughtThe longest time with no win of 1 stake or more.69.0 s65.0 s
Time to first featureThe time to the first feature. The value is 30 if no feature starts.10.7 min5.0 min
FeaturesThe number of features in the session.2.72.0
Largest drawdownThe largest fall of the balance from a peak.125 ×104 ×
Last 3 minutesThe change of the balance in the last 3 minutes.-24.6 ×-36.6 ×

The table shows 30,000 simulated sessions of the test game. The symbol × is 1 stake.

The mean session does not exist

The mean result of a session is -16 stakes. Almost no session ends near this value. 69% of the sessions lose the full bankroll before the time ends. The other 31% last 30 minutes, and many of them end with a profit.

A mean hides these groups. A designer must know the groups, their size, and the knob that moves a session from one group to a different group. Clustering gives the groups.

Clusters: what the procedure looks for

Clustering puts vectors into k groups. Each group has a centre. Each vector belongs to its nearest centre. A good set of centres is near the sessions.

J = (1 / n) · Σᵢ ‖ xᵢ − c(i) ‖²The objective. xᵢ is the vector of session i. c(i) is its nearest centre. A small J shows that the sessions are near their centres.
In plain words

For each session, measure the distance to its nearest centre and square it. J is the mean of these squares. The procedure looks for the centres that make J small.

Example. 3 sessions are 1, 2 and 3 units from their centres. The squares are 1, 4 and 9. J is 14 ÷ 3 = 4.7.

J = 0
for x in sessions:
    J += min(squared_distance(x, c) for c in centres)
J = J / len(sessions)

Use it. Compare J only between runs on the same data with the same k. More centres give a smaller J, so J does not tell you the correct k.

This problem has the name k-means. The usual procedure for it is the algorithm of Lloyd [1]. It assigns all the sessions, moves all the centres, and does this again for 20 passes or more. This series uses e-means [2], a procedure from 2026 that gets the same J in about 2 passes.

e-means: the procedure

  1. Calculate the 12 numbers for each session.
  2. Apply a logarithm to the numbers that have a long tail.
  3. Subtract the mean from each number. Then divide by the standard deviation.
  4. Select k start centres with the k-means++ rule [3]. This rule prefers sessions that are far from the centres already selected.
  5. Put the sessions in a random sequence. Divide them into batches of 512 sessions.
  6. For one batch, assign each session to its nearest centre.
  7. Set each centre to a weighted mean of its old position and the mean of its sessions in the batch. A number, the step, sets the weight of the batch.
  8. Decrease the step from batch to batch. The last step is 0.1 of the first step.
  9. After 2 passes through the data, set each centre to the mean of the sessions that it got in the last pass.
  10. Do steps 4 to 9 with 10 different starts. Keep the result with the smallest J.
In plain words

The algorithm of Lloyd reads all the sessions before it moves a centre. The e-means procedure reads a small batch, moves the centres, and reads the next batch with the better centres. The centres improve many times in one pass. The first moves are large. The last moves are small, and the centres come to rest.

Example. In this post, one pass has 58 batches of 512 sessions. The centres move 116 times in 2 passes.

for batch in shuffled(sessions, size=512):
    for c in centres:
        mine = [x for x in batch if nearest_centre(x) == c]
        c.count = (1 - step) * c.count + step * len(mine)
        c.total = (1 - step) * c.total + step * sum(mine)
        c.position = c.total / c.count

Use it. Do not set the batch size or the step by hand. The e-means paper gives 2 formulas that calculate them from the number of vectors, k and the number of passes.

Claim
For a fixed group of sessions, the mean of the group is the centre with the smallest sum of squared distances.
In plain words

The best position for a centre is the middle of its group. For this reason, each step of the procedure moves a centre toward the mean of its sessions.

The proof does not show that J decreases after each batch. The e-means paper gives no such proof. It gives measurements, and the check below does the same.

Proof (you can skip it)
  1. For one group with n sessions and the mean m, Σ‖x − c‖² = Σ‖x − m‖² + n·‖m − c‖².
  2. The first term does not depend on c. The second term is 0 when c = m, and it is above 0 for each other centre.
  3. As a result, the sum is smallest when c = m.
  4. Each centre of e-means is a weighted mean of sessions: a decayed sum of sessions divided by a decayed count. The last step of the procedure sets each centre to the mean of its sessions in the last pass.
∎
Check with numbers

In the selected run, e-means got J = 4.952 in 2 passes. Lloyd k-means with 10 k-means++ starts got J = 4.952, and its runs needed 17 to 56 passes. In 60 single runs of e-means, J was between 4.952 and 5.276. 6 more repeats of the procedure with 10 starts changed no share by more than 0.1 points.

The silhouette tells you how many groups to use. For one session, a is the mean distance to the sessions of its group. b is the mean distance to the sessions of the nearest other group.

s = (b − a) / max(a, b)The silhouette of one session. A value near 1 shows a clear group. A value near 0 shows a session on the border between two groups.
In plain words

Compare 2 distances for one session: the mean distance to its group, and the mean distance to the nearest other group. If the other group is much farther, the value is near 1. If the two distances are equal, the value is 0.

Example. The mean distance to its group is 2, and to the nearest other group it is 6. The silhouette is (6 − 2) ÷ 6 = 0.67.

Use it. Select k with the mean silhouette of all sessions. Do not select k with J.

The rule in this series is: calculate the mean silhouette for k = 3 to 7. Then select the largest k that is not more than 0.01 below the best value. The best value is 0.286. The rule selects k = 4, with 0.284.

0.200.250.3034567number of groups ksilhouettek = 44.95.35.66.06.305101520passes through the dataJe-means: 2 passesLloyd: 20 passes
Figure 1. Left: the mean silhouette for each number of groups. The black point is the selected k. Right: J for all sessions against the passes through the data. The black line is e-means, with one point for each batch. The grey line is Lloyd k-means from a k-means++ start, with one point for each pass.

Why e-means is the correct first tool

  1. You can read the result. A centre is a typical session with a value for each of the 12 numbers.
  2. It is fast. It needs about 2 passes through the data. Lloyd k-means needed 17 to 56 passes here. Part 11 shows the difference for 1 million rounds.
  3. The centres stay. You can assign the sessions of a new design to the same centres. Then the change of the shares measures the change of the feel.
  4. You know its limits. It prefers round groups. It has no proof that it finds the best centres. Slot data needs 2 repairs, and Part 11 shows why.

The 4 archetypes of the test game

An archetype is the centre of a group. The names come from the numbers that are far from the mean session.

No feature · 26% of sessionsThe bankroll ends before a feature starts.0102030start: 100False rescue · 36% of sessionsFeatures start, but the bankroll ends.0102030start: 100Long ride · 28% of sessionsFeatures keep the session in play to the end.0102030start: 100Strong finish · 9% of sessionsThe session ends with a large win.0102030start: 100
Figure 2. Six example sessions for each archetype. The vertical axis is the balance in stakes, from 0 to 420. The horizontal axis is the time in minutes. A vertical line shows a session that lost the bankroll.
No feature26%False rescue36%Long ride28%Strong finish9%Minutes playedNet resultLargest winThrill per minuteLetdown per minuteDelight per minuteBlank teases per minuteLongest droughtTime to first featureFeaturesLargest drawdownLast 3 minutes−30+3−30+3−30+3−30+3
Figure 3. The centre of each archetype. Each bar shows one of the 12 numbers, in standard deviations from the mean session. A black bar is 1 standard deviation or more from the mean.

No feature, 26% of sessions. The bankroll ends before a feature starts. The mean time in play is 8 minutes. The mean result is -99 stakes, with 0.0 features.

False rescue, 36% of sessions. Features start, but the bankroll ends. The mean time in play is 14 minutes. The mean result is -99 stakes, with 1.7 features.

Long ride, 28% of sessions. Features keep the session in play to the end. The mean time in play is 29 minutes. The mean result is 79 stakes, with 5.1 features.

Strong finish, 9% of sessions. The session ends with a large win. The mean time in play is 30 minutes. The mean result is 255 stakes, with 6.5 features.

The mean silhouette is 0.28. This value shows groups that touch. Archetypes are regions of one cloud of sessions. They are not fully separate types. The shares are stable. The group of one session near a border is not.

The price is fixed

Before you change the design, you must know what a design cannot change.

Claim
For a session with a stop rule, the mean result is E[net] = −c · (1 − RTP) · E[N]. N is the number of rounds and c is the stake.
In plain words

The mean loss of a session is the number of rounds × the part of each stake that the game keeps. A stop rule does not change this price, if the rule uses only the rounds that the player already played.

Example: the test game keeps 3.9% of each stake. A session of 100 rounds at 1 stake loses 3.9 stakes on average.

Proof (you can skip it)
  1. The result of round i is Yᵢ = Xᵢ − c. The rounds are independent. Each round has the mean −c · (1 − RTP).
  2. The stop rule uses only the rounds that the player already played. Mathematics calls such a rule a stop time.
  3. Wald's identity: for independent rounds with the same distribution and a stop time N with a finite mean, E[Y₁ + … + Y_N] = E[N] · E[Y].
  4. As a result, E[net] = −c · (1 − RTP) · E[N].
∎
Check with numbers

The mean session of the test game has 400 rounds. The formula gives -15.8 stakes. The simulation gives -16.2 stakes. The difference comes from the finite number of simulated sessions.

At a fixed RTP, the game keeps the same part of each stake. No mechanic changes this price. A design can change 2 things. It can change how much feel the player gets for the price. It can change which sessions pay the price.

Efficiency is the feel that a design gives for each stake that the game keeps.

Thrill for each stake lost108 in the test game
E[travel] / (c · (1 − RTP))

Travel is the total movement of belief in a round. This ratio is the movement that the player gets for each stake that the game keeps.

In plain words

Add the travel of all rounds. Divide by the money that the game kept in these rounds.

thrill_per_loss = sum(r.travel for r in rounds) / sum(stake - r.payout for r in rounds)

Use it. Compare designs that have the same RTP. The design with the larger value gives more feel for the same price.

Sessions that last31% in the test game
P(the session is in play after 30 minutes)

The share of sessions that do not lose the bankroll. A larger share gives more players the full time of play for the same price.

In plain words

Simulate many sessions with the same bankroll and the same time limit. Count the sessions that still have money at the time limit. Divide by the number of all sessions.

lasting = [s for s in sessions if s.minutes_played >= 30]
share = len(lasting) / len(sessions)

Use it. If the share is too low, decrease the volatility. The table of knobs in this post shows the effect of each knob.

Archetype shares26% · 36% · 28% · 9%
the share of sessions that are nearest to each centre

The feel of the game in one small table. The centres stay the same for all designs, so you can compare the shares.

In plain words

Assign each session to its nearest centre. Count the sessions of each centre. Divide each count by the number of all sessions.

for s in sessions:
    counts[nearest_centre(s)] += 1
shares = [n / len(sessions) for n in counts]

Use it. Keep the centres of the first design. Then a change of the shares shows what a new design does to the feel.

Designs at one RTP

The experiment changes 3 knobs of the test game:

  1. The number of scatters on reels 1 and 5. This sets how frequently the feature starts: 1 in 302, 1 in 151 or 1 in 94 spins.
  2. The number of free spins for 3 scatters: 6, 8, 10, 12, 14.
  3. The multiplier step for each winning spin: 0.80, 1.50, 2.29, 3.20.

Each change moves the RTP. The experiment scales the pays of the 4 low symbols until the RTP is the same again. This gives 56 designs with an RTP between 96.06% and 96.06%. The other combinations need low-symbol pays that are too small or too large.

70809010011012013014015020%30%40%50%60%70%80%share of sessions that last 30 minutesthrill for each stake lostthe test gamethe target pickfeature is rare (1 in 302)as in the test game (1 in 151)feature is frequent (1 in 94)black: on the frontier
Figure 4. 56 designs with the same RTP. Each mark is one design. The dashed line is the frontier: no other design is better on the two axes. The test game is not on the frontier: 3 designs are better on the two axes.

The figure shows a trade. A design with low volatility keeps more sessions in play, and it gives less thrill for each stake lost. A design with high volatility does the opposite. The frontier is the set of the best trades.

The test game is below the frontier. 3 designs give more sessions that last and more thrill for each stake lost, at the same RTP. The test game wastes feel.

Knob level (mean of all designs with this level)Last 30 minThrill / stake lostNo featureVolatility
Feature 1 in 302 spins46%8735%6.7
Feature 1 in 151 spins41%10023%7.9
Feature 1 in 94 spins38%11116%8.3
6 free spins57%8018%4.7
8 free spins46%9120%6.3
10 free spins38%10225%8.0
12 free spins33%11130%9.6
14 free spins31%11434%10.1
Multiplier step 0.8055%8519%4.9
Multiplier step 1.5043%9723%7.0
Multiplier step 2.2935%10528%8.8
Multiplier step 3.2031%10931%10.2

The table shows the mean effect of each knob. A feature that starts more frequently gives fewer sessions with no feature. A larger multiplier step gives more thrill for each stake lost and fewer sessions that last.

From a target to a design

A target is a set of limits on these numbers. This example uses 3 limits:

  1. Not more than 15% of the sessions are in the archetype "No feature".
  2. The thrill for each stake lost is not less than 95% of the value of the test game.
  3. The share of sessions that last 30 minutes is the largest possible.

2 of the 56 designs obey limits 1 and 2. Limit 3 selects one of them. Its feature is more frequent than the feature of the test game.

The test gameThe target pick
Free spins for 3 scatters1012
Multiplier step for each winning spin2.290.80
The feature starts1 in 151 spins1 in 94 spins
Pays of the low symbols× 1.00× 1.03
RTP96.06%96.06%
Volatility9.16.7
Sessions that last 30 minutes31%41%
Sessions with no feature26%14%
Thrill for each stake lost108104
Tingle0.590.63
○ the test game ● the target pickNo feature26% → 14%False rescue36% → 41%Long ride28% → 29%Strong finish9% → 16%0%10%20%30%40%50%share of sessions
Figure 5. The archetype shares of the test game and of the target pick. The centres are the centres of the test game. The RTP is the same.

The RTP did not change, so the price of each round did not change. The feel changed. The share of sessions with no feature went from 26% to 14%. The share of sessions that last went from 31% to 41%. The thrill for each stake lost is 96% of the first value.

The method in 7 steps

  1. Write the target feel as limits on measured numbers.
  2. Simulate books for the design. Calculate belief for each step of each book.
  3. Simulate sessions. Calculate the feel vector of each session.
  4. Cluster the sessions of the first design. Keep the centres.
  5. Change one knob. Correct the RTP with a second knob.
  6. Assign the new sessions to the same centres. Compare the shares and the efficiency.
  7. Keep the designs on the frontier. Select the design that obeys the target.

Limits and correct use

Belief is the value for a player who knows the mathematics. A real player estimates it from sounds and pictures. The metrics measure the signal that the game sends.

The session model uses independent rounds, one stake and one bankroll. A real player changes the stake and can stop early. The grid has 56 designs and 3 knobs. A real game has more knobs.

The archetypes touch. Give the shares, not the group of one session. Do the clustering again when the design changes much.

These numbers measure pressure on the player as well as pleasure. Blank teases, wins smaller than the stake and a fast loss of the bankroll are in the same data. A designer or a regulator can set limits on them with the same method.

Do it with an AI agent

You give the instructions and you read the checks. The agent writes the simulation and the clustering.

Give this to your AI agent
  1. Simulate 30,000 sessions of my game with a bankroll of 100 stakes and a limit of 30 minutes. For each session, record the 12 numbers of the table in this post. Take the logarithm of the amounts. Scale each number to a mean of 0 and a standard deviation of 1.

    You get. A table with one row for each session and 12 columns.

  2. Find the centres with e-means for k = 3 to 7. Use a k-means++ start, 2 passes and the distance-aware revival. Use 10 starts for each k and keep the smallest J. Select k with the mean silhouette. Print each centre and its share.

    You get. A small number of typical sessions. Check: a run of Lloyd k-means on the same data does not give a J that is much smaller.

  3. Change one knob of the game. Correct the RTP with the pays of the low symbols. Simulate the sessions again. Assign them to the old centres. Print the old shares and the new shares.

    You get. The effect of the knob on the feel at the same price. Check: in each design, the mean result of a session is −(1 − RTP) × the mean number of rounds.

References

  1. Lloyd SP (1982). Least squares quantization in PCM. IEEE Transactions on Information Theory 28:129–137.
  2. Bessa S, Mazaré P-E, Szilvasy G, Touvron H, Picard D, Douze M, Jégou H (2026). e-means: outperforming k-means (in one-tenth the epochs). arXiv:2611.09501.
  3. Arthur D, Vassilvitskii S (2007). k-means++: the advantages of careful seeding. Proceedings of the 18th ACM-SIAM Symposium on Discrete Algorithms, 1027–1035.

Next: Part 11. Audit the books: ten types of round. The same method for single rounds.