Coding for EVA’s emotional state is done through a huge 8-state machine. The prescalar on Timer0 of the Mega32 chip was set to 64 and made to overflow every 125 ticks. This means that Timer0 overflow interrupt occurs once every 1 ms. The state machine is executed once every millisecond.
Overall Game Timers and Counters
It is of utmost importance to keep a detailed and clear record of specific physical and emotional timers of EVA. There is an overall clock that counts the number of seconds that have elapsed since the start of the game. This game clock will synchronize every single action-reaction state of EVA. Besides the game clock, there are state-clocks that tracks the amount of time EVA spends in a particular state. It is reset every time EVA transitions from one state to another.
Next are the physical clocks of EVA. They are the:
General Coding in each State
Although each state is unique in its own ways, there are several similarities in the code that runs in each of the state. Upon transitioning from one state to another state, there are several variables that will be computed once and ‘remembered’ for that state alone. These variables include:
The above variables are the most basic variables that are repeated in every state. However their method of computation changes depending on the state as described above. Nevertheless, all these values are computed using a random number generator multiplied by some predefined weight.
Thus, at the first entry into a state from another, all these variables are predetermined, and as long as EVA remains in the same state, she will transition to other states depending on which counter (variable) is up. However upon leaving the state, a whole new set of values are computed in the new state.
Besides these once-through variables in each state, there are other similar computations in every state. They include:
Similar State Transition Condition Checks
In every state, there is a set of basic checks to determine when EVA needs to respond to the user. The most basic of these checks are those that takes care of her physical needs. Thus when any of the counters that track her physical well-being is up, she will demand an appropriate user interaction.
For example, if the TimeToHungry timer is up, EVA will display a ‘hungry-indicator’, telling the user that she needs to be fed. If the user fails to feed her past her hunger-level when the TimeToStarve is up, another counter will be activated to determine the amount of time EVA has been starving. EVA will then transition to either the Sad or Angry state. Based on a randomly generated cut-off point, when the amount of time EVA has been starving exceeds that level, EVA’s health will drop by 1 point. EVA’s health will continue to drop until the user feeds her.
Very similar to the hungry timer, when EVA needs to go to the toilet, she will display an urgent-indicator and demand the user’s attention. If the user fails to bring her to the toilet by the time the variable TimeToRelease is up, EVA will defecate and make a mess which requires cleaning up. EVA will also transition to either the Sad or Angry state. Again, a counter will count the amount of time the user takes to clean up the mess. If the time exceeds a randomly generated cut-off point, EVA’s discipline will decrease by 1 point.
The description for the sick timer is identical to the above 2 timers, except that the moment EVA is sick, a counter counts the amount of time the user fails to bring medication to her. Depending on the length of time and the cutoff point, EVA’s health will decrease correspondingly.
In all the above 3 timers described, if the user attends to the needs of EVA before she starves or releases her waste, another counter (HealthUpgradePoints) will be incremented. This counter will represent the number of times the user is careful in attending to EVA’s needs, and after a certain number of counts, EVA’s health will increase.