# MiekMath result plots!

This notebook shows you how you did with MiekMath. To run:

Select Cell > Run all

``````

In [ ]:

using DataFrames
using Plots
using MathProblems
using MathGame
using Report
using Tools
games = get_games()
#games = joinpath("results", "games_juliabox") |> load_games #Testing
games_count = length(games)
if games_count > 0
println("Games played so far: \$games_count")
else
error("No previous games. First play some games before running this notebook")
end

``````
``````

In [ ]:

# Select player
players = sort(unique([x.player for x in games]))
isel = if length(players) > 1
println("Select player for report:")
for (i, p) in enumerate(players)
println("\$i) \$p")
end
input_number_between("Player? ", 1, length(players))
else
1
end
player = players[isel]
println(@sprintf("Reporting for player %s", player))

``````
``````

In [ ]:

# Statistics per game kind for selected player
games_player = [x for x in games if x.player == player]
gen_games = Dict{ProblemGenerator,Array{Game}}()
for g in games_player
push!(gen_games[g.generator],g)
else
gen_games[g.generator] = [g]
end
end

``````
``````

In [ ]:

println("Games per generator:")
println(@sprintf("%22s : score  [count]", "generator"))
for (gen, games_c) in gen_games
games_count_c = length(games_c)
median_score = median([score(g.result) for g in games_c])
println(@sprintf("%22s :  %4.1f  [ %3i ]",
string(gen),median_score, games_count_c))
end

``````
``````

In [ ]:

# Score vs time
pyplot()
df_games_plot = nothing
for (gen, games_c) in gen_games
df_games_plot = truncated_scores(games_c)
n_report_min = 3
if nrow(df_games_plot) < n_report_min
println("\$gen : Fewer than \$n_report_min games.")
continue
end
f = df_games_plot
annotation = [(x[1], x[2]+0.5, x[3]) for x in zip(f[:time_number],f[:score],f[:ann_text])]
plt = plot(df_games_plot,:time_number, :score, seriestype=:bar, linewidth=2, bar_width=1,
color=df_games_plot[:color], legend=false, annotation=annotation, show=false)
ann_game_count = [(x[1], 1, string(x[3])) for x in zip(f[:time_number],f[:score],f[:game_count])]
annotate!(ann_game_count)
ti = "\$player : \$gen"
score_max = maximum(df_games_plot[:score])
ymax = 1.1*(score_max+0.5) # make room for text
plot!(xlabel="time", ylabel="Score", title=ti, ylims=(0,ymax))
plot!(xticks=(df_games_plot[:time_number],df_games_plot[:time_str]))
display(plt)
end
nothing

``````
``````

In [ ]:

# Most difficult problems
top_worst_count = 10
problem_count_min = 10 #100
print_mode = "table" # "sheet", "table"
println("Top \$top_worst_count most difficult problems")
for (gen,games_c) in gen_games
println("\n\$gen"); flush(STDOUT)
res = results_dataframe(games_c)
if nrow(res) < problem_count_min
println("Fewer than \$problem_count_min problems solved")
continue
end
resagg = mean_per_problem(res)
top_worst_count = min(top_worst_count, nrow(resagg))
if print_mode=="sheet"
for p in resagg[1:top_worst_count,:problem]
println(p)
end
else