Skip to content

Commit 3ded6eb

Browse files
authored
Multiple assigning errors (#38)
* fix: multiple assigning errors * fix: typo
1 parent 6cb1976 commit 3ded6eb

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

notebooks/Chapter01_Tic_Tac_Toe.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### A Pluto.jl notebook ###
2-
# v0.12.18
2+
# v0.14.3
33

44
using Markdown
55
using InteractiveUtils
@@ -147,7 +147,7 @@ The above `run` function defined in `ReinforcementLearning.jl` is quite straight
147147
148148
You are encouraged to read the [source code](https://github.com/JuliaReinforcementLearning/ReinforcementLearningCore.jl/blob/master/src/core/run.jl) of this function. It's pretty simple (less than 30 lines) and easy to understand. I'll wait you here until you are finished.
149149
150-
If you have finished reading it, you'll notice that one important argument is missing in the above function call, the `hook`. Now we'll add the forth argument to collect the reward of each player in every episode.
150+
If you have finished reading it, you'll notice that one important argument is missing in the above function call, the `hook`. Now we'll add the fourth argument to collect the reward of each player in every episode.
151151
"""
152152

153153
# ╔═╡ 6f58815c-4852-11eb-18e8-e55b276ba228

notebooks/Chapter02_Ten_Armed_Testbed.jl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### A Pluto.jl notebook ###
2-
# v0.12.18
2+
# v0.14.3
33

44
using Markdown
55
using InteractiveUtils
@@ -61,14 +61,15 @@ Now we create a testbed to calulate the average reward and perfect action percen
6161
"""
6262
A customized hook to record whether the action to take is the best action or not.
6363
"""
64-
Base.@kwdef struct CollectBestActions <: AbstractHook
65-
best_action::Int
66-
isbest::Vector{Bool} = []
67-
end
64+
begin
65+
Base.@kwdef struct CollectBestActions <: AbstractHook
66+
best_action::Int
67+
isbest::Vector{Bool} = []
68+
end
6869

69-
# ╔═╡ d0186892-4aad-11eb-080c-d985066abbc6
70-
function (h::CollectBestActions)(::PreActStage, agent, env, action)
71-
push!(h.isbest, h.best_action==action)
70+
function (h::CollectBestActions)(::PreActStage, agent, env, action)
71+
push!(h.isbest, h.best_action==action)
72+
end
7273
end
7374

7475
# ╔═╡ 1ff8d726-4aad-11eb-0d88-c7f6080c4072
@@ -208,16 +209,17 @@ Note that there's a keyword argument named `baseline` in the `GradientBanditLear
208209
"""
209210

210211
# ╔═╡ b291cb0c-4b1f-11eb-3ee5-cfcdfdcae00b
211-
Base.@kwdef mutable struct SampleAvg
212-
t::Int = 0
213-
avg::Float64 = 0.0
214-
end
212+
begin
213+
Base.@kwdef mutable struct SampleAvg
214+
t::Int = 0
215+
avg::Float64 = 0.0
216+
end
215217

216-
# ╔═╡ d61f3168-4b1f-11eb-2a20-2f3d1bb69cd9
217-
function (s::SampleAvg)(x)
218-
s.t += 1
219-
s.avg += (x - s.avg) / s.t
220-
s.avg
218+
function (s::SampleAvg)(x)
219+
s.t += 1
220+
s.avg += (x - s.avg) / s.t
221+
s.avg
222+
end
221223
end
222224

223225
# ╔═╡ e0e72a60-4b1f-11eb-1001-89777fd3d0f7
@@ -263,7 +265,6 @@ end
263265
# ╟─69bc9e66-4a5c-11eb-0288-1930cdb31d9d
264266
# ╟─c0ca4172-4aac-11eb-255d-8b0005441fb0
265267
# ╠═4bf0f782-4aad-11eb-291c-afa853f150a3
266-
# ╠═d0186892-4aad-11eb-080c-d985066abbc6
267268
# ╟─1ff8d726-4aad-11eb-0d88-c7f6080c4072
268269
# ╠═1fbc2952-4b1b-11eb-3b65-75c1058a9537
269270
# ╠═db64341a-4b1b-11eb-3f7b-f11b26f442f4
@@ -275,7 +276,6 @@ end
275276
# ╠═6d93c3d0-4b1e-11eb-2b41-af6689ba72f4
276277
# ╟─04e8320c-4b1f-11eb-3340-47f7392a8282
277278
# ╠═b291cb0c-4b1f-11eb-3ee5-cfcdfdcae00b
278-
# ╠═d61f3168-4b1f-11eb-2a20-2f3d1bb69cd9
279279
# ╠═e0e72a60-4b1f-11eb-1001-89777fd3d0f7
280280
# ╠═42525d24-4b20-11eb-099c-b10c90af166e
281281
# ╠═aad675d2-4b80-11eb-3d78-a1ef731d7d8b

0 commit comments

Comments
 (0)