0
\$\begingroup\$

For Part I of this discussion, see this thread: Probability help on rolling two D4 with all doubles counting as zero except double 4s, which count as 4

That dealt with probabilities using two D4 dice, most of which I could understand.

In Part II I also need to find probabilities, but I have NO IDEA how to calculate them. Hoping someone here can help. I hope I can explain it effectively.

THE SYSTEM: I have a chart on which six individual pieces move. Their respective movement is determined by a set of six disks that move left-to-right on a six-space-track (see inset image) which 'loops' back around to the beginning, forming a continuous circuit. Each of the colored disks match the color and icon on a D6.

Region Tokens

Those colors are blue, orange, yellow, green, red and purple. When a color is rolled THAT corresponding disk moves one space to the right on the track. If it reaches the end it loops back to the first space on the far left. This movement inevitably creates "stacks" of various size. Which is the whole point, because the number of tokens in the stack is the number of spaces a colored pawn will move on the chart mechanism.

Example: I roll the D6 and it comes up Green (forest). So I move the green forest token one space to the right where it now sits on top of the red token. This forms a "stack" of two tokens. Since Green was activated it will be the green pawn that will move 2-spaces on the chart.

This process of roll and move goes on indefinitely. The very first move will always result in a 'stack' 2-high, but as you continue rolling the tokens will become dispersed, forming stacks of 1,2,3 and occasionally 4-high. Theoretically stacks could reach 6-high, but 4 is the highest I have seen despite hundreds of test rolls. Logically 1 and 2 stacks should be more frequent and that seems to match my tests, 2-stacks being the most prevalent, though it's not always consistent.

Is there any way to calculate the odds for each 'stack' value: 1, 2, 3, 4, 5, 6?

The colors and icons are irrelevant to my query, so we may convert those to numbers if that helps: Blue=1, Orange=2, Yellow=3, Green=4, Red=5 and Purple=6

WHERE DO I START?

  1. Each movement is always exactly 1 space
  2. There are exactly 6 tokens
  3. There are exactly 6 spaces (but on an infinite loop)
  4. Smallest possible 'stack' 1
  5. Largest possible 'stack' 6
  6. First move always creates a 'stack' of 2

I am particularly curious how 1,2,3,4 compare to those in the D4 system referenced at the at the beginning.

\$\endgroup\$
13
  • 2
    \$\begingroup\$ You will not solve this problem by hand. You basically need to write a monte carlo simulation of the situation in some programming language or other. But, I have to ask a very pointed question: Is this for a role playing game? Or some other type of game. Because I am not seeing the obvious connection to RPGs here. \$\endgroup\$
    – Novak
    Commented Aug 28, 2023 at 4:15
  • 1
    \$\begingroup\$ @behemothbeer RPGs are a narrow subset of board games, at best. \$\endgroup\$
    – MJ713
    Commented Aug 28, 2023 at 4:25
  • 1
    \$\begingroup\$ @behemothbeer Well, the tour says "Don't ask about...Anything not directly related to role-playing games" and "Don't ask about...Questions about computer RPGs or board and card games". I don't make the rules, but there they are. \$\endgroup\$
    – MJ713
    Commented Aug 28, 2023 at 5:32
  • 5
    \$\begingroup\$ Unfortunatey this question is off-topic for our site. However you may be able to ask a version of it at one of our sister sites (Cross Validated, Mathematics or Board & Card Games). Be sure to check their posting requirements first though. Good luck! \$\endgroup\$
    – linksassin
    Commented Aug 28, 2023 at 6:38
  • 1
    \$\begingroup\$ @behemothbeer We answer dice and probability questions specifically as they relate to the main topic of the stack, which is tabletop role-playing games. We are not a stack that supports all games, or all dice questions, or all probability questions. That is why your question is off topic. \$\endgroup\$
    – Novak
    Commented Aug 28, 2023 at 13:11

1 Answer 1

1
\$\begingroup\$

Stationary distributions

You are probably looking for the stationary distribution of a Markov chain. If a unique stationary distribution exists, it represents what happens if you play the game for an infinite amount of time.

Stationary distributions can be found using an eigenvalue decomposition of the game's transition matrix. We'll represent the game state from the perspective of the last token to move, say blue:

  • Since the track is circular, if we roll blue on the die, it's the same as everyone else going back one space. So we will do that instead of tracking blue's position explicitly.
  • If we roll another color, they go forward one space, wrapping around if necessary.

One script later:

from itertools import combinations_with_replacement
import numpy as np

index_to_state = {}
state_to_index = {}

for i, state in enumerate(combinations_with_replacement(range(6), 5)):
    index_to_state[i] = state
    state_to_index[state] = i

n = len(index_to_state)

# Compute transition matrix.
transition = np.zeros((n, n))
for src in range(n):
    src_state = index_to_state[src]
    # Note that python/numpy indexes start at 0.
    for roll in range(6):
        if roll == 5:
            dst_state = [(x - 1) % 6 for x in src_state]
        else:
            dst_state = [x for x in src_state]
            dst_state[roll] = (dst_state[roll] + 1) % 6
        dst_state = tuple(sorted(dst_state))
        dst = state_to_index[dst_state]
        transition[dst, src] += 1/6

eigenvalues, eigenvectors = np.linalg.eig(transition)

we see that there is indeed a unique eigenvalue of +1. We can compute the stack size as

stationary_eigenvector = np.real(eigenvectors[:, np.argmax(np.real(eigenvalues))]

# The stack size is the number in the same spot as us (0).
stationary_stack_size = np.zeros(6)
for i, p in enumerate(stationary_eigenvector):
    state = index_to_state[i]
    stationary_stack_size[sum(x == 0 for x in state)] += p

print(stationary_stack_size / np.sum(stationary_stack_size))

which gives

[4.01877572e-01 4.01877572e-01 1.60751029e-01 3.21502058e-02
 3.21502058e-03 1.28600823e-04]

which is the same as if you had simply placed the other five tokens on the board uniformly and independently at random.

(This could be proved explicitly from the fact that any game state can be reached from any other game state, therefore the Markov chain is irreducible, therefore it has a unique stationary distribution. Then if you guess a distribution and it turns out to be stationary, that has to be the one. But the numerical approach can also be instructive.)

The mean stack size is then exactly \$11/6 \approx 1.83\$, which is a bit more than the \$1.5\$ of your other post.

The parity effect

However, there is a wrinkle: there is also an eigenvalue of -1, which is due to a parity effect. If you assign the numbers 1-6 to the spaces, and add up the spaces of each of the tokens, the total flips between even and odd on each turn. For example, it is impossible to land a 6-stack when the sum is odd. So the game flips between two disjoint sets of states. The stationary distribution is a half-and-half mix of these two sets.

We can compute the parity effect on stack size in a similar way:

parity_eigenvector = np.real(eigenvectors[:, np.argmin(np.real(eigenvalues))])

parity_stack_size = np.zeros(6)
for i, p in enumerate(parity_eigenvector):
    state = index_to_state[i]
    parity_stack_size[sum(x == 0 for x in state)] += p

print(parity_stack_size / parity_stack_size[-1] * stationary_stack_size[-1])

Result:

[-0.0001286   0.000643   -0.00128601  0.00128601 -0.000643    0.0001286 ]

Here we see turns that land on an even space sum are relatively more likely to land on an even-sized stack, and turns that land on an odd space sum are relatively more likely to land on an odd-sized stack. But in terms of mean stack size it's a wash.

There are also similar periodic effects modulo 3 and 6, with complex eigenvalues corresponding to roots of unity.

\$\endgroup\$
3
  • \$\begingroup\$ > [4.01877572e-01 4.01877572e-01 1.60751029e-01 3.21502058e-02 3.21502058e-03 1.28600823e-04] - in other words: 1 and 2 make up 80.4%, 1-3 is 96.5%, and 1-4 are 99.7%, the last two delivering only about 0.33% \$\endgroup\$
    – Trish
    Commented Aug 28, 2023 at 8:22
  • \$\begingroup\$ OP mentioned in chat that "most games will be complete in 30-40 moves", which does change the distribution slightly, since e.g. large stacks cannot occur in the earliest rounds. But the differences are pretty small (I ran some Monte Carlo simulations in Python). \$\endgroup\$
    – MJ713
    Commented Aug 29, 2023 at 19:12
  • \$\begingroup\$ The convergence rate can be described using the largest eigenvalue less than 1 in magnitude, which in this case appears to be 5/6. You may find 1 - 5/6 referred to as the "spectral gap", though the periodicity complicates this slightly. \$\endgroup\$ Commented Aug 30, 2023 at 5:05

Not the answer you're looking for? Browse other questions tagged .