Calculating Probability of Consecutive Varying rows.
Game Rules
DEMO
- A sequence is assembled from discrete sections.
- Each section has an equal probability to be divided into several segments { 1, 2, 3, 4, 5, 6, 7, 8 }.
- Each segment has an equal probability to be colored { red, green, blue, cyan, magenta, yellow }.
- Each section has an equal length.
- Every next subsequent section is connected to the previous one.
- All adjacent segments on different sections with the same color form a path starting from the last one.
- Round starts with two sections already stacked.
- For every step, if any new paths are formed the game is continued, otherwise it ends.
Probability Calculation
- Least Common Multipler for {1,2,3,4,5,6,7,8} = 840. Which is the minimum resolution for section length.
- To define all possible connections for all possible segments a boolean matrix is defined.
-
Adjacency Matrix
- Before calculating probability for Nth step, consider simple case.
- Number of all permutations for any two sections is
- \[ Permutations(prev, next) = colors^{(length_{prev} + length_{next})} \]
- Example of all permutations with lengths = { 1,2 } and colors = { red, blue }.
- \[ Permutations = 2^{1+2} = 2^3 = 8 \]
- Some of the patterns have a higher number of permutations which form connections.
- Every single section acts as a high-pass filter.
- Higher number of distinct colors correlates with a higher chance to form connections.
-
AA2 AB2 AA6 AB6 Total 4 4 36 180 Hits 2 4 6 60 Chance 50% 100% 16.67% 33.33% - \[ Variations(section_{length}) = colors^{length} \]
-
Segments 1 2 3 4 5 6 7 8 Variations 6 36 216 1296 7776 46656 279936 1679616 Patterns 1 2 5 15 52 203 876 4111 - Number of color permutations for each pattern is
- \[ Permutations(pattern) = \frac{colors!}{(colors - (Distinct(pattern) + 1))!} \]
- A matrix describing the amount of permutations with connections for every pair of patterns was generated.
- Using "Markov chain" model, it is possible to find a probability for reaching any step in the sequence.
- \[ Probability(step) = \sum_{i=1}^{8}\frac{\sum_{p=1}^{patterns_i} Permutations(pattern_p)Probability(pattern_p, step - 1)}{8 \sum_{p=1}^{patterns_i}Permutations(pattern_p)} \]
- With a starting condition of Probability(step = 0) = 1
- \[ Probability(pattern, step) = \] \[ \sum_{i=1}^{8} \sum_{p=1}^{patterns_i} Probability(pattern, step - 1) \frac{Intersection(pattern_p, pattern)Permutations(pattern_p)}{8Permutations(pattern) \sum_{p'=1}^{patterns_i}Permutations(pattern_{p'})} \]
- To determine the probability for streaks, we have to look at each segment in isolation.
- For connections starting from the first section, the probability for every segmentN to have connection with the length N.
- \[ Probability(segment_s, step) = \sum_{s'=1}^{segments} AdjacencyMatrix_{s s'} \frac{Probability(segment_{s'}, step - 1)}{8 colors} \]
- With a starting condition of Probability(step0) = 1
- For connections starting with offset > 0.
- First, probability for each step that certain segment is continuing any connection is defined.
- \[ Probability_c(segment_s, step) = \] \[ \sum_{i=1}^{8} \sum_{p=1}^{patterns_i} \frac{Distinct(pattern_p AdjacencyMatrix_i)Permutations(pattern_p)Probability(pattern_p, step - 1)}{8 colors \sum_{p'=1}^{patterns_i}Permutations(pattern_{p'})} \]
- \[ Probability(segment_s, step, offset) = \begin{cases} \sum_{s'=1}^{segments} AdjacencyMatrix_{ss'} \frac{Probability(segment_{s'}, step - 1, offset)}{8 colors} & step > 0 \\ Probability(section_s, offset - 1) - Probability_c(segment_s, offset) & step = 0 \end{cases} \]
- Using Monte Carlo method, theoretical results were cross checked and confirmed to be within the error margin.
- Excel File