5. some final words about specific demos - sitechtimes/science-demos GitHub Wiki
Coral Demo Stores:
Some general notes before I leave:
I've wasted quite a lot of time overthinking the various factors in this simulation. (Don't get me wrong, in real life this is pretty complicated, but for our purposes, it really does not matter.) Just have something that seems plausible to believe.
The store runs on a watcher that observes the current year. All the functions will be triggered by the year changing (note: the current math functions in such a way that it uses the previous value to calculate the next value for populations etc.)
Organism stats such as mortality rate etc. should be stored in a separate store, with datastore holding the environmental variables.
I will probably keep working on this for a bit more so we will see later.
In the most likely event of the math being atrocious, feel free to restructure it entirely and build it from the ground up. The current math is pretty bad since we tried to steal compiled code from gizmos and translate it into readable code with AI. There is definitely a multitude of errors caused by the AI.
Functionality:
The stores were created to house all the calculations and information that we process in this demos.
There will be multiple stores, with each of them serving a different purpose.
In general, the math is running on a watcher that detects changes to the user input (As of right now, it is only observing for changes on the selected year)
Data Store:
This is where we store environmental variables
Each object within this store represents an environment variable, their respective slider settings and ranges, as well as their default values.
The slider components also pull from this store, and generally you just need to put the name of the ref inside an array within the slider container to add it to the site.
In addition to this, we temporarily have the boolean for invasive species housed there. Feel free to change the designation or keep it, as there is currently no logic supporting or linked to it. (I believe the plan was for the species to be checkboxes and bound to the variables in the store)
Growth Factors Store:
This store contains all the stats for each of the organisms, such as growth rate and mortality rate.
At the moment, some of these numbers/variables don't make sense because yet again, they are generated by our AI approach.
Please note: these variables are computed properties because their growth rates have to be calculated based on environmental variables housed in population store. (I know, it's messy)
Maybe some future plans include adding a sort of impact factor? for each of the environmental variables for the species to represent their sensitivities. (This depends on what direction the math goes)
Feel free to restructure this store as accessing it from the main store is in fact quite tedious and long.
Population Store:
This is the store where most of our math is housed.
Currently, it is generally divided up into the organisms section and environmental variables section
The organisms section goes in order of organism object (houses the information and populations / capacities of all years in the simulation), capacities (These are functions that are supposed to update the cap of an organism's population for the year) and population (More functions that calculate the populations of organisms for that year).
Please note that capacity and population functions run using data values from the previous year (the calculations are set up in such a way that we push the calculated values into the organism object arrays then pull that same value to calculate the next year's values)
In addition, when accessing previous year values, there is a computed property that will subtract 1 from "current year" or the selected year. (This is what the watcher observes for changes and subsequently calls on all functions to advance the year by 1)
The environmental variables are generally computed properties that calculate values based on the slider values housed in Data Store. These sliders originate from user input and use them to create a "snapshot" of the year's environment. These past values are currently not saved and are overwritten by the subsequent values. (Feel free to make a separate array for each of them and simply push the values in after every year is calculated)
In addition to environmental and organism values, this store also aggregates all of the population values / capacities for the year into one variable that can be accessed by our unity end. However, when displaying the data on the charts, it is probably more convenient to use the arrays saved within each organism's object.
Due to the nature of our math, when a user decreases the year count, the system simply removes all the data from the arrays for the years that are "removed" or "reduced". This then allows for us to calculate values based on the year the user starts off at after the reduction. Environmental variables should not be affected, but if they are, they are computed properties that will automatically update. (This then gives the user the flexibility to change environmental settings midway through the simulation.