diff --git a/11_ultima_online.Rmd b/11_ultima_online.Rmd index 0acc170b..9156779c 100644 --- a/11_ultima_online.Rmd +++ b/11_ultima_online.Rmd @@ -19,7 +19,7 @@ using MCMCChains ## The Ultima Online Catastrophe -[Ultima online](https://uo.com/) is a fantasy massively multiplayer online role-playing game (MMORPG) created by [Richard Garriott](https://en.wikipedia.org/wiki/Richard_Garriott) between 1995 and 1997, when it was realesed. +[Ultima online](https://uo.com/) is a fantasy massively multiplayer online role-playing game (MMORPG) created by [Richard Garriott](https://en.wikipedia.org/wiki/Richard_Garriott) between 1995 and 1997, when it was released. The game consisted of a medieval fantasy world in which each player could build their own character. What was interesting and disruptive was that all players interacted with each other, and what one did had repercussions on the general map. So, the game was "live" in the sense that if two people were fighting in one area and another one came in, the latter could see that fight. Also, the warriors had to hunt and look for resources to get points and improve their skills and again, if a treasure was discovered, or an animal was hunted, it would no longer be available for the rest. @@ -49,17 +49,17 @@ The population at time $t$ multiplies at both rates because if the population is #### Parentheses on differential equations -Before anyone freaks out, lets talk a little bit about that strange notation. +Before anyone freaks out, let's talk a little bit about that strange notation. -As we said above, the prey´s population will grow proportionally to the birth rate and the actual population. And we also said that the population will shrink proportional to the mortality rate and its actual population. Can you realize that we are describing change? +As we said above, the prey's population will grow proportionally to the birth rate and the actual population. And we also said that the population will shrink proportional to the mortality rate and its actual population. Can you realize that we are describing change? -So that is exactly what the equation is saying! You can read that horrendous $d$ as change! So, the entire term $\frac{dPrey}{dt}=$ is just saying "The change of the pupulation over time (that´s why the $dt$ term is deviding there) is equal to..." and that´s it! +So that is exactly what the equation is saying! You can read that horrendous $d$ as change! So, the entire term $\frac{dPrey}{dt}=$ is just saying "The change of the population over time (that's why the $dt$ term is dividing there) is equal to..." and that's it! -This can be a difficult concept to understand because we are very used to work with absolute values. But sometimes (In fact, very often) it is much more easier to describe change over absolute values. And this is one of this cases. But, for now, lets leave this up to here, we will take it up again in the next chapter. +This can be a difficult concept to understand because we are very used to work with absolute values. But sometimes (In fact, very often) it is much easier to describe change over absolute values. And this is one of these cases. But, for now, let's leave this up to here, we will take it up again in the next chapter. #### Returning to LotkaVolterra -But the model we are looking for have to explain the interaction between the two species. To do so, we must include the Pradator Population in order to modify the mortality rate of the Prey, leaving us with: +But the model we are looking for has to explain the interaction between the two species. To do so, we must include the Predator Population in order to modify the mortality rate of the Prey, leaving us with: $\frac{dPrey}{dt} = Prey*(b_{prey} - m_{prey}*Pred)$ @@ -72,7 +72,7 @@ In this way we obtain the Lotka-Volterra model in which the population dynamics #### SciML to simulate population dynamics ```{julia} -#Let´s define our Lotka-Volterra model +#Let's define our Lotka-Volterra model function lotka_volterra(du,u,p,t) prey, pred = u @@ -101,7 +101,7 @@ plot(sol) #### Obtaining the model from the data -Back to the terrible case of Ultima Online. Suppose we had data on the population of predators and prey that were in harmony during the game at a given time. If we wanted to venture out and analyze what parameters Garriot and his team used to model their great ecosystem, would it be possible? Of course it is, we just need to add a little Bayesianism. +Back to the terrible case of Ultima Online. Suppose we had data on the population of predators and prey that were in harmony during the game at a given time. If we wanted to venture out and analyze what parameters Garriott and his team used to model their great ecosystem, would it be possible? Of course it is, we just need to add a little Bayesianism. ```{julia} data = CSV.read("./11_ultima_online/ultima_online_data.csv", DataFrame) @@ -177,7 +177,7 @@ The powerful SciML engine allows us to make Bayesian inferences but from dynamic #### Visualizing the results -As always, it is very interesting to be able to observe the uncertainty that Bayesianism provides us within our model. Let´s go for it! +As always, it is very interesting to be able to observe the uncertainty that Bayesianism provides us within our model. Let's go for it! First we should make a smaller sampling of the distributions of each parameter so that the number of models we plot does not become a problem when visualizing: @@ -190,7 +190,7 @@ begin end; ``` -And now let's solve the system of differential equations for each of the combinations of parameters that we form, saving them in solutions so that later we can use this array in the plotting. You can scroll left and see the solution to the 101 models we propouse (Notice that we add one final model using the mean of each parameter) +And now let's solve the system of differential equations for each of the combinations of parameters that we form, saving them in solutions so that later we can use this array in the plotting. You can scroll left and see the solution to the 101 models we propose (Notice that we add one final model using the mean of each parameter) ```{julia , results = FALSE} begin @@ -287,6 +287,7 @@ plot(sol_players) As you can see, the players could hunt enough to double the mortality rate of both animals, and the system would still be in balance. More herbivores would be observed (because they have a higher birth rate, and there would now be fewer carnivores) and the phase - the time it takes for a full cycle of population decline and rise - would be delayed. The creators of the game even assumed that the players would hunt mostly carnivores, because they would be rewarded with higher scores and resources (and because they would also have to defend themselves from the fierce attacks of the carnivores). The balance would be maintained anyway: + ```{julia,results = FALSE} begin p2 = [0.8, 0.4, 0.2, 0.4, 0.4, 0.6] @@ -328,11 +329,11 @@ plot(sol_crazy_players, legend=false) This sad story ends with the whole beautiful virtual ecosystem, planned for 3 years, destroyed in seconds. The animals of the medieval world that Garriott and his team had imagined had to be eliminated... In case you want to know more about this, you can listen to the story from the mouth of the protagonist himself [here](https://www.youtube.com/watch?v=KFNxJVTJleE&ab_channel=ArsTechnica) -But like every difficult moment, this one also left great lessons. From that moment on, the games started to been tested with real people during the whole development process. The idea that you could predict the behavior of millions of players was finished, and they started to test instead. +But like every difficult moment, this one also left great lessons. From that moment on, the games started to be tested with real people during the whole development process. The idea that you could predict the behavior of millions of players was finished, and they started to test instead. This was the beginning of a very Bayesian way of thinking, in which we start with a priori hypotheses that are tested with reality to modify the old beliefs, and gain a deeper understanding of what is really happening. -It makes sense, doesn't it? After all, getting comfortable with our beliefs never is a very good option, and going out into the world to learn new things seem like a more interesting one. +It makes sense, doesn't it? After all, getting comfortable with our beliefs is never a very good option, and going out into the world to learn new things seems like a more interesting one. ## Summary @@ -342,4 +343,4 @@ In this chapter we have learned about the usefulness of differential equations f - [SciML](https://sciml.ai/) - [Turing Bayesian Differential Equation](https://turing.ml/dev/tutorials/10-bayesiandiffeq/) -- [Garriot telling the Story](https://www.youtube.com/watch?v=KFNxJVTJleE&ab_channel=ArsTechnica) +- [Garriott telling the Story](https://www.youtube.com/watch?v=KFNxJVTJleE&ab_channel=ArsTechnica) diff --git a/11_ultima_online/11_ultima_online.jl b/11_ultima_online/11_ultima_online.jl index f2ca7d81..2e6aafae 100644 --- a/11_ultima_online/11_ultima_online.jl +++ b/11_ultima_online/11_ultima_online.jl @@ -24,7 +24,7 @@ We are currently working on: # ╔═╡ 74cc60be-2821-11eb-3ad7-e581052437bd md"""# The Ultima Online Catastrophe -[Ultima online](https://uo.com/) is a fantasy massively multiplayer online role-playing game (MMORPG) created by [Richard Garriott](https://en.wikipedia.org/wiki/Richard_Garriott) between 1995 and 1997, when it was realesed. +[Ultima online](https://uo.com/) is a fantasy massively multiplayer online role-playing game (MMORPG) created by [Richard Garriott](https://en.wikipedia.org/wiki/Richard_Garriott) between 1995 and 1997, when it was released. The game consisted of a medieval fantasy world in which each player could build their own character. What was interesting and disruptive was that all players interacted with each other, and what one did had repercussions on the general map. So, the game was "live" in the sense that if two people were fighting in one area and another one came in, the latter could see that fight. Also, the warriors had to hunt and look for resources to get points and improve their skills and again, if a treasure was discovered, or an animal was hunted, it would no longer be available for the rest. @@ -62,17 +62,17 @@ md"""The population at time *t* multiplies at both rates because if the populati #### Parentheses on differential equations -Before anyone freaks out, lets talk a little bit about that strange notation. +Before anyone freaks out, let's talk a little bit about that strange notation. -As we said above, the prey´s population will **grow** proportionally to the birth rate and the actual population. And we also said that the population will **shrink** proportional to the mortality rate and its actual population. Can you realize that we are describing **change**? +As we said above, the prey's population will **grow** proportionally to the birth rate and the actual population. And we also said that the population will **shrink** proportional to the mortality rate and its actual population. Can you realize that we are describing **change**? -So that is exactly what the equation is saying! You can read that horrendous $d$ as change! So, the entire term $\frac{dPrey}{dt}=$ is just saying "The change of the pupulation over time (that´s why the $dt$ term is deviding there) is equal to..." and that´s it! +So that is exactly what the equation is saying! You can read that horrendous $d$ as change! So, the entire term $\frac{dPrey}{dt}=$ is just saying "The change of the population over time (that's why the $dt$ term is dividing there) is equal to..." and that's it! -This can be a difficult concept to understand because we are very used to work with **absolute** values. But sometimes (In fact, very often) it is much more easier to describe change over absolute values. And this is one of this cases. But, for now, lets leave this up to here, we will take it up again in the next chapter. +This can be a difficult concept to understand because we are very used to work with **absolute** values. But sometimes (In fact, very often) it is much easier to describe change over absolute values. And this is one of these cases. But, for now, let's leave this up to here, we will take it up again in the next chapter. #### Returning to LotkaVolterra -But the model we are looking for have to explain the *interaction* between the two species. To do so, we must include the Pradator Population in order to modify the mortality rate of the Prey, leaving us with: +But the model we are looking for has to explain the *interaction* between the two species. To do so, we must include the Predator Population in order to modify the mortality rate of the Prey, leaving us with: """ # ╔═╡ e0f34b58-2845-11eb-0480-9d200fc79403 @@ -91,7 +91,7 @@ md"In this way we obtain the Lotka-Volterra model in which the population dynami md"#### SciML to simulate population dynamics" # ╔═╡ 5da9eb00-2848-11eb-0dfa-17ca0490bd44 -#Let´s define our Lotka-Volterra model +#Let's define our Lotka-Volterra model function lotka_volterra(du,u,p,t) prey, pred = u @@ -117,7 +117,7 @@ plot(sol) # ╔═╡ 4aff3714-284b-11eb-2047-814ca175e07b md"""#### Obtaining the model from the data -Back to the terrible case of Ultima Online. Suppose we had data on the population of predators and prey that were in harmony during the game at a given time. If we wanted to venture out and analyze what parameters Garriot and his team used to model their great ecosystem, would it be possible? Of course it is, we just need to add a little Bayesianism. +Back to the terrible case of Ultima Online. Suppose we had data on the population of predators and prey that were in harmony during the game at a given time. If we wanted to venture out and analyze what parameters Garriott and his team used to model their great ecosystem, would it be possible? Of course it is, we just need to add a little Bayesianism. """ # ╔═╡ e3da565c-2851-11eb-0fa7-a3cd80bb9d63 @@ -189,7 +189,7 @@ The powerful SciML engine allows us to make Bayesian inferences but from dynamic #### Visualizing the results -As always, it is very interesting to be able to observe the uncertainty that Bayesianism provides us *within* our model. Let´s go for it! +As always, it is very interesting to be able to observe the uncertainty that Bayesianism provides us *within* our model. Let's go for it! First we should make a smaller sampling of the distributions of each parameter so that the number of models we plot does not become a problem when visualizing: " @@ -203,7 +203,7 @@ begin end; # ╔═╡ dee1f67c-291a-11eb-11ba-7d6b7129b15c -md"And now let's solve the system of differential equations for each of the combinations of parameters that we form, saving them in *solutions* so that later we can use this array in the plotting. You can scroll left and see the solution to the 101 models we propouse (Notice that we add one final model using the mean of each parameter)" +md"And now let's solve the system of differential equations for each of the combinations of parameters that we form, saving them in *solutions* so that later we can use this array in the plotting. You can scroll left and see the solution to the 101 models we propose (Notice that we add one final model using the mean of each parameter)" # ╔═╡ 3794d5aa-291b-11eb-1e16-31c59b6d37a2 begin @@ -336,11 +336,11 @@ plot(sol_crazy_players, legend=false) # ╔═╡ 0e53ba34-29d5-11eb-3540-bbc2a0127cf5 md"This sad story ends with the whole beautiful virtual ecosystem, planned for 3 years, destroyed in seconds. The animals of the medieval world that Garriott and his team had imagined had to be eliminated... In case you want to know more about this, you can listen to the story from the mouth of the protagonist himself [here](https://www.youtube.com/watch?v=KFNxJVTJleE&ab_channel=ArsTechnica) -But like every difficult moment, this one also left great lessons. From that moment on, the games started to been tested with real people during the whole development process. The idea that you could predict the behavior of millions of players was finished, and they started to test instead. +But like every difficult moment, this one also left great lessons. From that moment on, the games started to be tested with real people during the whole development process. The idea that you could predict the behavior of millions of players was finished, and they started to test instead. This was the beginning of a very Bayesian way of thinking, in which we start with a priori hypotheses that are tested with reality to modify the old beliefs, and gain a deeper understanding of what is really happening. -It makes sense, doesn't it? After all, getting comfortable with our beliefs never is a very good option, and going out into the world to learn new things seem like a more interesting one. +It makes sense, doesn't it? After all, getting comfortable with our beliefs is never a very good option, and going out into the world to learn new things seems like a more interesting one. ### Summary @@ -352,7 +352,7 @@ md"### References - [SciML](https://sciml.ai/) - [Turing Bayesian Differential Equation](https://turing.ml/dev/tutorials/10-bayesiandiffeq/) -- [Garriot telling the Story](https://www.youtube.com/watch?v=KFNxJVTJleE&ab_channel=ArsTechnica)" +- [Garriott telling the Story](https://www.youtube.com/watch?v=KFNxJVTJleE&ab_channel=ArsTechnica)" # ╔═╡ e00277e6-8b5f-11eb-2626-3d60478516a7 md" ### Give us feedback diff --git a/12_ultima_continued/12_ultima_continued.jl b/12_ultima_continued/12_ultima_continued.jl index 72454e5b..025d8dbe 100644 --- a/12_ultima_continued/12_ultima_continued.jl +++ b/12_ultima_continued/12_ultima_continued.jl @@ -445,4 +445,4 @@ md"""### References # ╠═fef7edba-54dd-11eb-3025-35fe9ffae6ac # ╟─fe88958e-54e5-11eb-12bc-01ad625d85c5 # ╟─e6ec4364-54eb-11eb-1bf6-83db426cd32f -# ╟─aac56d4e-54e7-11eb-2d8a-1f21c386ef8d +# ╟─aac56d4e-54e7-11eb-2d8a-1f21c386ef8d \ No newline at end of file diff --git a/docs/ultima-online.html b/docs/ultima-online.html index b584cf40..e56a3eeb 100644 --- a/docs/ultima-online.html +++ b/docs/ultima-online.html @@ -301,7 +301,7 @@

Chapter 11 Ultima online

11.1 The Ultima Online Catastrophe

-

Ultima online is a fantasy massively multiplayer online role-playing game (MMORPG) created by Richard Garriott between 1995 and 1997, when it was realesed.

+

Ultima online is a fantasy massively multiplayer online role-playing game (MMORPG) created by Richard Garriott between 1995 and 1997, when it was released.

The game consisted of a medieval fantasy world in which each player could build their own character. What was interesting and disruptive was that all players interacted with each other, and what one did had repercussions on the general map. So, the game was “live” in the sense that if two people were fighting in one area and another one came in, the latter could see that fight. Also, the warriors had to hunt and look for resources to get points and improve their skills and again, if a treasure was discovered, or an animal was hunted, it would no longer be available for the rest.

During the development process of the game, Garriott and his team realized that, due to the massiveness of the game, there was going to be a moment when they would not be able to create content at the same speed as the players were consuming it. So they decided to automate the process.

After a lot of work, one of the ideas they came up with was to generate a “Virtual Ecosystem.” This was a really incredible idea in which a whole ecosystem in harmony was simulated inside the game. For example, if an area started to grow grass, the herbivorous animals would come and start eating it. If many animals arrived, they would surely end up eating all the food and would have to go look for other places, it could even happen that some of them were not lucky and died on the way, starving. In the same way, the carnivorous animals (that is, the predators of the herbivores) would strive to hunt as many animals as they could, but if in doing so they killed a significant number of them, food would become scarce causing them to die as well. In this way, as in “real” nature, a beautiful balance was generated.

@@ -318,14 +318,14 @@

11.1.1 The Lotka-Volterra model f

The population at time \(t\) multiplies at both rates because if the population is zero there can be no births or deaths. This leads us to the simplest ecological model, in which per capita growth is the difference between the birth rate and the mortality rate.

11.1.1.1 Parentheses on differential equations

-

Before anyone freaks out, lets talk a little bit about that strange notation.

-

As we said above, the prey´s population will grow proportionally to the birth rate and the actual population. And we also said that the population will shrink proportional to the mortality rate and its actual population. Can you realize that we are describing change?

-

So that is exactly what the equation is saying! You can read that horrendous \(d\) as change! So, the entire term \(\frac{dPrey}{dt}=\) is just saying “The change of the pupulation over time (that´s why the \(dt\) term is deviding there) is equal to…” and that´s it!

-

This can be a difficult concept to understand because we are very used to work with absolute values. But sometimes (In fact, very often) it is much more easier to describe change over absolute values. And this is one of this cases. But, for now, lets leave this up to here, we will take it up again in the next chapter.

+

Before anyone freaks out, let's talk a little bit about that strange notation.

+

As we said above, the prey's population will grow proportionally to the birth rate and the actual population. And we also said that the population will shrink proportional to the mortality rate and its actual population. Can you realize that we are describing change?

+

So that is exactly what the equation is saying! You can read that horrendous \(d\) as change! So, the entire term \(\frac{dPrey}{dt}=\) is just saying “The change of the population over time (that's why the \(dt\) term is dividing there) is equal to…” and that's it!

+

This can be a difficult concept to understand because we are very used to work with absolute values. But sometimes (In fact, very often) it is much easier to describe change over absolute values. And this is one of these cases. But, for now, let's leave this up to here, we will take it up again in the next chapter.

11.1.1.2 Returning to LotkaVolterra

-

But the model we are looking for have to explain the interaction between the two species. To do so, we must include the Pradator Population in order to modify the mortality rate of the Prey, leaving us with:

+

But the model we are looking for has to explain the interaction between the two species. To do so, we must include the Predator Population in order to modify the mortality rate of the Prey, leaving us with:

\(\frac{dPrey}{dt} = Prey*(b_{prey} - m_{prey}*Pred)\)

In a similar way we can think the interaction on the side of the predator, were the mortality rate would be constant and the birth rate will depend upon the Prey population:

\(\frac{dPred}{dt} = Pred*(b_{pred}*Prey - m_{pred})\)

@@ -333,7 +333,7 @@

11.1.1.2 Returning to LotkaVolter

11.1.1.3 SciML to simulate population dynamics

-
#Let´s define our Lotka-Volterra model
+
#Let's define our Lotka-Volterra model
 
 function lotka_volterra(du,u,p,t)
   prey, pred  = u
@@ -354,7 +354,7 @@ 

11.1.1.3 SciML to simulate popula

11.1.1.4 Obtaining the model from the data

-

Back to the terrible case of Ultima Online. Suppose we had data on the population of predators and prey that were in harmony during the game at a given time. If we wanted to venture out and analyze what parameters Garriot and his team used to model their great ecosystem, would it be possible? Of course it is, we just need to add a little Bayesianism.

+

Back to the terrible case of Ultima Online. Suppose we had data on the population of predators and prey that were in harmony during the game at a given time. If we wanted to venture out and analyze what parameters Garriott and his team used to model their great ecosystem, would it be possible? Of course it is, we just need to add a little Bayesianism.

data = CSV.read("./11_ultima_online/ultima_online_data.csv", DataFrame)
## 16×2 DataFrame
 ##  Row │ Column1   Column2
@@ -424,7 +424,7 @@ 

11.1.1.4 Obtaining the model from

11.1.1.5 Visualizing the results

-

As always, it is very interesting to be able to observe the uncertainty that Bayesianism provides us within our model. Let´s go for it!

+

As always, it is very interesting to be able to observe the uncertainty that Bayesianism provides us within our model. Let's go for it!

First we should make a smaller sampling of the distributions of each parameter so that the number of models we plot does not become a problem when visualizing:

begin
     birth_prey_ = sample(collect(get(posterior, :birth_prey)[1]), 100)
@@ -432,7 +432,7 @@ 

11.1.1.5 Visualizing the results< birth_pred_ = sample(collect(get(posterior, :birth_pred)[1]), 100) mort_pred_ = sample(collect(get(posterior, :mort_pred)[1]), 100) end;

-

And now let’s solve the system of differential equations for each of the combinations of parameters that we form, saving them in solutions so that later we can use this array in the plotting. You can scroll left and see the solution to the 101 models we propouse (Notice that we add one final model using the mean of each parameter)

+

And now let’s solve the system of differential equations for each of the combinations of parameters that we form, saving them in solutions so that later we can use this array in the plotting. You can scroll left and see the solution to the 101 models we propose (Notice that we add one final model using the mean of each parameter)

begin
     solutions = []
     for i in 1:length(birth_prey_)
@@ -518,9 +518,9 @@ 

11.1.1.6 The virtual catastrophe<
plot(sol_crazy_players, legend=false)

This sad story ends with the whole beautiful virtual ecosystem, planned for 3 years, destroyed in seconds. The animals of the medieval world that Garriott and his team had imagined had to be eliminated… In case you want to know more about this, you can listen to the story from the mouth of the protagonist himself here

-

But like every difficult moment, this one also left great lessons. From that moment on, the games started to been tested with real people during the whole development process. The idea that you could predict the behavior of millions of players was finished, and they started to test instead.

+

But like every difficult moment, this one also left great lessons. From that moment on, the games started to be tested with real people during the whole development process. The idea that you could predict the behavior of millions of players was finished, and they started to test instead.

This was the beginning of a very Bayesian way of thinking, in which we start with a priori hypotheses that are tested with reality to modify the old beliefs, and gain a deeper understanding of what is really happening.

-

It makes sense, doesn’t it? After all, getting comfortable with our beliefs never is a very good option, and going out into the world to learn new things seem like a more interesting one.

+

It makes sense, doesn’t it? After all, getting comfortable with our beliefs is never a very good option, and going out into the world to learn new things seems like a more interesting one.

@@ -533,7 +533,7 @@

11.3 References