Last active
July 30, 2020 21:55
-
-
Save Mercerenies/c1d6369480f0067224e6e514d0745cef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Final script for my way-too-deep analysis of a minigame in Yoshi's Island. | |
# | |
# For context, see my blog: http://mercerenies.sdf.org/blog/roulette.php | |
apl.js <<APL | sed 'y/¯/-/' | gnuplot -e 'set xlabel "Wager"; set ylabel "E"; set terminal png; set output "yoshis_island.png"; plot "-"' | |
norm←⊢÷(+/) | |
lhsEffect←(2 2 2⍴0 1 1 0 0 0 0 1)(2 2 2⍴1 0 0 0 0 0 0 1) | |
lhsProb←norm 8 6 | |
rhsEffect←0 1 2 3 | |
rhsProb←norm 7 4 2 1 | |
wager←2 2⍴¯1 0 0 0 | |
effects←,lhsEffect∘.{⍺+.×⍵ 1}rhsEffect | |
probabilities←,lhsProb∘.×rhsProb | |
initialBet←1+⍳99 | |
totalEffects←{wager+⍵}¨ effects | |
outcomes←{bet←⍵ ⋄ {↑⍵+.×bet 1}¨ totalEffects}¨ initialBet | |
expectedValues←{⍵+.×probabilities}¨ outcomes | |
⎕←initialBet,[0.5]expectedValues | |
APL | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment