Talk:Jump Attack
This is the talk page for discussing improvements to the Jump Attack article. It is not a forum for general discussion of the article's subject. Comments such as "Mario is my favorite character" are not allowed and will be removed on sight. Please use the Mario Boards or our Discord server to talk about Jump Attack.
If you do have a question or comment about the article, please remember to sign your edit with ~~~~
.
Mathematical expectation[edit]
I'm the one who wrote the "Mathematical expectation" section. I'm not really good at math so I want you to check the program I used to calculate the data. It's written in Python 2:
one=1 five=2 x5=3 bowser=4
import itertools
l=[one,one,one,one,five,five,five,x5,x5,bowser,bowser] p=itertools.permutations(l,5) # change to 7, 9
def coins(l): l=list(l) s=0 while len(l): a=l[0] del l[0] if a==one: s+=1 elif a==five: s+=5 elif a==x5: s*=5 elif a==bowser: s=0 break else: raise NameError('wtf?') return s
ans=[coins(l) for l in p] s=sum(ans)
print s/len(ans) print s print len(ans)
The result is:
11 661200 55440
11 18385920 1663200
3 71245440 19958400
Since the 9-Block Option has a bonus, the real number of coins earned is 6.
I daren't calculate the variance because my machine is slow. Another gossip-loving Toad (talk) 22:32, 20 October 2014 (EDT)
- Hi, I was curious about the expected reward as well, and when I saw the wiki page didn't list them, I ended up writing uncannily similar code as yours (I only checked the "talk" page after writing it), and found the same approximate values.
- I also saw that you'd added this to the page at first, but later removed them again since you didn't trust your numbers...I suppose my independently written code arriving at the same numbers would fully corroborate it, assuming the game does not secretly alter the game rules in the player's favor or something.
- With that caveat, I'm adding it back into the article.
- (Here's my code, python 3)
import numpy as np bowser = 0 one = 1 five = 5 xfive = 25 blocks = [one, one, one, one, five, five, five, xfive, xfive, bowser, bowser] def evaluate(blocks): total = 0 for block in blocks: if block == one or block == five: total += block elif block == xfive: total *= 5 else: return 0 return total count = 100_000 # Number of simulated games to run, increase for more accurate average mode = 5 # Chance to 7 or 9 total = sum( evaluate(np.random.permutation(blocks)[:mode]) for _ in range(count) ) print(total/count)
- Update: I realised you don't even need to simulate anything, it's actually faster to just compute every possible winning game and use that to get the exact expected values. I have amended the table.
- Python 3 code:
import itertools import math one = 1; five = 5; xfive = 25 winningBlocks = [one, one, one, one, five, five, five, xfive, xfive] def evaluate(blocks): total = 0 for block in blocks: if block == one or block == five: total += block elif block == xfive: total *= 5 return total print() for mode in [5, 7, 9]: print('====== %d-Block Option =====' % mode) count = math.factorial(11)//math.factorial(11-mode) print('# of combos:', count) winCount = math.factorial(9)//math.factorial(9-mode) print('# of non-losing combos:', winCount) # Only evaluate the winning combos-- far less than the actual total number of combinations. total = sum(evaluate(perm) for perm in itertools.permutations(winningBlocks, mode)) print() print('E[x | winning] =', total/winCount) print('E[x] =', total/count) if mode == 9: print('(9-block bonus multiplier: Multiply by 2 to get the in-game reward)') print()