Title: Some Mathematics of Machine Gaming
1Some Mathematics of Machine Gaming
- Prepared for
- American Mathematics Association of Two Year
Colleges - in Minneapolis for New Orleans
- 2 November 2007
- By Robert N. Baker
- New Mexico State University-Grants
- rnbaker_at_nmsu.edu
- This version for the AMATYC website has been
edited to reduce file size
2My thesis You dont need to rig the machine
to make profit, just rig the numbers. The
latter is legal, the former is not. This
workshop investigates how to do so, in classroom
ready activities, with keystrokes for using
table features of the TI -83 model graphing
calculator.
3- The Deck A Set to Model Computer Memory
-
- The Standard Deck of Cards and the Algebra of
Manipulating Computer Memories at the MAA at Reed
College, 1996 - Dynamic Memories S. Brent Morris, NSA
Director - Serial access and the Perfect Shuffle
- Static Memories aka RAM me, grad student
- Direct access and set construction
- Naming and accessing locations In an
economical fashion - Constructing large blocks on demand From
non-contiguous locations - Originally the deck was designed as a physical
model of the ancient four-tier Caste Social
System of China, - Pips evolved to indicate things associated with
the four classes in different societies across
Eurasia, through about 1600 AD. - Peasants (clubs) Military (spades) Professional
(diamonds) Theological (hearts)
4In 2007, decks of cards, on sale literally around
the world, use the pips and colors and structure
established by 1600 in France. Historical Note
The deck called the tarot spun off the standard
deck sometime after 1400ish, in Italy.
5Expansion-enabling technology for deck A.D. Chinese paper and printing - Block
printing on tiles, heavy paper - Popular among
royalty (invented by ? 969 A.D. ?) trade routes - Italy, Marco Polo, the Silk Road,
the Turks - Muslim expansion, Iberian peninsula
mines intellectual discourse Gutenbergs printing press (Cash for a starving
artist!) American mines, more world trade routes New Orleans, Mississippi River trade, riverboat
culture of movement - Improved printing,
cutting, stock - Rounded corners eased
shuffling! - Factory system kept price down.
1800s America moved west in wagons - Corner
indicators printed for shortcut - New! Blank
card(s) in each deck free. adopted blank as wild card tarot Jester?) introduced as model of real society The one of every bunch
who fits nowhere and everywhere.!?
6Poker
- A vying game winner determined by players
comparing their combinations of cards - Evolved in parlors and around campfires around
the world for more than 500 years - Formalized in cosmopolitan 1800s New Orleans with
a 20 card deck for 4 players max. - Now a television sport! (my San Diego topic)
- Now also a one-player machine game--the topic of
todays workshop.
7- Poker across continents and centuries A
combination game - ? 969 A.D. Chinese emperor Mu Tsung wife
(inventress?) - 15th Century Regional European variations
similar in structure - - Italian Il Frusso, Primiera French LaPrime,
LAmigu, LMesle or Brelan - - English Post and Pair and Brag German Pochen
- establish theory of probability
- 1708 -P. R. de Montmort, Essai danalyse sur les
jeux de hazard (Analtyic Essay - on Games of Chance). Applied probability to
card games and all life. - 1718 Louisiana territory game Poque - Five card
hand from 20 card deck, one bet showdown - 1800 Faro and 3-card Monte still most popular
card games on the circuit - 1834 J. H. Green documented the cheating
game, by the name Poker - 1840 Full-deck Poker introduced
- - Lowered typical hand enabled more players per
game - - The flush arose outside of royal setting,
accepted - 1860s 5-card Draw poker introduced--a second
bet - - 5-card Stud poker introduced--four bets
possible - - Straight became an officially-valued hand
8- Defining Order on the set
- Comparative-value for the decks kinds
- In the rules of poker,
- the kinds are given a (transitive) ordering.
- HIGH To LOW
- Aces, kings, queens, jacks, 10s, , 3s, 2s
- A k q j 10 9 3 2
- This post-1800 ordering is used to determine the
winner of the cut, and to help well-define an
order on the hands. - (Some house rules allow the ace also low.)
9Defining Order in the game
- Comparative-value for the types of hands
- In the rules of poker,
- the types of hands are given a (transitive)
ordering. - HIGH To LOW
- Straight Flush, 4 of a kind, full house, flush,
straight, 3 of a kind, - two pair, one pair, none of the above.
- SF 4K FH Fl St 3k 2pair 1pair
nota - This ordering is used to determine the winner of
each round of play (also known as a hand), nested
on the ordering of the kinds.
10- In poker, the value/ordering of hands is given by
the rules of the game. - Circa 15th Century
- It is not an arbitrary order.
- Two hands compare inversely to the
- probabilities of getting them
- (dealt from a randomized deck)
- Circa 18th Century
- Higher valued hands have lower probability of
occurrence.
11- Essential thesis Roll the Bones The history of
gambling - by David G. Schwartz
- The elaboration of probability allowed for
another path using a discrepancy between the
true odds and actual payouts to carve out a
statistically guaranteed profit. This is the most
significant change in all of gambling history and
directly let to lotteries, bookmaking, and
casinos. Thanks to a better understanding of
probability, professional gamblers can now offer
casual players the chance to bet as much as they
liked against an impersonal vendor, with the
house odds the irreducible price of
entertainment. - Pg. 80 2006 Gotham Books, Penguin Group,
Inc.
12- We will look at how to exploit this difference
between odds and payout, beginning with -
- Probabilities of different
- poker hands
- Probabilities can be computed for five-card
hands in straight poker from a randomized 52-card
deck, by counting 5-card subsets of the deck and
using techniques from probability theory.
13- General Definition Applied
- The probability you get a certain type, call it
type E, of valued combination in your 5 cards
from a randomized deck, ie. hand, is defined in
general by - Pr (E) the number of different ways of
satisfying E - the number of different 5-card hands in the
deck
14- First identify the denominator
- the number of different 5-card hands.
- - ie. the number of 5-element subsets of a
52-element set - - ie. the number of ways to choose 5 items from
52 - By the multiplication rule for events, there are
- 52 51 50 49 48 311,875,200
- ways to be dealt five cards from the deck.
15- But this computation implies a concern for the
process, which is not reflected by rules for the
game of poker. -
- Poker values only the finished five-card product
(subset, combination), not the order in which
they arrived (permutation). -
- What adjustment is needed to compute the number
we want?
16- Investigation
- Let a poker hand include a 1, 2, 3, 4, and 5.
List all of the ways this one poker hand can
result, written first-card-dealt on left, to
last-card-dealt on right. - Then count the number of these different
permutations of these five cards that all lead to
the same poker hand (combination).
17- A method Keep as much as constant as possible
for as long as possible, to make exhaustive list.
- 12345 13245 14235 15234
- 12354 13254 14253 15243
- 12435 13425 14325 15324
- 12453 13452 14352 15342
- 12534 13524 14523 15423
- 12543 13542 14532 15432
- _________________________________________
- 2 3 2 3 2 3 2 3
ways - (2 3) 4 4! different permutations
listed so far, all with the 1 dealt first.
18(Solution Cont.)
- This list includes only the ways to hold this
hand where the ace was the first card received
by the player. - Four different but similar lists--with the 2
listed first, 3 first, the 4 and 5--yield a total
of 5 lists for these five cards, each with 24
different orderings. - Thus we have constructed the
- (2 3 4) 5 5! 120
- ways to be dealt this hand.
19- With (2 3 4) 5 5! 120 different ways
to be dealt this one particular poker hand, we
generalize to say the same is true for any poker
hand. -
- Thus, we can assert
- (311,875,200) / 120 2,598,960
- different five-card hands are possible
- to construct from a standard deck of 52 cards.
20- Second, identify the numerators
- The numbers of each of the types of hands from a
standard deck of 52 playing cards. - Each computation represents its own rationale for
approaching the given counting problem. There
are often several different ways to discover the
one absolute answer to how many ways can you
...? - In the following, aCb stands for the standard
computation a!/(a-b)! b!.
21- Numbers of Hands
- 1 pair, no better i) 13 4C2 12C3 43
1,098,240 ii) (52 3
/ 2!) (48 44 40 / 3!) - 2 pairs, no better i) 13C2 4C2 4C2 11 4
123,552 ii) (52
3 / 2) (48 3 / 2) / 2! 44
iii) (13C1 4C2) (12C1 4C2) / 2! 11C1
4C1 -
- 3 of a kind, no better i) 13 4C3 12C2 42
54,912
ii) (52 3 2 / 3!) (48 44 / 2!)
iii) 13 4C3 (12 4C1 11 4C1 /
2!) -
- Straight, no better i) 10 45 - 40
10,200
(there are 40 straight flush hands!) - Flush, no better i) 13C5 4 - 40
5,108 -
- Full-house i) 13 4C3 12 4C2
3,744
ii) (52 3 2 / 3!) (48 3 /2!)
22- Numbers of Hands, cont.
-
- 4 of a kind i) 13 4C4 12 4C1
624 - ii) (52 3 2 1 / 4!) 48
- Straight Flush i) 10 4
40 - None of the Above, nota
1,302,540 - for these two methods, you need some of the
above information - i) (hands without even a pair) - (hands that
are flush OR straight) - (13 4) (12 4) (11 4) (10 4) (9 4)
/ 5! - (10,200 5,108 40) - 1,317,888 - 15,348
- ii) (total number of hands) - (hands noted
above as valued) - 2,598,960 - (40 624 3744 5108 10,200
54,912 123,552 1,098,240) 2,598,960 -
1,296,420
23- Sum of numbers of different hands
- 2,598,960
- This number agrees with the value independently
computed via 52 choose 5.
24- The Probabilities for 5-card poker hands
- from a randomized 52-card deck.
- The probability of an event ( of elements
in that event)___
( of elements in the sample space) - Then straight poker probabilities fall from the
defining formula - The probability of a hand ( of ways that
hand can occur) 2,598,960 - For ease of writing, let s 2,598,960 the
number of different 5-card hands.
25- Type of hand Method Probability
...and no better. - Straight Flush 40/s .00001539
- 4 of a kind 624/s .00024010
- Full house 3,744/s .00144058
- Flush 5,108/s .00196540
- Straight 10,200/s .00392464
- 3 of a kind 54,912/s .02112845
- Two pairs 123,552/s .04753902
- One pair 1,098,240/s .42256903
- None of the above 1,302,540/s .50117739
26Two tools needed in the move to
machines Definition A random variable is a
function with a non-numeric domain (often
well-defined situations) and numeric range. It
is a rule that assigns a number to a condition.
Often defined with a function table, a random
variable is neither random nor variable. Definiti
on The expected value of a random variable is a
weighted average of the random variables values
(range), with their probabilities as the weights.
For random variable called with range values
i then ExpVal() ? i Pr ( i )
27Cooperative Data Entry Observed on the helm of
USCG M/V Planetree, 2001
- To transfer data surely and quickly Use two
pairs to accommodate the human propensity for
typos. - On deck at the source of data
- One person reads the data out loud.
- One person reads and listens, to catch spoken
typos. - In the helm at the destination of data
- One person types the data into the machine.
- One person listens and watches, to catch written
typos.
28To a single-player game
- Winning determined by comparing the player to the
true odds, rather than to other players. - Winnings determined from the true odds, rather
than by vying. - In a fair game each hand paid at the reciprocal
of its probability. (Our first activity.) - Commercial machine games are designed to generate
profit at specified rates, typically capped by
state laws. (Our second activity.)
29- A Problem
- Logistical and psychological difficulties arise
in paying out in Single-Player games. - Our Solution
- Define and adjust a random variable until it
meets given constraints. Ill call it payout
and denote it - For this we will use the power of the list in
TI-83 calculators
30- First, well use the number 2,598,960
often, so want to give it an easy name. I
like the letter s. - In the home screen of your calculator (use 2nd
QUIT to get there, from anywhere) - type 2 5 9 8 9 6 0 STO then ALPHA S
then ENTER (S is the letter on the LN
button, in the leftmost column.) - From here on, use 2nd RCL ALPHA s to invoke
2,598,960.
31- Next, well begin work with lists.
- Hit STAT then ENTER to get into the lists
window. - Well want to use at least 6 lists, so if already
full of data, you should clear them.
32- Indicates auxiliary calculator info, often
relevant to students. - To clear all lists,
- use 2nd MEM ClrAllLists.
- MEM is an option on the key. Once in the MEM
window, you may simply hit the 4 key to activate
4 ClrAllLists, or else you may arrow down to
highlight 4 ClrAllLists and then hit ENTER. - Either way, the calculator will go to its home
screen, awaiting your command to execute that
operation. Hit ENTER. Then return to the list
screen via STAT ENTER.
33- Indicates auxiliary calculator info, often
relevant to students. - To clear one entire list,
- arrow up until the list title is highlighted,
hit CLEAR then hit the down arrow. - That list will be emptied, awaiting data input,
without altering the contents of any other list.
34- Indicates auxiliary calculator info, often
relevant to students. - To remove one entry from a list,
- use arrows to highlight it, then hit DEL.
- This will remove that value, and move the rest
of the list up by one position. - To change one entry in a list,
- highlight it, key in your desired value, then
hit ENTER.
35- In L1 enter the basic data for our
investigation - The number of ways each type of hand can occur.
- Arrow the cursor into L1 then type
- 40 ENTER 624 ENTER 3744 ENTER
- 5108, 10200, 54912, 123552,
- 1098240, 1302540.
- Be sure to hit ENTER after each value.
36- In L2, compute probabilities.
-
- Right arrow into L2, then up arrow until title is
highlighted. - Type 2nd L1 ALPHA S ENTER
- L2 fills with decimal approximations for the
probabilities of each of the types of hands
37- Indicates auxiliary calculator info, often
relevant to students. - Recall 1.5E5 is the TIs format for
scientific notation, and means 0.000015. - To view an entry with more accuracy, highlight
that entry, look on bottom row of screen
38- Use L3 to compute a fair game payout rule
- In theory, in a fair game the payout for an event
should be inversely proportional to its
probability. Thus we can create a reasonable
random variable for payout by taking the
reciprocals of probabilities. - Right arrow into L3, then up arrow until title is
highlighted. Type 1 2nd L2 ENTER - L3 fills with the reciprocals of the
probabilities
39- In computing the expected value of this payout
design, each product-pair is a number times its
reciprocal (pr times 1/pr), thus 1. - With a partition of 9 elements, the expected
value of this random variable is 9. - For our goal of a fair game, with our random
variable of inverses, the cost to play should be
9.
40- This, however, is not convenient to consumers.
- We can adjust our random variables values to
yield an expected value of 1, with commensurate
cost to play of 1, - by simply dividing each of its values by 9.
41-
- Use L4 to construct a better random variable.
- Right arrow into L4, then up arrow until title is
highlighted. Type 2nd L3 9 ENTER . -
- L4 fills with payout values for a conjectured
fair game with cost to play of 1.
42- We can now use features of the calculator to
find the expected value for the suggested
payouts, ie. for the random variable . - To determine E () ? ( P ())
- we need determine the products P () and
then sum them.
43- The traditional paper and pencil approach
requires that we compute each of the nine
products x times P(x), organize these in a table,
and then add them to obtain the random variables
expected value. - This method can be duplicated with the lists in
the calculator. Use the lists that already
contain the given information L2 has the
probabilities, L4 has the suggested fair game
payout assignments.
44- To duplicate the traditional method
- In LIST EDIT screen, arrow into L5, then up
arrow until title is highlighted. - Type 2nd L2 2nd L4 ENTER .
- L5 fills with the desired products x P (x).
- To obtain the sum of these products, and thus the
expected value of the game, we then can - Use the STAT CALC features of the calculator.
45- Tradition continued
- In Home Screen, compute E() by summing the list
of products in L5. -
- Type 2nd QUIT to get to home screen, then
STAT then arrow right to CALC then ENTER
1 for the 1-Var Stats summary. - (This places you back in home screen, where you
are prompted to supply the location for a list of
data.) - Type 2nd L5 ENTER to obtain basic stats on
data in L5. Look on the second line from the top
of this summary, - ? x gives the sum of the products stored in
L5, - which is the desired expected value.
46- OR to obtain that sum of products more directly
- The calculator can also give us our desired
result more directlyusing its sum feature. - From the home screen, hit
- 2nd LIST right arrow to MATH then type 5.
- This places sum( on the home screen. This
command needs a list for its argument. - Type 2nd L5 ) Enter.
- The returned sum is the desired expected
value. - Is it the same as ? x found in the first method?
47- Yet another way to obtain the sum from the home
screen, without needing to prepare L5 and its
intermediate products. -
- In the home screen, type 2nd ENTRY , edit the
argument to Sum (L2L4). Hit Enter. -
- This should yield the same expected value as
found above. It provides a method to obtain the
sum of products, without documenting those
products themselves. - Some keystrokes given later in this activity use
this time-saving method, when trying via guess
and check to discover a random variable that will
address legal concerns as well as human
psychology in the programming of gaming machines.
48(No Transcript)
49- Problem
- The payouts for a fair game with cost of 1
include decimal fractions. - This is inconvenient the machine and players
want payouts only in whole number multiples of
the cost to play. - Note No nice sample size smaller than 100,000
plays enables us even to expect a straight flush
in the sample. - In the above table, I chose to round
probabilities to 5 decimal places to ease working
with sample sizes 100,000. -
50- Activity 1 In search of expected value of 1
with whole number payout values. - 1) In L5, round to whole number values to
approximate the values in L4. - 2) Check the expected value by the following
key strokes, for sum of Probs Payouts - 2nd QUIT 2nd LIST arrow right to MATH
then hit 5 Sum( 2nd L2 2nd L5 ) ENTER
51- Activity 1 (Fair Game Cont.)
- 3) Adjust the list in L5 (hit STAT ENTER,
arrow into L5) to bring you closer to an expected
value of 1, then check via 2nd QUIT 2nd
ENTRY ENTER - 4) Repeat steps 2 and 3 until youve got a sum
of products, ie expected value, equal to 1. - 5) Does your random variable pay out often
enough to keep the interest of a paying player?
52- Institutionalized mercantile gambling
- Is not interested in sponsoring fair games.
- It employs Machine Poker for profit
- using a discrepancy between the true odds and
actual payouts to carve out a statistically
guaranteed profit. -
- By using a well-designed random variable
- (call it payout, with nickname )
- Based on known probabilities
- If the laws of probability hold in the long run
- (and watch that random-number generator)
- Then the costs to players will exceed the payout.
53- We will design one. Our method Assign numeric
values to each type of hand, do the computations
adjust until legal and profitable , etc. - Activity 2 Determine random variable
assignments for an expected value of 0.86. -
- 1) In L6, enter values (use the fair game
values in L5 as guidance) to guess. - 2) Check the expected value by the following
key strokes 2nd QUIT 2nd ENTRY and edit
Sum argument to L2L6 then hit ENTER.
54- Activity 2 (Cont.)
- 3) Adjust list to get closer to 0.86, as needed
(hit STAT ENTER, arrow into L6). - Check via 2nd QUIT 2nd ENTER ENTER.
- 4) Repeat step 3 until sum is very close to
0.86 and payouts seem reasonable - 5) Argue the psychological acceptability, to
players, of your payout schedule. Use number of
payouts per 100,000 plays as one of your
measurable indicators.
55Conclusions
- Comparative games can be adapted to single-player
games through probability. - Random variable, payout schedule, same thing a
rule assigning numbers to situations. - Even truly random machines pay the house, as
players accept payouts disparate from odds. - In our technologic age, once-intimidating numbers
arent so difficult to work with, and learn from. - ???