3
Background
As described here http://www.ericharshbarger.org/dice/#gofirst_4d12, "Go First" Dice is a set of four dice, each with unique numbering, so that:
- There will never be a tie. Each die has a unique set of numbers.
- Regardless of what subset of dice are rolled against one another, each player will always have an equal chance of rolling the high number.
Here is the specific numbering for the four dice mentioned, as an example:
DICE COUNT: 4
FACE COUNT: 12
D1: 1,8,11,14,19,22,27,30,35,38,41,48
D2: 2,7,10,15,18,23,26,31,34,39,42,47
D3: 3,6,12,13,17,24,25,32,36,37,43,46
D4: 4,5, 9,16,20,21,28,29,33,40,44,45
Goal
Without requiring any particular result, I would like to be able to generate a set of N
"Go First" dice... Such that, example output might look like so (formatted, python console):
>>> generate_dice(players=4)
[[1,8,11,14,19,22,27,30,35,38,41,48],
[2,7,10,15,18,23,26,31,34,39,42,47],
[3,6,12,13,17,24,25,32,36,37,43,46],
[4,5,9,16,20,21,28,29,33,40,44,45]]
The number of sides here is chosen just for example purposes, because it matches the other example given. The number of sides of the dice can be determined by the algorithm used.
Ideally the solution would be in Python, but I can also read PHP, Javascript, some Ruby, quite well.
I'm honestly puzzling over this, and would love to understand what terminology/math I should have studied to figure this out. I've tried to explain it before, but seem to be having trouble not using words that imply too many things about what should be generated, and what odds should be, etc. I'm specifically interested in being able to generate "a set of N 'Go First' dice".
Extra
Here's some ugly python, to "prove" the dice, and perhaps give an example.
def fair_chance(die1, die2):
wins = 0
losses = 0
ties = 0
for i in die1:
for x in die2:
if cmp(i, x) < 0:
losses += 1
if cmp(i, x) > 0:
wins += 1
if cmp(i, x) == 0:
ties += 1
if wins == losses and losses != 0 and ties == 0:
return True
return False
Give the above example dice:
D1 = [1,8,11,14,19,22,27,30,35,38,41,48]
D2 = [2,7,10,15,18,23,26,31,34,39,42,47]
D3 = [3,6,12,13,17,24,25,32,36,37,43,46]
D4 = [4,5, 9,16,20,21,28,29,33,40,44,45]
fair_chance(D1, D2) # True
fair_chance(D1, D3) # True
fair_chance(D1, D4) # True
fair_chance(D2, D3) # True
fair_chance(D2, D4) # True
fair_chance(D3, D4) # True
Thus, the function generate_dice
should work, such that output in a Python shell would look like this:
>>> dice = generate_dice(players=4)
>>> D1 = dice[0]
>>> D2 = dice[1]
>>> D3 = dice[2]
>>> D4 = dice[3]
>>> fair_chance(D1, D2)
True
>>> fair_chance(D1, D3)
True
>>> fair_chance(D1, D4)
True
>>> fair_chance(D2, D3)
True
>>> fair_chance(D2, D4)
True
>>> fair_chance(D3, D4)
True
What is the objective winning criterion?
– Peter Taylor – 2012-09-08T18:58:42.573Also note: your "proving" code only checks pairs, but the spec requires that "Regardless of what subset of dice are rolled against one another, each player will always have an equal chance of rolling the high number" (my emphasis). – Peter Taylor – 2012-09-09T07:45:48.347
It's fairly easy to prove a basic constraint on the number of sides the dice must have (assuming they each have the same number of sides). If we have
– Peter Taylor – 2012-09-20T20:36:51.850N
dice each havingD
sides and we want a fair result for any1 < M <= N
subset, we requireD^M == 0 (mod M)
. ThereforeD
must be a multiple of theN
th primorial number.