Environment

The environment is what the individuals are inhabiting. Their actions determine in part how the environment changes. We will describe each environment.

Nadezhda

For our trusty cockroach the environment is basic. We only need to keep track of the source of food, and the location of the cockroach. We model that by integers.

1 pub struct Environment {
2     /// The location of the cockroach
3     pub cockroach_location: i32,
4     /// The location of the pile of food
5     pub food_location: i32,
6 }

Exercises

  1. Creating structs with many fields is cumbersome. An fluent interface could alleviate the nuisance. Create an fluent interface for the various environment.