Average Idle-Dice Rolling

2

So I ran into this progressive/idle game cleverly called Idle Dice. Has a variety of random effects applied to a pretty typical progression formula game. Warning, time sink! Play at your own risk.

However after you have 5 dice (summed the usual way) along with some bonuses for various matches (pair, two pair, three of a kind, etc), but after that you eventually get multiplier dice. These five dice are all multiplied against the total rolled by the first five dice and multiplicatively combine with each other.

Even later on you get access to a roulette wheel which can (if it lands on the right wedges) "skip 10 minutes." Sometimes longer, but all intervals are some multiple of 10 minutes.

Your task:

Given the multiplier dice I have, how much will I make when I land on the "skip 10 minutes" wedge of the roulette wheel (figuring I can calculate the 20 minute and 1 hour wedges from there)? We'll ignore any upgraded multipliers and focus solely on the flat base values of each die (incremental games, being what they are, get to obscenely large values in a hurry).

Input

  • Five values in any reasonable format. Each value represents the number of faces of each of the five multiplier dice.
    • Missing dice can either be explicitly specified (as 0) or left absent, your choice as long as it is made clear how your program accepts it.
    • You can assume input values of 0, 2, 4, 6, 8, 10, 12, 20, and 100 will be used.
    • For example an input of [6,6,4,2] would indicate that there are 2 six-sided multiplier dice, 1 four sided, and 1 two sided, while 6 6 4 2 0 would also be acceptable.

How the dice roll

  • All ten dice are rolled once a second
  • The five base dice are summed
  • The sum is multiplied by each of the five multiplier's dice's face value
  • That total is multiplied by the score bonus (if any)

The dice

  • The five basic (six sided) dice will be assumed all present.

Score bonus values:

We'll assume the following score multipliers (which apply to the face results of the base 5 dice, not the multiplier dice):

  • Pair: 2
  • Triplet: 7
  • Two-Pair: 5
  • Four of a Kind: 60
  • Straight: 20
  • Full House (pair + triplet): 30
  • Five of a Kind: 1500

This page has the odds listed out for the likelyhood of any given result, except a straight for some reason, which is 240/7776 (what's called a Large Straight, rather than a Short Straight).

Note: My original test cases were computed using an incorrect value of 2600/7776 odds for a Pair (correct value should be 3600). Given the existing answers, I am not fixing this.

Output:

Compute the expected average total over a 10 minute period (600 rolls) based on the inputs provided, assuming all dice are uniformly distributed. Output need only be accurate to the nearest whole value, but more precision is allowed.

Test cases

Two extra decimal-fractions of precision included for convenience.

[2] -> 111643.52
[4] -> 186072.53
[6] -> 260501.54
[8] -> 334930.56
[10] -> 409359.57
[12] -> 483788.58
[20] -> 781504.63
[100] -> 3758665.12
[2,2,2] -> 251197.92
[4,2,2] -> 418663.19
[6,6,6] -> 3191143.90
[2,2,2,2,2] -> 565195.31
[6,6,6,6,6] -> 39091512.83
[10,8,6,4,2] -> 24177799.48
[100,20,2,2,2] -> 133197695.3
[100,20,12,2,2] -> 577190013.02
[100,20,12,10,8] -> 6349090143.23
[100,100,100,100,100] -> 24445512498226.80

Draco18s no longer trusts SE

Posted 2019-03-01T22:45:30.633

Reputation: 3 053

1Note: Before you port the R answer note that it is not meeting requirements (for example the result for 20,20,20,20,20 is off by 1). – Jonathan Allan – 2019-03-02T19:08:04.397

2Could you check the results for 100,20,12,10,8 and 100,100,100,100,100? – Jonathan Allan – 2019-03-02T19:37:44.497

@JonathanAllan I may have miscalculated when I was writing up the post, double checking... – Draco18s no longer trusts SE – 2019-03-02T20:20:13.093

1@JonathanAllan Corrected. I also noticed a discrepancy in recalculating that I'd mis-typed the odds for a Pair as 2600 (instead of 3600), but given the existing answers I will not be fixing that. [100,100,100,100,100] was off only in the last 3 digits, [100,20,12,10,8] was horrifically wrong. Thanks for the spot-check; those two I'd calculated differently, as the values were so large, and likely made a mistake somewhere. – Draco18s no longer trusts SE – 2019-03-02T20:39:05.083

Looks like there may be more miscalculations - see this Python 3 @ TIO (tinyurl used as link too long for comment) - this limits pairs to 2600, and finds a "multiplier" of 75319.29012345678 (I believe the correct one, with all 3600 pairs, to be 76805.5555555555 = 600*995400/6^5)

– Jonathan Allan – 2019-03-02T21:21:46.090

@JonathanAllan Ah, I know what it is. And its my own stupid fault too (sigh (I graduated college and forgot how to Math)). Straights are counted again in the no match count of 720. Option (a) leave the challenge alone or option (b) update all the test cases and invalidate answers. – Draco18s no longer trusts SE – 2019-03-02T21:48:15.483

@Draco18s I believe you should be OK to invalidate answers so long as you comment and notify each answerer. – Giuseppe – 2019-03-04T15:37:55.503

Answers

6

R, 50 32 bytes

function(M)prod(M/2+.5)*74429.01

Try it online!

-17 Bytes thanks to Nick Kennedy

Ignores any missing bonus dice. 74429.01 is approximately the expected value of the "regular" dice (over a 10 minute period). Just a brute force approach.

Works pretty well, but integers get promoted to doubles once we get past the 2-billion mark (2^31-1), leading to a loss of precision.

Because the "regular" and "bonus" dice are independent, \$E[RB]=E[R]E[B]\$, easing the calculations to simply calculating \$E[B]\$ (which is again the prod of the expected values of each die) and scaling by \$E[R]\$, easily calculated from the given test cases.

Giuseppe

Posted 2019-03-01T22:45:30.633

Reputation: 21 077

How about [https://tio.run/##K/qfpmCj@z@tNC@5JDM/T8NXs6AoP0VDw1fbUFPfSFPL3MTEyFLPwPB/mkayhpGBpiYXmKEDhFC2oYGOhY6ZjgmSgIGOkYEOqhqwkCFU7D8A Try it online!]? Only 33 bytes – Nick Kennedy – 2019-03-02T07:08:17.160

1

Works with all examples too: Try it online!

– Nick Kennedy – 2019-03-02T08:14:56.703

@NickKennedy nice! Edited; found another byte to golf off as well. – Giuseppe – 2019-03-02T14:06:46.890

1The example 100,20,12,10,8 seems off by a lot? 76189081718.75 vs 6349089943. Are we supposed to be accurate to the nearest whole number? – dana – 2019-03-02T14:27:15.007

1@dana I think the question is wrong since both answers agree – Nick Kennedy – 2019-03-02T16:36:07.253

While the precision loss at 2^31 may help, this is still off by 1 for five 20 sided dice. I think (although am not 100% certain) that 74429.012 would do. – Jonathan Allan – 2019-03-02T18:04:47.500

...also I believe that an answer should theoretically give the correct answer if precision were not lost (which would, I believe, require 74429.01234615). – Jonathan Allan – 2019-03-02T18:09:11.053

The expectation is 600*964600/6/6/6/6/6 so function(M)prod((M+1)/2)*6028750/81 would work properly for 35. – Jonathan Allan – 2019-03-02T19:00:47.517

@JonathanAllan thanks, that's an excellent suggestion. – Giuseppe – 2019-03-04T15:25:00.687

...and if the post gets matched to reality that will become 600*995400/6/6/6/6/6 = 691250/9 :) – Jonathan Allan – 2019-03-04T16:07:33.830

5

Jelly, 16 bytes

‘HPד¡LT⁼þd+’÷Ø%

Try it online!

‘              Add 1 to each input element
 H             Halve; this is the expected value of each die.
  P            Product.
   ד¡LT⁼þd+’  Multiply by 319670173900294.
   ֯%         Divide by 2^32.
               319670173900294/2^32 is approximately 74429.01234615,
                 the expected value of the dice before the multiplier.

By the law of total expectation, the expected product of independent random values is the product of the expected values. The expected value of each n-sided multiplier die is simply (n+1)/2.

lirtosiast

Posted 2019-03-01T22:45:30.633

Reputation: 20 331

1‘HPד©Ȥ^ƭẈr’÷ȷ8 is spot on and saves a byte :) – Jonathan Allan – 2019-03-02T17:55:38.243

1...in fact, since the true expectation is 964600*600/6/6/6/6/6 = 6028750/81, we can do ‘HPד_qż’÷81 for 12 bytes. – Jonathan Allan – 2019-03-02T18:49:47.730

1

JavaScript, 35 bytes

Port of Giuseppe's R solution.

a=>a.map(n=>x*=++n/2,x=74429.01)&&x

Try It Online!

Shaggy

Posted 2019-03-01T22:45:30.633

Reputation: 24 623

Output need only be accurate to the nearest whole value – Jonathan Allan – 2019-03-02T18:07:06.237

1

Japt, 19 18 bytes

rÈ*°Y/2}6028750/81

-1 byte thanks to @Shaggy

Try it online!

With slightly less precision: 17 bytes

rÈ*½*(YÄ}74429.01

Quintec

Posted 2019-03-01T22:45:30.633

Reputation: 2 801

...except for the fact that it fails to satisfy requirements - "Output need only be accurate to the nearest whole value". – Jonathan Allan – 2019-03-02T18:56:29.080

@JonathanAllan Does this work, then? It seems like 74429.012 fails for smaller values. – Quintec – 2019-03-02T19:11:16.450

Looks like it; what is #Ÿ835086950#“Ñ/2pH? – Jonathan Allan – 2019-03-02T19:12:39.777

@JonathanAllan 319670173900294/(2^32) with marginal compression using charcodes- shoco doesn't work on numbers, argh. There's probably a better way to compress numbers but this is all I can think of, still new to the language – Quintec – 2019-03-02T19:13:55.480

Would multiplying by 6028750 and then dividing by 81 be shorter? (I believe that is the actual value i.e. 600*964600/6^5) – Jonathan Allan – 2019-03-02T19:17:06.243

@JonathanAllan seems to give me a different result – Quintec – 2019-03-02T19:22:58.397

@JonathanAllan https://www.wolframalpha.com/input/?i=319670173900294+%2F+(2%5E32) gives a different fraction

– Quintec – 2019-03-02T19:25:39.790

Well, it's a different number. Where does 319670173900294/(2^32) come from? Is 600*964600/6^5 not the correct expectation for the 600 rolls? – Jonathan Allan – 2019-03-02T19:26:37.343

@JonathanAllan It does not match the output given in the question. I'll think about this more. – Quintec – 2019-03-02T19:28:34.310

Hmm, it matches all but the last two to the 2dp given... (and the penultimate example looks way off, so we cannot compare that). – Jonathan Allan – 2019-03-02T19:37:29.910

...and now matches all to 1dp and all but the last to 2dp. – Jonathan Allan – 2019-03-02T20:42:12.537

@JonathanAllan Got it, thanks! – Quintec – 2019-03-02T22:46:06.383

-1 byte – Shaggy – 2019-03-02T22:56:36.930

@Shaggy Ooh, nice, thanks – Quintec – 2019-03-02T22:58:53.580

1

05AB1E, 12 bytes

>;P•₅·e•*81/

Port of @lirtosiast's Jelly answer combined with @JonathanAllan's comment (which states \$6028750/81 == 964600*600/6/6/6/6/6\$).

Try it online or verify all test cases.

Explanation:

>             # Increase each value in the (implicit) input-list by 1
              #  i.e. [100,20,12,2,2] → [101,21,13,3,3]
 ;            # Halve each value in the list
              #  i.e. [101,21,13,3,3] → [55.5,10.5,6.5,1.5,1.5]
  P           # Take the product of this list
              #  i.e. [55.5,10.5,6.5,1.5,1.5] → 7754.90625
   •₅·e•*     # Multiply it by the compressed integer 6028750
              #  i.e. 7754.90625 * 6028750 → 46752391054.6875
         81/  # Then divide it by 81
              #  i.e. 46752391054.6875 / 81 → 577190013.0208334
              # (and output implicitly as result)

See this 05AB1E answer of mine (section How to compress large integer?) to understand why •₅·e• is 6028750.

Kevin Cruijssen

Posted 2019-03-01T22:45:30.633

Reputation: 67 575