Shop OBEX P1 Docs P2 Docs Learn Events
Calculating Odds from Lookup Tables — Parallax Forums

Calculating Odds from Lookup Tables

MikerocontrollerMikerocontroller Posts: 310
edited 2008-10-17 19:04 in General Discussion
·· I'm trying to calculate odds for a slot machine game I posted in the Completed Projects section a few weeks ago.··My program randomly selects one value from each lookup table:

· LOOKUP rnd1,[noparse][[/noparse]0,0,0,0,0,1,1,1,2,2,2,2,3,3,3,3],rnd1
· LOOKUP rnd2,[noparse][[/noparse]0,0,0,0,1,1,1,2,2,2,2,2,2,3,3,3],rnd2
· LOOKUP rnd3,[noparse][[/noparse]0,0,0,0,1,1,1,1,1,2,2,2,2,2,3,3],rnd3


· What I'm trying to determine is the odds of 3-of -a -kind combinations and also pairs and singles of "0". A formula to work with would be appreciated.· Also what is the total number of possible combinations·?

· 16 +16(squared) +16(cubed)·?· Thanks for any help you can provide.

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-10-17 07:46
    Since there are multiple identical values in each set,
    the number of combinations is less than the number of
    permutaions.

    permutations = 16*16*16 (because there are 16 items in each set)
    combinations = 4*4*4 (because there are 4 diferent values in each set)

    If you denote the sets as A, B and C then
    A0 = 5/16 (because there are 5 0's in set A)
    A1 = 3/16
    A2 = 4/16
    A3 = 4/16
    B0 = 4/16
    B1 = 3/16
    B2 = 6/16
    B3 = 3/16
    C0 = 4/16
    C1 = 5/16
    C2 = 5/16
    C3 = 2/16

    Total odds = Ax * Bx * Cx
    Using integer math, leaving out the denominators
    the odd is an integer value relative to 16*16*16
    The highest odd = 5*6*5 = 150
    The lowest odd = 3*3*2 = 18

    Edit:
    if you say that 0,0,x is identical to 0,x,0 and x,0,0 (where x<>0, for pair of 0's)
    you must add the odds to find the odds for a pair of 0's.
    Due to the few possibilities I suggest you write out the tables
    and calculate those odds by hand. Then simply put them in a table.

    Edit2:
    Using formula's
    A0 = 5
    A1 = 3
    A2 = 4
    A3 = 4
    B0 = 4
    B1 = 3
    B2 = 6
    B3 = 3
    C0 = 4
    C1 = 5
    C2 = 5
    C3 = 2

    A0B0C0 = A0*B0*C0
    A0B0C1 = A0*B0*C1
    A0B0C2 = A0*B0*C2
    A0B0C3 = A0*B0*C3
    A0B1C0 = A0*B1*C0
    A0B1C1 = A0*B1*C1
    A0B1C2 = A0*B1*C2
    A0B1C3 = A0*B1*C3
    A0B2C0 = A0*B2*C0
    A0B2C1 = A0*B2*C1
    A0B2C2 = A0*B2*C2
    A0B2C3 = A0*B2*C3
    A0B3C0 = A0*B3*C0
    A0B3C1 = A0*B3*C1
    A0B3C2 = A0*B3*C2
    A0B3C3 = A0*B3*C3
    A1B0C0 = A1*B0*C0
    A1B0C1 = A1*B0*C1
    A1B0C2 = A1*B0*C2
    A1B0C3 = A1*B0*C3
    A1B1C0 = A1*B1*C0
    A1B1C1 = A1*B1*C1
    A1B1C2 = A1*B1*C2
    A1B1C3 = A1*B1*C3
    A1B2C0 = A1*B2*C0
    A1B2C1 = A1*B2*C1
    A1B2C2 = A1*B2*C2
    A1B2C3 = A1*B2*C3
    A1B3C0 = A1*B3*C0
    A1B3C1 = A1*B3*C1
    A1B3C2 = A1*B3*C2
    A1B3C3 = A1*B3*C3
    A2B0C0 = A2*B0*C0
    A2B0C1 = A2*B0*C1
    A2B0C2 = A2*B0*C2
    A2B0C3 = A2*B0*C3
    A2B1C0 = A2*B1*C0
    A2B1C1 = A2*B1*C1
    A2B1C2 = A2*B1*C2
    A2B1C3 = A2*B1*C3
    A2B2C0 = A2*B2*C0
    A2B2C1 = A2*B2*C1
    A2B2C2 = A2*B2*C2
    A2B2C3 = A2*B2*C3
    A2B3C0 = A2*B3*C0
    A2B3C1 = A2*B3*C1
    A2B3C2 = A2*B3*C2
    A2B3C3 = A2*B3*C3
    A3B0C0 = A3*B0*C0
    A3B0C1 = A3*B0*C1
    A3B0C2 = A3*B0*C2
    A3B0C3 = A3*B0*C3
    A3B1C0 = A3*B1*C0
    A3B1C1 = A3*B1*C1
    A3B1C2 = A3*B1*C2
    A3B1C3 = A3*B1*C3
    A3B2C0 = A3*B2*C0
    A3B2C1 = A3*B2*C1
    A3B2C2 = A3*B2*C2
    A3B2C3 = A3*B2*C3
    A3B3C0 = A3*B3*C0
    A3B3C1 = A3*B3*C1
    A3B3C2 = A3*B3*C2
    A3B3C3 = A3*B3*C3

    Pair0 = A0B0C1 + A0B0C2 + A0B0C3 + A0B1C0 + A0B2C0 + A0B3C0 + A1B0C0 + A2B0C0 + A3B0C0
    Pair1 = A1B1C0 + A1B1C2 + A1B1C3 + A1B0C1 + A1B2C1 + A1B3C1 + A0B1C1 + A2B1C1 + A3B1C1
    Pair2 = A2B2C0 + A2B2C1 + A2B2C3 + A2B0C2 + A2B1C2 + A2B3C2 + A0B2C2 + A1B2C2 + A3B2C2
    Pair3 = A3B3C0 + A3B3C1 + A3B3C2 + A3B0C3 + A3B1C3 + A3B2C3 + A0B3C3 + A1B3C3 + A2B3C3

    Three0 = A0B0C0
    Three1 = A1B1C1
    Three2 = A2B2C2
    Three3 = A3B3C3


    regards peter

    Post Edited (Peter Verkaik) : 10/17/2008 8:18:03 AM GMT
  • MikerocontrollerMikerocontroller Posts: 310
    edited 2008-10-17 19:04
    · Thank-you Peter for the explanations and examples.· This is exacly the information I was looking for.· Thank you for your time and effort!
Sign In or Register to comment.