Skip to content

Instantly share code, notes, and snippets.

@dietercastel
Last active September 16, 2019 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dietercastel/e0a7eefa3b5bdeef22948075dcd04da9 to your computer and use it in GitHub Desktop.
Save dietercastel/e0a7eefa3b5bdeef22948075dcd04da9 to your computer and use it in GitHub Desktop.
RPS julia plotting
#Plot of calculating the win chance for g-player Rock, Paper, Scissors.
# A winning RPS game contains exactly two options.
#Total amount of options BigInt function
tot(g) = 3^BigInt(g)
#Winning options BigInt function
win(g) = 3*2*(2^(BigInt(g)-1)-1)
#Calculate the win chance
winchance(g) = win(g)//tot(g)
xto(n) = range(3,stop=n)
yto(n) = map(x-> winchance(x), xto(n))
n=30
x = xto(n)
y = yto(n)
using Plots
using PlotThemes
theme(:dark)
label = "W(g)/T(g)"
# Using LaTeX with the default gr backend was not readable so disabled for now.
#using LaTeXStrings #Note that LaTeXStrings is Case-Sensitive
#label = L"\frac{W(g)}{T(g)}"
plot(x,y,label=label,xticks = x)
xaxis!("Groep van g (>2)")
yaxis!("Kans op winnaars")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment