Skip to content

Commit ae43678

Browse files
committed
2 parents 5580e3e + e6b64d0 commit ae43678

File tree

14 files changed

+211
-128
lines changed

14 files changed

+211
-128
lines changed

Manifest.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
2121

2222
[[Compat]]
2323
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
24-
git-tree-sha1 = "4866e381721b30fac8dda4c8cb1d9db45c8d2994"
24+
git-tree-sha1 = "31d0151f5716b655421d9d75b7fa74cc4e744df2"
2525
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
26-
version = "3.37.0"
26+
version = "3.39.0"
2727

2828
[[DataAPI]]
29-
git-tree-sha1 = "bec2532f8adb82005476c141ec23e921fc20971b"
29+
git-tree-sha1 = "cc70b17275652eb47bc9e5f81635981f13cea5c8"
3030
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
31-
version = "1.8.0"
31+
version = "1.9.0"
3232

3333
[[DataStructures]]
3434
deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
@@ -56,9 +56,9 @@ version = "0.8.5"
5656

5757
[[Documenter]]
5858
deps = ["ANSIColoredPrinters", "Base64", "Dates", "DocStringExtensions", "IOCapture", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"]
59-
git-tree-sha1 = "fe0bc46b27cd3413df55859152fd70e50744025f"
59+
git-tree-sha1 = "8b43e37cfb4f4edc2b6180409acc0cebce7fede8"
6060
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
61-
version = "0.27.6"
61+
version = "0.27.7"
6262

6363
[[DocumenterTools]]
6464
deps = ["AbstractTrees", "Base64", "DocStringExtensions", "Documenter", "FileWatching", "Gumbo", "LibGit2", "Sass"]
@@ -72,7 +72,7 @@ uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
7272

7373
[[EcosystemCore]]
7474
deps = ["StatsBase"]
75-
git-tree-sha1 = "6673d8009ca36aedd7a37b6f6cfbde0e179b2a59"
75+
git-tree-sha1 = "9b3a25d787bcd5974160b1c7064096b8fb37a88c"
7676
repo-rev = "main"
7777
repo-url = "https://github.com/JuliaTeachingCTU/EcosystemCore.jl.git"
7878
uuid = "3e0d8730-8ea0-4ee2-afe6-c85384c618a2"
@@ -171,9 +171,9 @@ version = "1.4.1"
171171

172172
[[Parsers]]
173173
deps = ["Dates"]
174-
git-tree-sha1 = "438d35d2d95ae2c5e8780b330592b6de8494e779"
174+
git-tree-sha1 = "a8709b968a1ea6abc2dc1967cb1db6ac9a00dfb6"
175175
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
176-
version = "2.0.3"
176+
version = "2.0.5"
177177

178178
[[Pkg]]
179179
deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]

Project.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
1111

1212
[compat]
1313
julia = "1.6"
14+
15+
[extras]
16+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
17+
18+
[targets]
19+
test = ["Test"]

docs/Manifest.toml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ version = "1.16.1+0"
5757

5858
[[ChainRulesCore]]
5959
deps = ["Compat", "LinearAlgebra", "SparseArrays"]
60-
git-tree-sha1 = "bd4afa1fdeec0c8b89dad3c6e92bc6e3b0fec9ce"
60+
git-tree-sha1 = "a325370b9dd0e6bf5656a6f1a7ae80755f8ccc46"
6161
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
62-
version = "1.6.0"
62+
version = "1.7.2"
6363

6464
[[ColorSchemes]]
6565
deps = ["ColorTypes", "Colors", "FixedPointNumbers", "Random"]
66-
git-tree-sha1 = "9995eb3977fbf67b86d0a0a0508e83017ded03f2"
66+
git-tree-sha1 = "a851fec56cb73cfdf43762999ec72eff5b86882a"
6767
uuid = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
68-
version = "3.14.0"
68+
version = "3.15.0"
6969

7070
[[ColorTypes]]
7171
deps = ["FixedPointNumbers", "Random"]
@@ -81,9 +81,9 @@ version = "0.12.8"
8181

8282
[[Compat]]
8383
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
84-
git-tree-sha1 = "1a90210acd935f222ea19657f143004d2c2a1117"
84+
git-tree-sha1 = "31d0151f5716b655421d9d75b7fa74cc4e744df2"
8585
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
86-
version = "3.38.0"
86+
version = "3.39.0"
8787

8888
[[CompilerSupportLibraries_jll]]
8989
deps = ["Artifacts", "Libdl"]
@@ -131,9 +131,9 @@ version = "0.8.5"
131131

132132
[[Documenter]]
133133
deps = ["ANSIColoredPrinters", "Base64", "Dates", "DocStringExtensions", "IOCapture", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"]
134-
git-tree-sha1 = "fe0bc46b27cd3413df55859152fd70e50744025f"
134+
git-tree-sha1 = "8b43e37cfb4f4edc2b6180409acc0cebce7fede8"
135135
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
136-
version = "0.27.6"
136+
version = "0.27.7"
137137

138138
[[DocumenterTools]]
139139
deps = ["AbstractTrees", "Base64", "DocStringExtensions", "Documenter", "FileWatching", "Gumbo", "LibGit2", "Sass"]
@@ -153,7 +153,7 @@ version = "2.2.3+0"
153153

154154
[[EcosystemCore]]
155155
deps = ["StatsBase"]
156-
git-tree-sha1 = "43c67ffceba411b843d9d7237d9210e7b075d934"
156+
git-tree-sha1 = "9b3a25d787bcd5974160b1c7064096b8fb37a88c"
157157
repo-rev = "main"
158158
repo-url = "https://github.com/JuliaTeachingCTU/EcosystemCore.jl.git"
159159
uuid = "3e0d8730-8ea0-4ee2-afe6-c85384c618a2"
@@ -283,9 +283,9 @@ version = "0.10.1+1"
283283

284284
[[HTTP]]
285285
deps = ["Base64", "Dates", "IniFile", "Logging", "MbedTLS", "NetworkOptions", "Sockets", "URIs"]
286-
git-tree-sha1 = "60ed5f1643927479f845b0135bb369b031b541fa"
286+
git-tree-sha1 = "14eece7a3308b4d8be910e265c724a6ba51a9798"
287287
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
288-
version = "0.9.14"
288+
version = "0.9.16"
289289

290290
[[HarfBuzz_jll]]
291291
deps = ["Artifacts", "Cairo_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "Graphite2_jll", "JLLWrappers", "Libdl", "Libffi_jll", "Pkg"]
@@ -539,9 +539,9 @@ version = "8.44.0+0"
539539

540540
[[Parsers]]
541541
deps = ["Dates"]
542-
git-tree-sha1 = "9d8c00ef7a8d110787ff6f170579846f776133a9"
542+
git-tree-sha1 = "a8709b968a1ea6abc2dc1967cb1db6ac9a00dfb6"
543543
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
544-
version = "2.0.4"
544+
version = "2.0.5"
545545

546546
[[Pixman_jll]]
547547
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
@@ -561,15 +561,15 @@ version = "2.0.1"
561561

562562
[[PlotUtils]]
563563
deps = ["ColorSchemes", "Colors", "Dates", "Printf", "Random", "Reexport", "Statistics"]
564-
git-tree-sha1 = "2537ed3c0ed5e03896927187f5f2ee6a4ab342db"
564+
git-tree-sha1 = "b084324b4af5a438cd63619fd006614b3b20b87b"
565565
uuid = "995b91a9-d308-5afd-9ec6-746e21dbc043"
566-
version = "1.0.14"
566+
version = "1.0.15"
567567

568568
[[Plots]]
569569
deps = ["Base64", "Contour", "Dates", "Downloads", "FFMPEG", "FixedPointNumbers", "GR", "GeometryBasics", "JSON", "Latexify", "LinearAlgebra", "Measures", "NaNMath", "PlotThemes", "PlotUtils", "Printf", "REPL", "Random", "RecipesBase", "RecipesPipeline", "Reexport", "Requires", "Scratch", "Showoff", "SparseArrays", "Statistics", "StatsBase", "UUIDs"]
570-
git-tree-sha1 = "457b13497a3ea4deb33d273a6a5ea15c25c0ebd9"
570+
git-tree-sha1 = "6841db754bd01a91d281370d9a0f8787e220ae08"
571571
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
572-
version = "1.22.2"
572+
version = "1.22.4"
573573

574574
[[Preferences]]
575575
deps = ["TOML"]
@@ -682,9 +682,9 @@ uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
682682

683683
[[StaticArrays]]
684684
deps = ["LinearAlgebra", "Random", "Statistics"]
685-
git-tree-sha1 = "3240808c6d463ac46f1c1cd7638375cd22abbccb"
685+
git-tree-sha1 = "3c76dde64d03699e074ac02eb2e8ba8254d428da"
686686
uuid = "90137ffa-7385-5640-81b9-e52037218182"
687-
version = "1.2.12"
687+
version = "1.2.13"
688688

689689
[[Statistics]]
690690
deps = ["LinearAlgebra", "SparseArrays"]
@@ -719,9 +719,9 @@ version = "1.0.1"
719719

720720
[[Tables]]
721721
deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "TableTraits", "Test"]
722-
git-tree-sha1 = "1162ce4a6c4b7e31e0e6b14486a6986951c73be9"
722+
git-tree-sha1 = "fed34d0e71b91734bf0a7e10eb1bb05296ddbcd0"
723723
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
724-
version = "1.5.2"
724+
version = "1.6.0"
725725

726726
[[Tar]]
727727
deps = ["ArgTools", "SHA"]

docs/make.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ lecture_03 = [
6060
lecture_04 = [
6161
"Lecture" => "./lecture_04/lecture.md"
6262
"Lab" => "./lecture_04/lab.md"
63+
"Homework" => "./lecture_04/hw.md"
6364
]
6465

6566
lecture_05 = [
@@ -109,7 +110,7 @@ makedocs(;
109110
"1: Introduction" => lecture_01,
110111
"2: The power of Type System & multiple dispatch" => lecture_02,
111112
"3: Design patterns" => lecture_03,
112-
"4: Packages development, environments, etc..." => lecture_04,
113+
"4: Packages development, Unit Tests & CI" => lecture_04,
113114
"5: Benchmarking, profiling, and performance gotchas" => lecture_05,
114115
"6: Language introspection" => lecture_06,
115116
"7: Macros" => lecture_07,

docs/src/lecture_02/hw.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ end
5555
5656
function agent_step!(a::Animal, w::World)
5757
incr_energy!(a,-1)
58-
if rand() <= food_prob(a)
58+
if rand() <= foodprob(a)
5959
dinner = find_food(a,w)
6060
eat!(a, dinner, w)
6161
end
6262
if energy(a) <= 0
6363
kill_agent!(a,w)
6464
return
6565
end
66-
if rand() <= reproduction_prob(a)
66+
if rand() <= reprprob(a)
6767
reproduce!(a,w)
6868
end
6969
return a
@@ -79,16 +79,16 @@ mutable struct Sheep <: Animal
7979
id::Int
8080
energy::Float64
8181
Δenergy::Float64
82-
reproduction_prob::Float64
83-
food_prob::Float64
82+
reprprob::Float64
83+
foodprob::Float64
8484
end
8585
8686
mutable struct Wolf <: Animal
8787
id::Int
8888
energy::Float64
8989
Δenergy::Float64
90-
reproduction_prob::Float64
91-
food_prob::Float64
90+
reprprob::Float64
91+
foodprob::Float64
9292
end
9393
9494
id(a::Agent) = a.id # every agent has an ID so we can just define id for Agent here
@@ -100,8 +100,8 @@ grow!(a::Plant) = a.size += 1
100100
# get field values
101101
energy(a::Animal) = a.energy
102102
Δenergy(a::Animal) = a.Δenergy
103-
reproduction_prob(a::Animal) = a.reproduction_prob
104-
food_prob(a::Animal) = a.food_prob
103+
reprprob(a::Animal) = a.reprprob
104+
foodprob(a::Animal) = a.foodprob
105105
106106
# set field values
107107
energy!(a::Animal, e) = a.energy = e

docs/src/lecture_02/lab.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,15 @@ removed from the world. If it has positive energy it will try to reproduce.
9191
```@example non_parametric_agents
9292
function agent_step!(a::Animal, w::World)
9393
incr_energy!(a,-1)
94-
if rand() <= food_prob(a)
94+
if rand() <= foodprob(a)
9595
dinner = find_food(a,w)
9696
eat!(a, dinner, w)
9797
end
9898
if energy(a) <= 0
9999
kill_agent!(a,w)
100100
return
101101
end
102-
if rand() <= reproduction_prob(a)
102+
if rand() <= reprprob(a)
103103
reproduce!(a,w)
104104
end
105105
return a
@@ -179,8 +179,8 @@ mutable struct Sheep <: Animal
179179
id::Int
180180
energy::Float64
181181
Δenergy::Float64
182-
reproduction_prob::Float64
183-
food_prob::Float64
182+
reprprob::Float64
183+
foodprob::Float64
184184
end
185185
```
186186
Again we will use `Sheep` as a generic example for an `Animal` which
@@ -190,8 +190,8 @@ all other fields of our animals will stay constant.
190190
# get field values
191191
energy(a::Animal) = a.energy
192192
Δenergy(a::Animal) = a.Δenergy
193-
reproduction_prob(a::Animal) = a.reproduction_prob
194-
food_prob(a::Animal) = a.food_prob
193+
reprprob(a::Animal) = a.reprprob
194+
foodprob(a::Animal) = a.foodprob
195195
196196
# set field values
197197
energy!(a::Animal, e) = a.energy = e
@@ -275,8 +275,8 @@ mutable struct Wolf <: Animal
275275
id::Int
276276
energy::Float64
277277
Δenergy::Float64
278-
reproduction_prob::Float64
279-
food_prob::Float64
278+
reprprob::Float64
279+
foodprob::Float64
280280
end
281281
282282
function eat!(wolf::Wolf, sheep::Sheep, w::World)

docs/src/lecture_03/hw.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,6 @@ delicious looks but decreases the energy of the sheep by
2222
```@raw html
2323
</div></div>
2424
```
25-
```@setup hw03
26-
abstract type Mushroom <: PlantSpecies end
27-
Base.show(io::IO,::Type{Mushroom}) = print(io,"🍄")
28-
29-
EcosystemCore.eats(::Animal{Sheep},::Plant{Mushroom}) = true
30-
function EcosystemCore.eat!(s::Animal{Sheep}, m::Plant{Mushroom}, w::World)
31-
incr_energy!(s, -size(m)*Δenergy(s))
32-
EcosystemCore.kill_agent!(m,w)
33-
end
34-
```
3525
Your new species should give you results like below
3626
```@repl hw03
3727
s = Sheep(1,2,2,1,1);
@@ -74,20 +64,6 @@ calls to the function `fn` that is returned by `every_nth(f,n)`.
7464
```@raw html
7565
</div></div>
7666
```
77-
```@setup hw03
78-
function every_nth(f::Function, n::Int)
79-
i = 1
80-
function callback(w::World)
81-
# display(i) # comment this out to see how the counter increases
82-
if i == n
83-
f(w)
84-
i = 1
85-
else
86-
i += 1
87-
end
88-
end
89-
end
90-
```
9167
You can use `every_nth` to log and save the agent count only every couple of
9268
steps of your simulation. Using `every_nth` will look like this:
9369
```@repl hw03

0 commit comments

Comments
 (0)