Danny Yoo <firstname.lastname@example.org>
Whenever I come to Las Vegas, I squint through the cigarette smoke at the gambling machines and frown. Dad is always puzzled by my morose behavior.
“What’s wrong?” he asks. I pause and collect my thoughts.
Why does it bother me to be here, in Vegas, watching people play these games of chance, especially when the odds are rolled by a computer program?
Here, let’s look at a simple dice-rolling program.
This is a simple program that uses the built-in random function to simulate the dice roll.
; count-frequencies: -> void ; Roll the roller a bunch of times, and tally up how the dice rolls.
> (define (count-frequencies) ; Let's keep a tally to count the dice rolls: (define tally (make-hash)) ; We will roll the dice a bunch, and add the results to our tally: (for ([trial-number (in-range 10000)]) (define this-roll (dice-roll)) (hash-set! tally this-roll (add1 (hash-ref tally this-roll 0)))) ; Finally, let's print the results: (for ([i (in-range 6)]) (printf "~a: ~a\n" (add1 i) (hash-ref tally (add1 i)))))
The result of count-frequencies on our dice-roll look reasonably even. So what’s the big problem?
Experienced programmers know that there is no true randomness here.
Rather, the rolls we are getting are pseudorandom. The computer dutifully performs
a series of steps on a piece of information—
; Let us control the seed value: > (random-seed 31337)
; Roll the dice a few times... > (for/list ([trial (in-range 10)]) (dice-roll))
'(4 3 2 2 4 5 6 3 6 5)
; If we re-seed, we'll see the exact same rolls! > (random-seed 31337)
> (for/list ([trial (in-range 10)]) (dice-roll))
'(4 3 2 2 4 5 6 3 6 5)
And how can one tell, without having access to the program’s source code, as well as the literacy to read it?
So part of my discomfort is being a member of a tribe that has a secret: programs only do what we tell them to. These programs can be perfectly impartial or partial, and it depends on whose hand guided their creation. Though they may be housed in boxes of solid steel, their integrity is ultimately based on whether or not their programmer has integrity too.
But how can I say this all to Dad as he waits there, expectantly?
“Oh, nothing,” I reply.
He nods and pulls the one-armed bandit.