-
-
Notifications
You must be signed in to change notification settings - Fork 3
Home
Please note that most of this content is just a draft.
Creatures are composed of separate parts, which should have very specific roles. Part of this project is to explore object oriented programming in SpriteKit, so using established paradigms to govern how these parts interact with each other should be a priority.
The body controls locomotion and keeps track of metadata about the body, such has how much health it has, and how long it has lived. It also responds to outside stimuli, and can send the brain data about its surrounding. The body also houses some inheritable traits, like movement speed and physical size.
The brain is in charge of any decision making necessary for the creature, such as determining which food pellets or mates to pursue. The brain can send signals back to the body (such as the creature's "current target") and also request data from the body (such as all food pellets or creatures in the tank) for further processing. At the moment, the brain is not specialized between creatures and is not inheritable--but I expect to change that.
The brain has a sub-component composed of a GKStateMachine, which is (at the moment) probably too elaborate and the brain class could handle everything it does much more simply. However, if creature behavior becomes more complex, the benefit of using GKStateMachine could become more apparent.
The limbs are simple accoutrement that (at this time) serve no functional purpose. Limbs color, shape, and initial position on the body are inheritable traits.
Every second a creature thinks about their situation. This is handled by an update
operation called by the scene on the creature, which then calls think
on the brain. The brain then reaches out to the body for that data it needs (current health) to decide which state to be in. For example, if creature health is above a certain threshold, the creature should be put into a "mating" state.
In that state, every second the brain will request data from the body (a list of all eligible mates in the tank), and then process that list to determine the most desirable mate. The brain will then tell the body to target the creature it decided upon. The body is then in charge of moving the creature to that mate. Because these creatures are so simple, the brain is not involved in navigation beyond picking where to go.