Skip to content

Instantly share code, notes, and snippets.

@Mercerenies
Last active July 30, 2020 21:55
Show Gist options
  • Save Mercerenies/c1d6369480f0067224e6e514d0745cef to your computer and use it in GitHub Desktop.
Save Mercerenies/c1d6369480f0067224e6e514d0745cef to your computer and use it in GitHub Desktop.
#!/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