Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Random
- struct Card
- embers::Number
- quickdraw::Number
- stumbles::Number
- skip::Number
- isColdSnap::Bool
- function Card(isColdSnap::Bool)
- new(0, 0, 0, 0, isColdSnap)
- end
- function Card(embers; quickdraw = 0, stumbles = 0, skip = 0)
- new(embers, quickdraw, stumbles, skip, false)
- end
- end
- STU = Card(0)
- SNE = Card(0)
- STA = Card(0)
- TRH = Card(0)
- EMS = Card(2)
- EVA = Card(0)
- TRL = Card(0)
- FRF = Card(4)
- LAS = Card(0)
- SEW = Card(0)
- BST = Card(0)
- REC = Card(10)
- SPT = Card(0)
- NIL = Card(0)
- SAG = Card(0)
- QUI = Card(0, quickdraw = 1)
- EES = Card(0, skip = 1)
- SWA = Card(10, stumbles = 2)
- COS = Card(true)
- ethos_deck = [
- repeat([SNE], 4)...,
- repeat([STA], 4)...,
- repeat([TRH], 5)...,
- repeat([EMS], 5)...,
- repeat([EVA], 3)...,
- TRL,
- repeat([FRF], 2)...,
- repeat([LAS], 3)...,
- SEW,
- repeat([BST], 2)...,
- REC,
- repeat([SPT], 2)...,
- NIL,
- SAG,
- QUI,
- repeat([EES], 2)...,
- SWA,
- COS
- ]
- function simulate_run(starting_deck::Vector{Card})
- deck = deepcopy(starting_deck)
- total_embers = 0
- double_embers = 0
- quickdraw = 0
- stumble_timer = 3
- skip = 0
- while length(deck) > 0
- if skip > 0
- skip -= 1
- continue
- end
- card = popat!(deck, rand(1:length(deck)))
- total_embers += double_embers > 0 ? card.embers * 2 : card.embers
- quickdraw += card.quickdraw
- push!(deck, repeat([STU], card.stumbles)...)
- skip = card.skip
- double_embers > 0 && (double_embers -= 1)
- card.isColdSnap && (double_embers += 3)
- if quickdraw > 0
- if stumble_timer == 0
- push!(deck, STU)
- stumble_timer = 3
- else
- stumble_timer -= 1
- end
- end
- quickdraw > 0 && (quickdraw -= 1)
- end
- total_embers
- end
- data = [simulate_run(ethos_deck) for _ in 1:10000]
- using Statistics
- exp_data = map(x -> x - minimum(data), data)
- println("The average value of COS is $(mean(exp_data)) ± $(std(exp_data)), making the overall deck ember average $(mean(data)). The 50th percentile (median) is $(median(exp_data))")
- using CairoMakie
- f, _, _ = hist(data; normalization = :pdf, color = :values, bar_labels = :x,
- label_formatter = x -> Integer(floor(x)), label_size = 15,
- strokewidth = 0.5, strokecolor = (:black, 0.5), colormap = :blues,
- axis = (; title = "Frost Embers of Etho's Deck incl. Cold Snap", titlesize = 20,
- subtitle = "Note: Without COS, the frost embers of the deck are 38 ± 0 (no variation)",
- subtitlevisible = true,
- xlabel = "Total Resulting Frost Embers", ylabel = "Probability Density",
- xgridvisible = false, topspinevisible = false, rightspinevisible = false,
- bottomspinevisible = false, xticks = [0], yticks = LinearTicks(8)))
- save("COS_histogram.png", f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement