Currently, I am running very simple loops using a custom function that generate an array. I am then taking the last value of the array and pushing it into another. Fortunately the function returns the right values but all the print statements are broken… only returning blank lines until the final result.
Furthermore, the welcome screen doesn’t seem to render either.
So, for example, I am running a calculation and then asking it to print using a print() statement - what I get is 100 blank lines and then the last result. Any thoughts?
function marty(Wager, GamesPlayed; GameWinProb = 0.5, CashInHand = Wager)
CurrentWager = Wager
Balance = CashInHand
BalResults = []
for i = 1:GamesPlayed
win_loose_sim = rand(Bernoulli(GameWinProb))
if win_loose_sim == true
Balance = Balance + CurrentWager
CurrentWager = Wager
elseif win_loose_sim == false
Balance = Balance - CurrentWager
CurrentWager = Wager * 2
end
push!(BalResults, Balance)
end
println()
#println("Gain/Loss after $GamesPlayed games: ", Balance - CashInHand,'$')
return BalResults
end
Here is the offending function
function x_hand_dist(trials, games)
finalresult = []
for i = 1:trials
trial_result = last(marty(5, games, GameWinProb = 0.185, CashInHand = 400))
#print(trial_result)
push!(finalresult, trial_result)
end
return finalresult
end
Same Issue but worse…
function resim()
trials = 1000
for games = 10:5:1000
sim = mean(x_hand_dist(trials, games))
#print("Total Games:", games," ","Mean Balance:", sim)
if sim < 0
println("Total Games:", games," ","Mean Balance:", mean(x_hand_dist(trials, games)))
break
else
println("Total Games:", games," ","Mean Balance:", sim)
end
end
end