Slot machine payout calculation

The slot machine has 5 reels and displays 3 symbols per reel (without spaces or "empty" symbols).

Payouts can occur in several ways. Some examples ...

  • A special diamond symbol will appear
  • 3 Lucky 7 appears
  • All five characters in the payline are identical.
  • All five characters have the same number, but different colors.
  • Etc.

There are also several paylines that you need to check for payouts.

Examples of 30 different paylines

What is the most efficient way to calculate winnings for each spin? Or is there a better way than brute force to apply each payout scenario to each payline?

+4
source share
2

, , . 7s, 7s. . h w - , O (hw *), .

. ( ) , * h ** w *; , m = h ^ w, , * h ** w. , , , . , 2 6 . , 2, 6.

, w [1, h], payline [i] = (1 ) . , 1 [1, 1, 1, 1, 1], 17 - [3, 3, 2, 1, 2].

, . , .

Initialize: 
    Create a root node at column 0 (off-screen, non-column part of all solutions)
    root node.length = 0
    root node.terminal = false
    Add all paylines (in the form of length w arrays of integers ranging from 1 to h) to the root nodes' "toDistribute set"
    Create a toWork queue, add the root node to it

Iterate: while toWork not empty:
    let node n = toWork.pop()
    if n.length < w
        create children of n with length n.length + 1 and terminal = (n.length + 1 == w).
    for payline p in n.toDistribute
        remove p from n.toDistribute
        if(p.length > 1)
            add p.subArray(1, end) to child of n as applicable.
    add children of n to toWork

1-11 , :

enter image description here

; sum i = 1 to w of h ^ i. ( ), , . , ; , - , .

, node ( , ..). , , dfs , node ( ), node. , . Else, . , [1, 1,...] , 1 1 2 1 , , [1, 1,...] (2, 6, 16, 20) , dfs .

, dfs, , , ( ) . , , , . , , .

+8

RTP, . - . - , . : https://raw.githubusercontent.com/VelbazhdSoftwareLLC/BugABoomSimulator/master/Main.cs

:

    private static int[][] paytable = {
        new int[]{0,0,0,0,0,0,0,0,0,0,0,0,0},
        new int[]{0,0,0,0,0,0,0,0,0,0,0,0,0},
        new int[]{0,0,0,0,0,0,0,0,2,2,2,10,2},
        new int[]{5,5,5,10,10,10,15,15,25,25,50,250,5},
        new int[]{25,25,25,50,50,50,75,75,125,125,250,2500,0},
        new int[]{125,125,125,250,250,250,500,500,750,750,1250,10000,0},
    };

:

    private static int[][] lines = {
        new int[]{1,1,1,1,1},
        new int[]{0,0,0,0,0},
        new int[]{2,2,2,2,2},
        new int[]{0,1,2,1,0},
        new int[]{2,1,0,1,2},
        new int[]{0,0,1,2,2},
        new int[]{2,2,1,0,0},
        new int[]{1,0,1,2,1},
        new int[]{1,2,1,0,1},
        new int[]{1,0,0,1,0},
        new int[]{1,2,2,1,2},
        new int[]{0,1,0,0,1},
        new int[]{2,1,2,2,1},
        new int[]{0,2,0,2,0},
        new int[]{2,0,2,0,2},
        new int[]{1,0,2,0,1},
        new int[]{1,2,0,2,1},
        new int[]{0,1,1,1,0},
        new int[]{2,1,1,1,2},
        new int[]{0,2,2,2,0},
    };

:

    private static int[][] baseReels = {
        new int[]{0,4,11,1,3,2,5,9,0,4,2,7,8,0,5,2,6,10,0,5,1,3,9,4,2,7,8,0,5,2,6,9,0,5,2,4,10,0,5,1,7,9,2,5},
        new int[]{4,1,11,2,7,0,9,5,1,3,8,4,2,6,12,4,0,3,1,8,4,2,6,0,10,4,1,3,2,12,4,0,7,1,8,2,4,0,9,1,6,2,8,0},
        new int[]{1,7,11,5,1,7,8,6,0,3,12,4,1,6,9,5,2,7,10,1,3,2,8,1,3,0,9,5,1,3,10,6,0,3,8,7,1,6,12,3,2,5,9,3},
        new int[]{5,2,11,3,0,6,1,5,12,2,4,0,10,3,1,7,3,2,11,5,4,6,0,5,12,1,3,7,2,4,8,0,3,6,1,4,12,2,5,7,0,4,9,1},
        new int[]{7,0,11,4,6,1,9,5,10,2,7,3,8,0,4,9,1,6,5,10,2,8,3},
    };

    private static int[][] freeReels = {
        new int[]{2,4,11,0,3,7,1,4,8,2,5,6,0,5,9,1,3,7,2,4,10,0,3,1,8,4,2,5,6,0,4,1,10,5,2,3,7,0,5,9,1,3,6},
        new int[]{4,2,11,0,5,2,12,1,7,0,9,2,3,0,12,2,4,0,5,8,2,6,0,12,2,7,1,3,10,6,0},
        new int[]{1,4,11,2,7,8,1,5,12,0,3,9,1,7,8,1,5,12,2,6,10,1,4,9,3,1,8,0,12,6,9},
        new int[]{6,4,11,2,7,3,9,1,6,5,12,0,4,10,2,3,8,1,7,5,12,0},
        new int[]{3,4,11,0,6,5,3,8,1,7,4,9,2,5,10,0,3,8,1,4,10,2,5,9},
    };

, RTP:

    private static void spin(int[][] reels) {
        for (int i = 0, r, u, d; i < view.Length && i < reels.Length; i++) {
            if (bruteForce == true) {
                u = reelsStops [i];
                r = u + 1;
                d = u + 2;
            } else {
                u = prng.Next (reels [i].Length);
                r = u + 1;
                d = u + 2;
            }

            r = r % reels[i].Length;
            d = d % reels[i].Length;

            view[i][0] = reels[i][u];
            view[i][1] = reels[i][r];
            view[i][2] = reels[i][d];
        }
    }

.

+1

All Articles