BBO Discussion Forums: cool dice/probability problem - BBO Discussion Forums

Jump to content

  • 3 Pages +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

cool dice/probability problem

#41 User is offline   mgoetze 

  • PipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 4,942
  • Joined: 2005-January-28
  • Gender:Male
  • Location:Cologne, Germany
  • Interests:Sleeping, Eating

Posted 2016-April-17, 15:26

View PostZelandakh, on 2016-April-17, 11:46, said:

Intuitively, the general case of any number of dice ought to have a solution, since the number of possibilities is simply a factor greater and the single outcomes always sum to a whole factor. But proving that might be quite difficult - it would be a lot easier to disprove if someone can come up with a counter example.

Well, I don't know how general you mean the general case to be, but I think it is quite clear that you cannot accurately simulate throwing two 2-sided dice by throwing three 2-sided dice.
"One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision"
    -- Bertrand Russell
0

#42 User is offline   barmar 

  • PipPipPipPipPipPipPipPipPipPipPipPip
  • Group: Admin
  • Posts: 21,415
  • Joined: 2004-August-21
  • Gender:Male

Posted 2016-April-17, 17:52

View Postmgoetze, on 2016-April-17, 15:26, said:

Well, I don't know how general you mean the general case to be, but I think it is quite clear that you cannot accurately simulate throwing two 2-sided dice by throwing three 2-sided dice.

2-sided dice? I think those are coins. :)

#43 User is offline   nige1 

  • 5-level belongs to me
  • PipPipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 9,128
  • Joined: 2004-August-30
  • Gender:Male
  • Location:Glasgow Scotland
  • Interests:Poems Computers

Posted 2016-April-17, 20:41

View Postmgoetze, on 2016-April-17, 15:26, said:

Well, I don't know how general you mean the general case to be, but I think it is quite clear that you cannot accurately simulate throwing two 2-sided dice by throwing three 2-sided dice.
but you can with 4 * 2-sided "dice"
HHHT -> HH
HTTT -> TT
HHHH + TTTT + HHTT -> HT

0

#44 User is offline   Zelandakh 

  • PipPipPipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 10,667
  • Joined: 2006-May-18
  • Gender:Not Telling

Posted 2016-April-18, 02:39

The coin case is a good one because you can solve it using Pascal's triangle. You simply need to find a transformation between the xth row and 2(x-y) times the yth, where x is the number of dice thrown and y the number required. x=3 and y=2 gives 1:3:3:1 and 2:4:2, which as Michael points out does not work, whereas, as Nigel points out, x=4, y=2 is 1:4:6:4:1 -> 4:8:4, which can be mapped by adding the 2 triples to the HHTT result (4:6+1+1:4). The same logic shows that x=4, y=3 also fails as a mapping from 1:4:6:4:1 to 2:6:6:2 is also not available. This time increasing x to 5 (1:5:10:10:5:1), 6 (1:6:15:20:15:6:1) or 7(1:7:21:35:35:21:7:1) does not give a solution. I have not checked further but it does not look good for the general case. ;)
(-: Zel :-)
1

#45 User is offline   WellSpyder 

  • PipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 1,627
  • Joined: 2009-November-30
  • Location:Oxfordshire, England

Posted 2016-April-18, 04:03

View PostVampyr, on 2016-April-16, 14:55, said:

I play backgammon, and it is often important to distinguish between one die and two (or more) dice.

Perhaps we'll all end up just calling then cubes.....
0

#46 User is offline   Cyberyeti 

  • PipPipPipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 13,925
  • Joined: 2009-July-13
  • Location:England

Posted 2016-April-18, 05:04

View Postbarmar, on 2016-April-17, 17:52, said:

2-sided dice? I think those are coins. :)


Roleplayers will know that you do occasionally have to roll 2 sided dice. You normally roll a 6 sided dice and go odd/even or high/low.
0

#47 User is offline   Zelandakh 

  • PipPipPipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 10,667
  • Joined: 2006-May-18
  • Gender:Not Telling

Posted 2016-April-18, 05:58

View PostCyberyeti, on 2016-April-18, 05:04, said:

Roleplayers will know that you do occasionally have to roll 2 sided dice. You normally roll a 6 sided dice and go odd/even or high/low.

My standard random roll was a d20 and a d10, which covered most possibiilites - ability checks, percentile rolls, wandering monsters, etc - without tipping off the players what was going on. The same principle applies though, 1-10 -> 1, 11-20 -> 2 and ignore the d10. That is of course also the answer to the earlier question about simulating a die of a lower number of sides. B-)
(-: Zel :-)
0

#48 User is offline   nige1 

  • 5-level belongs to me
  • PipPipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 9,128
  • Joined: 2004-August-30
  • Gender:Male
  • Location:Glasgow Scotland
  • Interests:Poems Computers

Posted 2016-April-18, 22:37

Perusing the YouTube discussion , Alan Ingleby's answer seems neat
When m = 3 and n = 2:
t = m1 + m2 + m3.
n1 = 1 + (t mod 6).
n2 = 1 + (t mod 3) + 3 * (t mod 2).

0

#49 User is offline   gwnn 

  • Csaba the Hutt
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 13,027
  • Joined: 2006-June-16
  • Gender:Male
  • Location:Göttingen, Germany
  • Interests:bye

Posted 2016-April-19, 00:08

That can't work. You can't map 3 dice to 2 based on the sum alone. This has been established.
... and I can prove it with my usual, flawless logic.
      George Carlin
0

#50 User is offline   nige1 

  • 5-level belongs to me
  • PipPipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 9,128
  • Joined: 2004-August-30
  • Gender:Male
  • Location:Glasgow Scotland
  • Interests:Poems Computers

Posted 2016-April-19, 06:51

View Postgwnn, on 2016-April-19, 00:08, said:

That can't work. You can't map 3 dice to 2 based on the sum alone. This has been established.
Duh :(
0

#51 User is offline   nige1 

  • 5-level belongs to me
  • PipPipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 9,128
  • Joined: 2004-August-30
  • Gender:Male
  • Location:Glasgow Scotland
  • Interests:Poems Computers

Posted 2016-May-25, 23:39

https://www.youtube....h?v=hBBftD7gq7Y
Some other solutions.
0

#52 User is offline   gwnn 

  • Csaba the Hutt
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 13,027
  • Joined: 2006-June-16
  • Gender:Male
  • Location:Göttingen, Germany
  • Interests:bye

Posted 2016-May-26, 05:41

View Postnige1, on 2016-May-25, 23:39, said:


thanks for that - I was subscribed to his channel but somehow missed this video! wow a lot of material out there. I did enjoy some of the solutions and I don't think this "hexagon" method is as impressive as he makes it out to be. *shrug*
... and I can prove it with my usual, flawless logic.
      George Carlin
0

#53 User is offline   nige1 

  • 5-level belongs to me
  • PipPipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 9,128
  • Joined: 2004-August-30
  • Gender:Male
  • Location:Glasgow Scotland
  • Interests:Poems Computers

Posted 2016-June-05, 19:02

You can save the following code as a hypertext file e.g. cooldice.htm and run it by clicking on the file-name. It demonstrates a method that works and a method that fails. Also Gwnn's solution. You can easily include your own.

<!DOCTYPE html>
<html>
<head>
<title>dice</title>
<meta name="author" content="2016 Nigel Guthrie">
<meta charset="utf-8">
<style>
nav {
	background: yellow;
	position: fixed;
	right: 0;
	top: 0;
	width: 15em;
	z-index: 1;
}/* Right menu sidebar */
.D  {
	text-align: right; 
	border: medium solid black;
}
.D0, .D1, .D2 	{
	background: red; 
	color: white; 
	font-weight: bold; 
	text-align: center;
}
.D0 {background: green;}
.D2 {background: blue;}
</style>
</head>
<body>
<nav>
<p>Numberphile 3 dice ==> 2.
<br>Click a transform method</p>
<ul>
<li><a href="javascript: DEMO.show (modmod);">modmod: Modulo 6 and 3.</a>
<li><a href="javascript: DEMO.show (tetris);">tetris: Tetra/tri nums.</a>
<li><a href="javascript: DEMO.show (bigwee);">bigwee: Big and small.</a>
</ul>
</nav>
<script>
const SIDES = 6;
var DEMO = {
a: SIDES,
b: SIDES,
c: SIDES,
start: function start () {
	DEMO.a = DEMO.b = DEMO.c = 6
},// initialize demo.
die: function die () {
	return 1 + Math.floor (SIDES * Math.random())
},// Random die throw.
rand3: function rand3 () {
	return [DEMO.die(), DEMO.die(), DEMO.die()]
},// Random throw of 3 dice.
perm3: function perm3 () {
	if (++DEMO.c > SIDES)  {
		DEMO.c = 1;
		if (++DEMO.b > SIDES) {
			DEMO.b = 1;
			if (++DEMO.a > SIDES) {
				DEMO.a = 1;
			}
		}
	}
	return [DEMO.a, DEMO.b, DEMO.c];
},// Next higher permutation of 3 dice.
sumMod: function sumMod(d, m) {
	return (d[0] + d[1] + d[2]) % m
},// Sum of dice modulo 3.
tri: function tri (n){
	return n * (n + 1) / 2
},// Triangular number.
tet: function tet (n){
	return n * (n + 1) * (n + 2) / 6
},// Tetrahedral number.
show: function show (dice3) {
	h2 = document.createElement ("h2");
	document.body.appendChild (h2);
	h2.innerHTML = ("Demo of method: " + dice3.name);
	DEMO.simulate (DEMO.perm3, dice3, 216);
	DEMO.simulate (DEMO.rand3, dice3, 3600);
},// Create table, demonstrate method with permed and random throws.
simulate: function simulate (dice3, transform, chucks) {
	var m = DEMO.table (dice3.name);
	for (var i = 0; i < chucks; i++) {
		var d3 = dice3 ();
		var d = transform (d3);
		m [d[0]][d[1]].innerHTML++;
		m [d[0]][SIDES + 1].innerHTML++;
		m [SIDES + 1][d[1]].innerHTML++;
		m [SIDES + 1][SIDES + 1].innerHTML++;
//		alert ("3 dice: " + d3 + " ==> 2 dice: " + d);
	}
},// Count occurences of each pair of dice.
table: function table (text) {
	var m = [];
	var tb = document.createElement ("table")
	document.body.appendChild (tb);
	for (var r = 0; r < SIDES + 2; r++) {
		var tr = document.createElement ("tr");
		tb.appendChild (tr);
		m [r] = [];
		for (var c = 0; c < SIDES + 2; c++) {
			var td = document.createElement ("td");
			td.className = "D";
			tr.appendChild (td);
			m [r] [c] = td;
		}
		m [r][0].innerHTML = m [0][r].innerHTML = r;
		m [r][0].className = "D1";
		m [0][r].className = "D2";
	}
	m [0][0].innerHTML= text;
	m [0][0].className= "D0";
	m [0][SIDES + 1].innerHTML= m [SIDES + 1][0].innerHTML= "Total";
	return m;
},
};// Demo object containing common functions.

function modmod (d) {
/** Promising but failing effort.
	Sum mod 3 is the index of the 2nd die.
**/
	return [ 1 + DEMO.sumMod (d, 6), d.sort () [DEMO.sumMod (d, 3)]];
};// 3 dice => 2. Choose a die depending on sum mod 3 (fails).

function num35 (a, b, c){
	if ((a == b) && (b == c)) return 0;
	if (b == c) b = a;
	return DEMO.tet (5 - a) + DEMO.tri (5 - b) + 5 - c + 2;
};// Jan van Lent: 3 dice ==> number from 0 to 35 (uniformly).

function tetris (d) {
/** Jan van Lent's solution.
	Reduce 3 dice to a number from 0 to 35.
	The two dice are n mod 6 and the floor of n/6.
**/
	d.sort ();
	var n = num35 (d [0], d [1], d [2]);
	return [1 + Math.floor (n/6), 1 + n % 6]
};

function bigwee (d) {
/** Gwnn's solution.
	Define s as 1, 2, 3, or 4 and B as 5 or 6.
	identical numbers: 66
	BBB: 55 (nb: just 556 or 566 as 555 and 666 are already taken)
	ssB: ss (i.e., forget about the 5 or 6)
	sBB: s5 (i.e., take the small one and include a 5)
	sss: m6, where m is the sum of the three mod 5.
**/
	d.sort ();
	if ((d[0] == d[1]) && (d [1] == d[2])) return [6, 6];
	if ((d[0] > 4) && (d[1] > 4) && (d[2] > 4)) return [5, 5];
	if ((d[0] < 5) && (d[1] < 5) && (d[2] > 4)) return [d[0], d[1]];
	if ((d[0] < 5) && (d[1] > 4) && (d[2] > 4)) return [d[0],5];
	return [1 + DEMO.sumMod (d, 5), 6];
}
</script>
</body>
</html>

1

#54 User is offline   barmar 

  • PipPipPipPipPipPipPipPipPipPipPipPip
  • Group: Admin
  • Posts: 21,415
  • Joined: 2004-August-21
  • Gender:Male

Posted 2016-June-06, 09:36

LOL, that's probably the first time that the "code" markup has been used in this forum to post actual computer code.

#55 User is offline   barmar 

  • PipPipPipPipPipPipPipPipPipPipPipPip
  • Group: Admin
  • Posts: 21,415
  • Joined: 2004-August-21
  • Gender:Male

Posted 2016-June-06, 09:38

I've put it online in my development sandbox so you don't need to know how to do it yourself.

http://dev.bridgebas...t/cooldice.html

  • 3 Pages +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users