2
\$\begingroup\$

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
\$\endgroup\$
  • 1
    \$\begingroup\$ Note: 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). \$\endgroup\$ – Jonathan Allan Mar 2 at 19:08
  • 2
    \$\begingroup\$ Could you check the results for 100,20,12,10,8 and 100,100,100,100,100? \$\endgroup\$ – Jonathan Allan Mar 2 at 19:37
  • \$\begingroup\$ @JonathanAllan I may have miscalculated when I was writing up the post, double checking... \$\endgroup\$ – Draco18s Mar 2 at 20:20
  • 1
    \$\begingroup\$ @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. \$\endgroup\$ – Draco18s Mar 2 at 20:39
  • \$\begingroup\$ 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) \$\endgroup\$ – Jonathan Allan Mar 2 at 21:21
6
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ How about [tio.run/##K/qfpmCj@z@tNC@5JDM/… Try it online!]? Only 33 bytes \$\endgroup\$ – Nick Kennedy Mar 2 at 7:08
  • 1
    \$\begingroup\$ Works with all examples too: Try it online! \$\endgroup\$ – Nick Kennedy Mar 2 at 8:14
  • \$\begingroup\$ @NickKennedy nice! Edited; found another byte to golf off as well. \$\endgroup\$ – Giuseppe Mar 2 at 14:06
  • 1
    \$\begingroup\$ The 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? \$\endgroup\$ – dana Mar 2 at 14:27
  • 1
    \$\begingroup\$ @dana I think the question is wrong since both answers agree \$\endgroup\$ – Nick Kennedy Mar 2 at 16:36
5
\$\begingroup\$

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.

\$\endgroup\$
  • 1
    \$\begingroup\$ ‘HPד©Ȥ^ƭẈr’÷ȷ8 is spot on and saves a byte :) \$\endgroup\$ – Jonathan Allan Mar 2 at 17:55
  • 1
    \$\begingroup\$ ...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. \$\endgroup\$ – Jonathan Allan Mar 2 at 18:49
1
\$\begingroup\$

JavaScript, 35 bytes

Port of Giuseppe's R solution.

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

Try It Online!

\$\endgroup\$
  • \$\begingroup\$ Output need only be accurate to the nearest whole value \$\endgroup\$ – Jonathan Allan Mar 2 at 18:07
1
\$\begingroup\$

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
\$\endgroup\$
  • \$\begingroup\$ ...except for the fact that it fails to satisfy requirements - "Output need only be accurate to the nearest whole value". \$\endgroup\$ – Jonathan Allan Mar 2 at 18:56
  • \$\begingroup\$ @JonathanAllan Does this work, then? It seems like 74429.012 fails for smaller values. \$\endgroup\$ – Quintec Mar 2 at 19:11
  • \$\begingroup\$ Looks like it; what is #Ÿ835086950#“Ñ/2pH? \$\endgroup\$ – Jonathan Allan Mar 2 at 19:12
  • \$\begingroup\$ @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 \$\endgroup\$ – Quintec Mar 2 at 19:13
  • \$\begingroup\$ Would multiplying by 6028750 and then dividing by 81 be shorter? (I believe that is the actual value i.e. 600*964600/6^5) \$\endgroup\$ – Jonathan Allan Mar 2 at 19:17
1
\$\begingroup\$

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.