Skip to content
This repository has been archived by the owner on Aug 5, 2020. It is now read-only.

Commit

Permalink
Does final polish
Browse files Browse the repository at this point in the history
  • Loading branch information
TilBlechschmidt committed May 17, 2020
1 parent 79155e3 commit c3124d4
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
//#-code-completion(everything, hide)
/*:
Large swarms of fish or birds are complex entities that are comprised of hundreds if not thousands of individuals.
Each of these is following a set of behavioral rules. One might think that such a rule could be to try and follow a leading bird.
For small swarms, this might actually be the case but for larger ones, it is quite the opposite.
Each of these is following a set of behavioral rules.
Turn your attention to human behavior in a group for a moment.
Picture a concert hall where everybody wants to leave after the show. Every human has the same goal - to reach the exit. However most of the time not everybody is just going straight for the exit but instead, move laterally to get into a better spot within the group that is trying to leave.
Another example is people at the checkout in the grocery store. Not everybody is using the same checkout terminal but instead, they are distributing to wherever the least people are at that moment.
These are some basic examples of rules in the real world and just like humans, fish, and birds have similar rules that determine their behavior.
You might have noticed the fish on the right. These are currently following one simple rule:
A simulation where you have a lot of individual entities that each follow a set of rules is called a cellular automaton. These are used in areas like biology and physics amongst others to recreate real-world behaviors of complex systems and this playground will make use of it to show you how awesome swarms are! You might have noticed the fish on the right. These are currently following one simple rule:
`move in a random direction`
*/

/*:
A simulation where you have a lot of individual entities that each follow a set of rules is called a cellular automaton. These are used in areas like biology and physics amongst others to recreate real-world behaviors of complex systems and this playground will make use of it to show you how awesome swarms are!
The fish on the right will be your pets! You can interact with them by touching them 🐠
They will be your pets! Take care of them, you can interact by touching them 🐠
Continue to the [next page](@next) to discover some more interesting rules and get coding!
*/

This file was deleted.

Binary file not shown.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func align() {
//#-end-hidden-code
//#-code-completion(everything, hide)
/*:
To give the fish on the right some purpose in life lets provide them with some more rules!
To give your fish some purpose in life lets provide them with some more rules!
* Experiment:
Below are some rules you can experiment with - try enabling different ones and look at the result. Remember that you can slowly step through your code to enable the rules one after another by pressing the gauge on the bottom left of the fish tank!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ simulation.configuration.scale = 0.5
}
```
* Experiment: Try making the two teams flock and one avoid the other to prevent them from just swimming through each other!
* Experiment: Try making the two teams flock and avoid each other to prevent them from swimming through each other!
*/
//#-code-completion(everything, hide)
//#-code-completion(currentmodule, show)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ simulation.configuration.compressionFactor = 1
simulation.configuration.scale = 0.5
//#-end-hidden-code
/*:
As previously mentioned you can interact with your pet fish by touching them. By default, this attracts them with a moderate force. You can try to split a swarm into multiple individual schools of fish or change its direction!
As previously mentioned you can interact with your pet by touching them. By default, this attracts them with a moderate force. You can try to split a swarm into multiple individual schools of fish or change its direction!
This force, like many other things, can be configured to behave differently! You can change its strength and radius like this (those are the defaults):
```
Expand Down Expand Up @@ -32,4 +32,4 @@ addForces {
}
//#-end-editable-code

//: When you have played with your fish head to the [next page](@next) to learn more on how you can change the environment!
//: When you have played with your fish head to the [next page](@next) to learn more on how you can change the environment of the simulation!
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ addForces {
//#-end-editable-code


//: On the [next page](@next) you will learn how to change what happens when you touch your fish
//: On the [next page](@next) you will learn how to change what happens when you touch your fish.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ var config = SimulationConfiguration()
config.compressionFactor = 0.5
config.scale = 0.75

config.visualiseForces = true
config.visualisationForces = [.separation]

var interaction = InteractionConfiguration()

let bigTeam = Team(of: 25, size: 0.75)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ simulation.configuration.scale = 0.75
let team1 = Team(of: 250)
add(team1)
```
* Important: You should **not** create teams bigger than 5.000 fish (it fries the simulation)!
You can repeat this with different names multiple times and get multiple teams! In addition to the number of fish, there is a variety of other parameters that can be tweaked. Have a play with them below!
* Note: All teams you add will have the three rules we previously used enabled by default on this page. You will learn how to do this yourself in a bit.
Expand Down Expand Up @@ -43,8 +45,6 @@ add(weirdFish)

/*:
You may notice that your teams of fish are currently not interacting with each other. They are not even moving out of the way of the other fish when they pass through them! That happens because all rules we added only affect fish in the same team. Let's change that on the [next page](@next)!
* Important: You should **not** create teams bigger than 5.000 fish (it fries the simulation)!
*/
//#-hidden-code
simulation.interaction.teams.forEach {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
//#-code-completion(identifier, show, flee(from:configuration:), align(with:configuration:), chase(:configuration:), becomePredator(of:))
//#-code-completion(identifier, show, init(strength:radius:), init(strength:radius:speedLimit:fieldOfView:scaleWithPeers:))
//#-code-completion(identifier, show, simulation, configuration, simulationSpeed, scale, visualiseForces, visualisationBoidID, visualisationForces, compressionFactor, touchRadius, touchStrength)
//#-code-completion(identifier, show, heading, velocity, fixedColor, angleOfAttack)
//#-editable-code
simulation.configuration.compressionFactor = 1
simulation.configuration.scale = 0.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
simulation.configuration.simulationSpeed = 0.75
//#-end-hidden-code
/*:
The final showcase of emergent behavior will be obstacle avoidance! In the case of this simulation, the walls (and waves) are obstacles that have to be avoided. Below is an example of a **very** big swarm of fish that barely fits into the given space.
The final showcase of emergent behavior will be obstacle avoidance! In the case of this simulation, the boundaries and waves are obstacles that have to be avoided. Below is an example of a **very** big swarm of fish that barely fits into the given space.
* Experiment:
Look closely how the swarm moves towards one corner of the tank and as the pressure increases a critical point is reached where seemingly the whole swarm changes direction at once. This happens even though some fish are far away from the wall and don't even know why they are changing direction!
Expand All @@ -16,6 +16,7 @@ simulation.configuration.simulationSpeed = 0.75
//#-code-completion(identifier, show, flee(from:configuration:), align(with:configuration:), chase(:configuration:), becomePredator(of:))
//#-code-completion(identifier, show, init(strength:radius:), init(strength:radius:speedLimit:fieldOfView:scaleWithPeers:))
//#-code-completion(identifier, show, simulation, configuration, simulationSpeed, scale, visualiseForces, visualisationBoidID, visualisationForces, compressionFactor, touchRadius, touchStrength)
//#-code-completion(identifier, show, heading, velocity, fixedColor, angleOfAttack)
//#-editable-code
let fish = Team(of: 2500, coloration: .heading)
add(fish)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
If you are interested in the topic and would like to read more about it you can read/watch the resources below.
- Original research by [Craig Reynolds](http://www.red3d.com/cwr/boids/) from 1986
- Recent video by [SmarterEveryDay](https://www.youtube.com/watch?v=4LWmRuB-uNU) on the topic
- Recent video by [SmarterEveryDay](https://www.youtube.com/watch?v=4LWmRuB-uNU)
*/
//#-editable-code
let fish = Team(of: 5000, coloration: .heading)
Expand Down

0 comments on commit c3124d4

Please sign in to comment.