Digital Being - Hunger, Energy and Morale
Internal States of a Digital Being

Let's figure out what variables we should keep track.
Core Variables
Energy: Short-term ability to act. Depletes with movement/work. Rest/food restores it.
Hunger: Separate from energy. Hunger is a drive. Energy is usable fuel.
Safety: Whether the organism is in danger, exposed, unstable, or threatened.
Comfort: Local bodily/environmental well-being. Warmth, shelter, social comfort, pleasantness.
Morale: Emotional momentum. Affects willingness to explore or persist.
Bonding: Need for context, attention, belonging, attachment.
Curiosity: Drive towards novelty, exploration, play, learning.
Fatigue: Pressure to rest. Different from energy. You can be "wired but tired."
Energy
Energy = immediately available capacity to perform work
Energy is current allowance for action. That is, if they want to perform some action, it will require that it has minimum amount of energy. Otherwise, body may reject the request.
Replenishment: Energy is consumed, but replenishes over time. This is because if the body will try to juice it up to keep it at stable level.
Cash Flow: It is easier to picture this as "cash flow" than HP bar. There is some influx function and there is outflux function.
Routing: There should be a notion of routing of this energy since if character is running lots of blood pumps into the muscles to replenish oxygen there. On the other hand, character is doing something that uses lots of brain. Then the blood naturally flows towards the head.
Analysis: I think doing this manually will create endless loop of tuning. One thing that was good about Tree Growth Simulation was that the energy was constant (other than the sunlight influx from boundary pixels). Nutrients were fixed to whatever initial ground pixels had them. So, this allowed proportional growth without unstable growth.
Simulating Blood Circulation
I think perhaps simulating this energy flow as texture in a fixed grid of pixels would be helpful. That is we draw a preset character silhouette and then manually layout the components like head. Add fat, muscles, and gut. And link the logic of energy expenditure to each of these components. The replenishment is done through diffusion. The heart component continuously pumps and that is the primary organ that gets the energy. If that fails, the body dies. Benefit of the algorithm would be that it is a equalibrium seeking machine by default. With only local rules with energy conservation constraint, there is less room for making things blow up. I know this will take more time than just having set of math equations but perhaps it is kinda thing where itself can be marketed as a feature.
For instance, let's imagine following silhouette. Energy (blood) grid will flow through this grid. Nutrients will be diffused across this grid.
So, we would model different areas of the body. Like muscles (orange), brain (gray) and circulatory system (red).
In this view, we are not really growing this organism from single pixel like we were planning but we are laying things out manually (i.e. by drawing the blueprint by hand).
Growing it out of single pixel would be moonshot goal but that's a rabbit hole I don't want to get into right now. Let's just draw the blueprint ourselves.
The trick here is that blood flow is simulated in 2D space. The main logic here is that heart has 2 compartment which allows blood circulation (not diffusion).
So, when simulating (i.e. fragment shader over time using local rules), we should be able to actually see the heart beat.
Then, each muscles will have ID and aggregation shader will query the amount of energy each muscle is getting. Then, if there is not much energy left, the body (i.e. state machine will adjust intensity.
Can we do the same without simulating the blood circulation in 2D grid?
Of course any function can be approximated. However, the math gets complicated. That is we not only need to track the magnitude but also the standard deviation and the distribution. By laying out a physical barriers (shader local rules) and quantization (0..255), we restrict the search space enough for us to easily play around with.
One, there is no arbitrary real number space (unless of course we use floating point texture types), and functions are not continuous. So the equations are rather limited.
Physical limitation (distance between nodes and rate at which the information can reach, energy conservation constraint), provides natural rate limiting of information delivery.
We've done this for tree growth simulation by layering in nutrients and energy layers. This allowed for growth simulation to produce sound tree structures from single cell.
Impact of change is visually inspectable and explainable.
Most importantly, this provides human engineer a feedback loop which gets them fired up.
Pixel: This is a real and coherent direction. I think the core of your idea is not really "simulate blood accurately." It is "build a spatial internal physiology substrate" so behavior emerges from local transport, storage, and consumption rules. That is a strong idea, and fits your project unusually well. What you are proposing gives you:
a body that has inside structure
local failure modes
time delay between intake and usable action
visual causality
a system that is easier to tune by inspection than a giant coupled equation set.
That is all genuinely valuable.
Sprited Dev: However, this is going into the Type 3 terratory. We decisively postponed it to Type 3 (see post). We need to stay focused on prototyping a fake being that behaves like a living character. It is prototype that will showcase that this idea can work. Not the final product. We should stay focused on this current focus (i.e. proof of concept). We don't need a full living being. We need something that feels real for first 2 minutes.
What can we do at this time?
Let's for now assume that we had grid-simulation of:
part masks (brain, muscles, etc.)
energy map
nutrient map
What we would do is to query the oxygen map with the part-masks. Then use those go gate actions and such.
Assuming energy is preserved per parts, we can assign a single value for each high level parts. Let's first define parts:
Heart: Blood circulator. Moderates blood pressure
Stomach: When food is digested, glucose, amino acids and fatty acids are absorbed into blood stream (immediate energy)
Excess glucose gets stored in liver and muscles ("medium speed energy").
Extra glucose and other materials get stored as fat in:
abdomen
thighs
arms
organs (visceral fat)
Hormones control which region store more. Insulin, Cortisol and Sex Hormones (estrogen, Testosterone). High insulin promotes fat storage everywhere. High cortisol biases storage towards abdominal fat. Estrogen more storage in hips and thighs.
Blood flow: regions with more blood flow get more nutirents. More nutrients mean more storage opportunity.
Receptor density: Fat cells in different regions respond differently. Some are more sensitive to store fat signals. Some are more resistant to release fat.
Genetics determines distribution patterns. Apple shape or pear shape.
Fat cells can grow (hypertrophy) or new fat cell can form (hyperplasia).
Fat storage is distributed + biased, not centrally controlled.
Unused materials is expelled.
Muscle: Can consume Glucose, Fatty Acids and stored glycogen (local storage). It can use oxygen (aerobic, efficient, and sustainable). Or it can be Anaerobic (without enough oxygen), where it uses glucose only, inefficient, and produces lactate and works short bursts.
- So it can run witout oxygen but not sustainably.
Brain: Container for mentally taxing actions.
Brain needs constant energy.
Primarily uses glucose
Can use ketones (during fasting)
CANNOT operate without oxygen (very quickly fails).
Lung: We need lung to provide oxygen.
Summary: We have abstraction--heart (transport), stomach (nutrient), muscle (movement), lung (oxygen) and brain (cognitive). Imagine these as nodes that interacts with each other.
Let's diagram this.
Each of these nodes require Nutrient, Oxygen levels. Those will be variables.
Nutrient
Oxygen
In each tick, we will simulate the flow of nutrients and oxygen to these areas. Heart rate variable will be used to control metabolic rate and what not.
Variables
Let's define these variables more formally.
Nutrients (per node): Nutrient available at the node to be used.
Oxygen (per node): Oxygen available at the node to be used.
(Out of Scope)
Nutrients Pull(per node): Represents the current pull for nutrients at node.(Out of Scope)
Oxygen Pull(per node): Represents the current pull for oxygen at node.Heart Rate (global): Helps moderate the speed of simulation.
We also need to add some hormones.
Arousal (bodily, per node): How activated the organism is. When low, it is sleepy and sluggish. When high, it is alert and intense.
Valence (global): negative (sad, distressed) vs positive (happy, content).
Bond (global): Attachment, trust, social warmth (lonely state driver?)
Motivation (mental, global): Willingness to act. When low, they are passive, idle. Otherwise, exploratory and active. If you are low on motivation and high on arousal, you are "anxious but frozen."
Stress (short-term, per node): Short-term urgency signal. Cortisol equivalent. Perhaps we model it per node.
Let's also define some derived variables:
Hunger (global): Derived from nutrient level and nutrient pull level. Also there is biological clock that increases these values. Trigger for food seeking and eating.
Fatigue (global): Low energy, low nutrients and low persisted oxygen, stress. Trigger for resting.
Curiosity (global): Drives exploration. Derived by positivity, bond, etc.
Great, now we have the variables set up. Let's discuss how these variables will map induce states.
Connecting the Dots
We now need to decide how these variables will be exposed to the model (the brain powered by LLM), and how the model will trigger actions.
We will also model how "body" will react to these variables. Say, if the digital being is running and has no more energy left, it will have to transition its state to stopping the run.
Let's draw out encapsulation diagram that pictures this interaction.
This diagram explains that most of the body variables are contained within the body enclosure and only few variables are exposed. State machine is like the subconscious autonomous machine which is program that runs on top of body that modulates things and does it. Then it will ask the model for next action when the conditions are met and handle requests from the brain (i.e. the model).
Let's pause it here. We had a good exercise. We should take some breather.
-- Sprited Dev 🐛



