Feel free to join the next Helmholtz Hacky Hour #26 on Wednesday, April 21, 2021 from 2PM to 3PM!

Commit c29cea4e authored by Martin Lange's avatar Martin Lange

final fixes of typos and wording, explicit types for components retrieved from mappers

parent 821354d2
Pipeline #12197 passed with stage
in 12 seconds
......@@ -37,18 +37,18 @@ Model development is an iterative process. For example, submodels are frequently
A design approach that facilitates this style of work is the Entity鈥揅omponent鈥揝ystem (ECS) pattern, by decoupling the state of the model from the logic. While it is rooted in game design, it has proven to be useful for IBMs.
In ECS terms, *entities* are an abstract handles to refer to what we usually consider entities in the IBM world. For example in a predator-prey-model, each predator and each prey could be represented by an entity. In a livestock model, each individual animal, each herd, and each market could be represented by an entity.
In ECS terms, *entities* are abstract handles to refer to what we usually consider entities in the IBM world. For example in a predator-prey-model, each predator and each prey could be represented by an entity. In a livestock model, each individual animal, each herd, and each market could be represented by an entity.
Each entity has one or more *components* which contain the entity's state variables. What can happen with an entity in the model results from the composition of its components. To resume the livestock example, all three types of entities could have a location component, but only animals would have an age. The herds could e.g. have a component holding their trade partners.
What is called a submodel in modelling terms are *systems* in ECS. Systems contain the logic of a model and operate on a certain combination of components. Examples of this kind of logic could be:
What is called a submodel in modelling terms are *systems* in ECS. Systems contain the logic of the model and operate on a certain combination of components. Examples of this kind of logic could be:
* If something has a position and a velocity, it moves (i.e. changes position).
* If something has a velocity and a mass, is falls due to gravity (i.e. changes velocity).
Because systems are only concerned with certain components relevant to their logic, while further components are ignored, the ECS approach enables independent development of different aspects of a model.
Because systems are only concerned with certain components relevant for their logic, while further components are ignored, the ECS approach enables independent development of different aspects of a model.
Component composition can also change over time. Composition changes are often performed by systems, and effect which systems process an entity.
Component composition can also change over time. Composition changes are often performed by systems, and affect which systems process an entity.
A hurdle to overcome when starting to use ECS is to replace thinking about the type of an entity by considering which components/state variables are affected by which systems/processes. The model dynamics then emerge from the interaction of systems via overlapping components.
......@@ -102,7 +102,7 @@ public class Energy extends com.artemis.Component {
Component `Movement` contains the direction the entity is moving, in radians.
Entities have components `Movement` only when searching, but not when grassing. The presence or absence of the component defines an entity's behaviour.
Entities have component `Movement` only when searching, but not when grassing. The presence or absence of the component defines an entity's behaviour.
```java
/// file:src/main/java/grassing/comp/Movement.java
......@@ -253,7 +253,7 @@ p_{t+1} = p_t + r p_t \frac{k - p_t}{k}
where $`p_t`$ is the amount in the current step and $`p_{t+1}`$ in the next step. $`r`$ is the growth rate per step and $`k`$ is the capacity. Capacity is always 1.0.
> The grassing system does not use any entities, and only modifies the `Grass` grid, which is a resource here in ECS terms.
> The grass growth system does not access any entities, and only modifies the `Grass` grid, which is a resource in ECS terms.
>
> A system implements what happens in each time step, but scheduling of those steps is done by the ECS, outside the systems.
......@@ -266,8 +266,8 @@ import com.artemis.annotations.Wire;
import grassing.res.Grass;
public class LogisticGrassGrowth extends BaseSystem {
// A system must extend BaseSystem or one of its many sub-classes for different purposes
// Since this system does not use any entities, we simply extend `BaseSystem`
// A system must extend BaseSystem or one of its many sub-classes that serve different purposes
// Since this system does not access any entities, we simply extend `BaseSystem`
@Wire Grass grass; // The resource is automatically "injected" by the ECS through @Wire
......@@ -369,8 +369,8 @@ public class Reproduction extends IteratingSystem {
@Override
protected void process(int id) {
if(random.rng.nextFloat() < reproductionProb) {
var pos = position.get(id);
var e = energy.get(id);
Position pos = position.get(id);
Energy e = energy.get(id);
e.value /= 2;
int entity = world.create();
......@@ -385,9 +385,9 @@ public class Reproduction extends IteratingSystem {
### Grassing
The grassing behaviour works on all entities that have the components `Position`, `Energy` but not `Movement`. Thus, it ignores grassers that are currently searching (and thus have `Movement`).
The grassing behaviour works on all entities that have the components `Position` and `Energy` but not `Movement`. Thus, it ignores grassers that are currently searching (and thus have `Movement`).
If the grasser's energy is 1.0 or above, it does nothing. Otherwise, the grasser decides if there is enough grass in it's grid cell. If this is the case, the grasser consumes grass and converts it to energy. Otherwise, the grasser switches to the searching behaviour.
If the grasser's energy is 1.0 or above, it does nothing. Otherwise, the grasser decides if there is enough grass in its grid cell. If this is the case, the grasser consumes grass and converts it to energy. Otherwise, the grasser switches to the searching behaviour.
> The behaviour is switched by adding component `Movement`.
>
......@@ -498,8 +498,8 @@ public class SearchBehaviour extends IteratingSystem {
}
private void randomWalk(int id) {
var pos = position.get(id);
var mov = movement.get(id);
Position pos = position.get(id);
Movement mov = movement.get(id);
mov.direction += (float) random.rng.nextGaussian() * maxAngle;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment