Skip to content

Commit df3df64

Browse files
authored
Merge pull request #1 from toolpath/alambe/debugging_helpers
Debugging helpers
2 parents 7b5cf05 + bd3ec60 commit df3df64

5 files changed

Lines changed: 20 additions & 5 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ sessions
1414
archive
1515

1616
TODO.md
17+
18+
.vscode

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "AlphaZero"
22
uuid = "8ed9eb0b-7496-408d-8c8b-2119aeea02cd"
3-
authors = ["Jonathan Laurent <jonathan.laurent@cs.cmu.edu>"]
4-
version = "0.5.4"
3+
authors = ["Jonathan Laurent <jonathan.laurent@cs.cmu.edu>, forked by Andrew Lambe <andrew.b.lambe@gmail.com"]
4+
version = "0.5.5"
55

66
[deps]
77
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"

src/mcts.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,12 @@ function run_simulation!(env::Env, game; η, root=true)
208208
else
209209
ϵ = root ? env.noise_ϵ : 0.
210210
scores = uct_scores(info, env.cpuct, ϵ, η)
211+
if length(scores) != length(actions)
212+
@warn "Scores array has length $(length(scores)) but Actions array has length $(length(actions))"
213+
@show scores
214+
@show state
215+
@show actions
216+
end
211217
action_id = argmax(scores)
212218
action = actions[action_id]
213219
wp = GI.white_playing(game)

src/play.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,11 @@ function play_game(gspec, player; flip_probability=0.)
308308
actions, π_target = think(player, game)
309309
τ = player_temperature(player, game, length(trace))
310310
π_sample = apply_temperature(π_target, τ)
311+
if length(actions) != length(π_target)
312+
@warn "Actions array has length $(length(actions)) but Policy array has length $(length(π_target))"
313+
@show actions
314+
@show π_target
315+
end
311316
a = actions[Util.rand_categorical(π_sample)]
312317
GI.play!(game, a)
313318
push!(trace, π_target, GI.white_reward(game), GI.current_state(game))

src/ui/plots.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,15 @@ function performances_plot(rep::Report.Iteration)
5959
push!(global_content, rep.perfs_learning.time)
6060
glob = Plots.pie(global_labels, global_content,
6161
title="Global",
62-
legend=:right)
62+
legend=:bottomright)
6363
# Self-play details
6464
self_play =
6565
let gcratio = rep.perfs_self_play.gc_time / rep.perfs_self_play.time
6666
Plots.pie(
6767
["MCTS and Inference", "GC"],
6868
[1 - gcratio, gcratio],
69-
title="Self Play")
69+
title="Self Play",
70+
legend=:topright)
7071
end
7172
# Learning details
7273
learning = Plots.pie(
@@ -75,7 +76,8 @@ function performances_plot(rep::Report.Iteration)
7576
rep.learning.time_loss,
7677
rep.learning.time_train,
7778
rep.learning.time_eval],
78-
title="Learning")
79+
title="Learning",
80+
legend=:bottomright)
7981
return Plots.plot(glob, self_play, learning)
8082
end
8183

0 commit comments

Comments
 (0)