diff --git a/Project.toml b/Project.toml index 357e764f..7c030e6e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "AlphaZero" uuid = "8ed9eb0b-7496-408d-8c8b-2119aeea02cd" authors = ["Jonathan Laurent "] -version = "0.5.4" +version = "0.5.5" [deps] ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63" @@ -15,7 +15,7 @@ Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" ExprTools = "e2ba6199-217a-4e67-a87a-7c52f15ade04" Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c" -Formatting = "59287772-0a20-5a39-b81b-1366585eb4c0" +Format = "1fa38f19-a742-5d3f-a2b9-30dd87b9d5f8" JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" Knet = "1902f260-5fb4-5aff-8c31-6271790ab950" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" @@ -42,7 +42,7 @@ Distributions = "0.24.18, 0.25" Documenter = "0.26.3, 0.27" ExprTools = "= 0.1.3, 0.1" Flux = "0.12.2, 0.13" -Formatting = "0.4.2" +Format = "1.3" JSON3 = "1.8.1" Knet = "1.4.8" LoggingExtras = "0.4.7, 1" diff --git a/games/connect-four/scripts/pons_benchmark.jl b/games/connect-four/scripts/pons_benchmark.jl index 6a3d5a44..f91b0829 100644 --- a/games/connect-four/scripts/pons_benchmark.jl +++ b/games/connect-four/scripts/pons_benchmark.jl @@ -84,7 +84,7 @@ const BENCHMARKS = load_benchmarks(BENCHMARKS_DIR) using AlphaZero using .Examples.ConnectFour: GameSpec, Solver, Training using ProgressMeter -using Formatting +using Format using Statistics: mean const gspec = GameSpec() @@ -139,7 +139,7 @@ function test_player(make_player, oracle) err = test_player_on(make_player, oracle, bench, p) push!(errs, err) err_str = - println("($(bench.stage), $(bench.difficulty)): $(fmt(".2f", 100 * err))%") + println("($(bench.stage), $(bench.difficulty)): $(pyfmt(".2f", 100 * err))%") end return errs end diff --git a/src/AlphaZero.jl b/src/AlphaZero.jl index 19462b29..34991917 100644 --- a/src/AlphaZero.jl +++ b/src/AlphaZero.jl @@ -6,7 +6,7 @@ module AlphaZero import Distributed - using Formatting + using Format using Base: @kwdef using DataStructures: CircularBuffer using Distributions: Categorical, Dirichlet @@ -187,4 +187,4 @@ module AlphaZero end -end \ No newline at end of file +end diff --git a/src/trace.jl b/src/trace.jl index e65ec476..cf6148dc 100644 --- a/src/trace.jl +++ b/src/trace.jl @@ -53,7 +53,7 @@ function debug_trace(gspec::AbstractGameSpec, t::Trace) game = GI.init(gspec, t.states[i]) GI.render(game) for (a, p) in zip(GI.available_actions(game), t.policies[i]) - print("$(GI.action_string(gspec, a)): $(fmt(".3f", p)) ") + print("$(GI.action_string(gspec, a)): $(pyfmt(".3f", p)) ") end println("") println("Obtained reward of: $(t.rewards[i]).") diff --git a/src/ui/explorer.jl b/src/ui/explorer.jl index 72be3bee..31f2add8 100644 --- a/src/ui/explorer.jl +++ b/src/ui/explorer.jl @@ -120,8 +120,8 @@ end ##### function print_state_statistics(gspec, stats::StateStats) - prob = Log.ColType(nothing, x -> fmt(".1f", 100 * x) * "%") - val = Log.ColType(nothing, x -> fmt("+.2f", x)) + prob = Log.ColType(nothing, x -> pyfmt(".1f", 100 * x) * "%") + val = Log.ColType(nothing, x -> pyfmt("+.2f", x)) bigint = Log.ColType(nothing, n -> format(ceil(Int, n), commas=true)) alabel = Log.ColType(nothing, identity) btable = Log.Table([ @@ -305,4 +305,4 @@ end function explore(player::AbstractPlayer, gspec::AbstractGameSpec; args...) return explore(player, GI.init(gspec), args...) -end \ No newline at end of file +end diff --git a/src/ui/log.jl b/src/ui/log.jl index 45d9736f..c250a03a 100644 --- a/src/ui/log.jl +++ b/src/ui/log.jl @@ -8,7 +8,7 @@ module Log export Logger using Crayons -using Formatting: fmt +using Format: pyfmt import ProgressMeter const INDENT_STEP = 2 @@ -130,7 +130,7 @@ end set_columns(tab, cols) = Table(cols, tab.header_style, tab.comments_style) -fixed_width(str, width) = fmt(">$(width)s", first(str, width)) +fixed_width(str, width) = pyfmt(">$(width)s", first(str, width)) intersperse(sep, words) = reduce((x, y) -> x * sep * y, words) diff --git a/src/ui/session.jl b/src/ui/session.jl index e7fc757e..cfd56629 100644 --- a/src/ui/session.jl +++ b/src/ui/session.jl @@ -348,7 +348,7 @@ AlphaZero.AlphaZeroPlayer(s::Session; args...) = AlphaZero.AlphaZeroPlayer(s.env ##### Utilities for printing reports ##### -const NUM_COL = Log.ColType(7, x -> fmt(".4f", x)) +const NUM_COL = Log.ColType(7, x -> pyfmt(".4f", x)) const BIGINT_COL = Log.ColType(10, n -> format(ceil(Int, n), commas=true)) const LEARNING_STATUS_TABLE = Log.Table([ @@ -401,7 +401,7 @@ end function print_report(logger::Logger, report::Report.SelfPlay) sspeed = format(round(Int, report.samples_gen_speed), commas=true) Log.print(logger, "Generating $(sspeed) samples per second on average") - avgdepth = fmt(".1f", report.average_exploration_depth) + avgdepth = pyfmt(".1f", report.average_exploration_depth) Log.print(logger, "Average exploration depth: $avgdepth") memf = format(report.mcts_memory_footprint, autoscale=:metric, precision=2) Log.print(logger, "MCTS memory footprint per worker: $(memf)B") @@ -433,7 +433,7 @@ function print_report( nn_replaced=false, ternary_outcome=false) - r = fmt("+.2f", report.avgr) + r = pyfmt("+.2f", report.avgr) if ternary_outcome n = length(report.rewards) stats = Benchmark.TernaryOutcomeStatistics(report) @@ -449,7 +449,7 @@ function print_report( push!(details, "network replaced") end details = isempty(details) ? "" : " (" * join(details, ", ") * ")" - red = fmt(".1f", 100 * report.redundancy) + red = pyfmt(".1f", 100 * report.redundancy) msg = "Average reward: $r$details, redundancy: $red%" Log.print(logger, msg) end diff --git a/src/ui/ui.jl b/src/ui/ui.jl index 73d2d4cb..e2eb1441 100644 --- a/src/ui/ui.jl +++ b/src/ui/ui.jl @@ -16,7 +16,7 @@ module UserInterface import JSON3 using Base: @kwdef using Statistics: mean - using Formatting: format, fmt + using Format: format, pyfmt using Crayons: @crayon_str using Colors: @colorant_str using ProgressMeter @@ -30,4 +30,4 @@ module UserInterface include("json.jl") include("session.jl") -end \ No newline at end of file +end