Cell types - makingthematrix/gailibrary GitHub Wiki
Each cell needs an id and a type. They could be stored in the values map, as any other value. It would look more pure from the cellular automata point of view, but it's more practical to keep them separately, as these two identify the cell in GAI and have to be present - a cell without them would make no sense.
The user is able to pre-register cell types. A CellType
defines required values (but not optional ones), their default initial values, and the pseud-random number generator's seed, if needed.
struct CellType {
type: CellTypeId
values: Map<ValueId, Option<Value>>
lazyVals: Set<ValueId>
prngSeed: Option<Int>
}
It does not define variables – these are set to an empty map at the beginning of every iteration and can be populated by functions however they want. Lazy vals here are only valueIds
/functionIds
(they are interchangeable) of functions which can be used to compute lazy vals for the cell of the given type.
Later, if we want to create a cell of a given type, we can simply call:
GAI.createCell(cellId: CellId, cellType: CellTypeId, optionalValuesMap: Map<ValueId, Value>)
Why optional values? Consider for example an NPC who is a soldier in the game. It has ammo and health initially set to Coeff(1.0)
, and it has position
and direction
, but these are different for every soldier, so they have no defaults and we can't set them initially in the cell type. Instead we set them to None
in the CellType
data structure (I might want to rethink that in the future) and, upon creating the cell based on that cell type, replace them with the actual position and direction of the soldier.
Variables and the pseudo-random numbers generators <- | -> Graphs