as i said, some i believe is organizational, with regard to using one loop per update type instead of one loop per update frequency (IE one loop for all stuff that updates every frame, one for all stuff that updates once per game second, one for stuff that updates once per game every minute, etc). or using a single loop that updates every frame, then calls the less frequent updates using conditional control flow.
but even with one loop, and separating the list of traps and the "where's my house" info from the player info, i'm still looking at a PC entity type with something like 90 update and check methods!
whether its OO and all in one place or not, it still seems like a lot. i mean, know its an in-depth sim, but ~90 types of updates and checks?
OTOH, i wrote down the name of each of the 99 methods, while counting them, just in case i had to post some examples <g>. while looking over the names, each seemed to be something that an entity must have - at least for this game.
different updates occur at different rates, once per frame, second, minute, hour, or day, and also at other intervals like 5 minutes, 10 minutes, 15 minutes, etc. all the game's update() routine does is increment the clock and then call the appropriate update routines. since it appears that it models or checks ~99 things in relation to a PC, it would seem that i can reduce the number of loops, but not the number of methods.
consolidating the many small loops into fewer larger loops would make changes like this easier. might be less cache friendly though.
and none of the check loops could be consolidated. in OO terms, they are basically methods of the "list of PCs" object. so they have to iterate through the list of PCs to do their checks, stuff like "who's the closest player to player X's house", and stuff like that.
here's some of the types of updates (in the order they appear in the code):
WARNING! LONG LIST!
nuke_mood_friends_of(A). severely reduces mood (a la the sims) of all players who are friends with NPC "A" (who just died).
run_bandmember. update for a PC under AI control. the game is single player, but the player can control multiple PCs, like a household in The Sims. the player can switch between PCs at any time by hitting TAB. PCs not being controlled by the player are controlled by AI. this is the update routine for when they are under AI control.
nuke_band_mood. severely reduces the mood of all PCs (called when a PC dies).
kill_bandmember. hey, every object needs a dispose, right?
try_move_rafts. part of this routine adds a raft's movement to a PCs movement (you can walk around on a raft in motion!) it also calls automap for each PC onboard.
model_falling. does what it says. applies gravity, calculates velocity, checks for impact or glancing blow bounce off wall type thing, stops fall when hit ground, applies damage, kills player if needed.
model_paddling fatigue. increases fatigue when you're paddling a raft.
model sneak detection. does LOS/LOF checks for being spotted while in sneak mode.
model fatigue decrease. due to resting or not moving / attacking, or undertaking low energy actions like stargazing.
model player attacks. increment attack counters, apply attack results at appropriate point through the attack, reset "attacking flag" when attack completed.
model band member surprise. surprise is modeled in encounters. surprise gives you a few seconds to move before your opponent can, or causes you to be unable to move for a few seconds while your opponent can. this updates those counters.
resolve animal attack. a section of this routine checks for a PC in the line of fire of an animal's attack, and if found, checks for hit, applies damage, and kills the player if needed. so this the equivalent of where the game's "damage PC entity" method gets called.
check for 100% fatigue. checks for fatigue hitting 100%. when fatigue hits 100%, if the PC is doing an action (swimming, moving cross country, fixing a bow, gathering berries, etc), the action is pushed on the PC action stack. a "rest" action is then started. the rest action is designed to interrupt other actions, and therefore automatically pops the action stack if needed on completion.
check rock shelter encounters. checks for player near rock shelter. generates encounter if needed. removes encountered nps/animals, and resets "encounter checked" flag when no PCs nearby any longer. the game has 5000 rock shelters based on real world frequency distribution and the size of the game world.
check cave encounters - same idea, for caves. the game has 60,000 caves based on real world frequency distribution and the size of the game world.
check hut encounters - same idea, for huts. the game has 18,000 huts based on estimated population densities, the percentage of the population staying in one place at any given time, and the size of the game world.
check hut takeovers - checks for abandoned huts near the PCs. gives them the option to take them over. huts are typically "abandoned" because the player has killed or chased off the occupants.
model climbing animals - one of the actions in the game is "climb tree". if you get an encounter with a wild animal, you can climb a tree and wait for them to wander off. but some animals can climb up trees after you. this checks each PC to see of they're up a tree and in an encounter with an animal that can climb trees. if so, it forces them to jump to the ground to get away from the animal, at which point combat resumes as usual, although the player can always climb a tree again, not that it will do much good.
model fatigue due to damage - most shooters don't model this. but you DO get tired faster when wounded. this might be an example of one of the update methods required due to the depth of the simulation.
model fatigue due to encumbrance - another real world effect most shooters don't model.
model effects of intoxicants - somewhat akin to potion effects in skyrim etc.
make torches go out - an update on a PCs time limited inventory item.
check caveman encounters. encounter checks are done for each PC or group of PCs.
reduce water
reduce food
reduce sleep
affect mood
check animal encounters
reduce hygiene due to movement
model carried food spoilage
model raids on PC's caves / rock shelters / huts
model exposure
model heatstroke
model wear and tear of clothing and similar equipment. all objects in the game have a quality level 0-100%, and wear out / weather away.
check quest encounters. does any encounter checks needed for all active quests of all PCs, and generates the encounters. i know for sure oblivion does this.
model intoxicant OD
do wildfire. checks if PCs are in a map square with a wildfire. if so, does an animation of the player caught in the wildfire, applies damage, kills player if needed.
mood boost nature lovers: each PC and NPC has 3 interests. doing stuff related to your interests boosts your mood. this does a mood boost on all PCs with nature as an interest, who are outside.
reduce hygiene
model dehydration
model damage from disease
reduce food for cold weather (burn more calories to maintain body temp).
model drowning in floods - the game tracks water tables and flooding, driven by the weather engine.
model background radiation (IE old age - permanent reduction of hit points, until you eventually die).
zero god relations - move relations with the gods towards zero.
model skill reduction - skills go down over time. you must practice / research / refresh to keep up. only seen this when you get locked up in oblivion.
model starvation
model getting sick (catching an illness, not the effects thereof).
reduce social stat (a la the sims)
add band member - add a new PC to the list of PC entities.
selected band member - returns true if the player selected a PC with the spacebar to interact with them.
mood boost nearbys - does mood boost on all nearby PCs when a PC does an action like sing, play flute, or play drums.
talk to band member - does a check to stop talking if they die. "jeez, i didn't think i was that boring!" <g>.
listen to band member - does a check to stop listening if they die.
rungame - contains code to reset all PC's "moved" flags, and reset horizontal velocities for PCs not falling. basically clearing flags before calling update_all();
and thats it for the update type stuff. a few things in there may not technically be PC updates. it looks like a lot of the methods are checks such as "band member in way of band member", "band member near dropped object", "someone paddling" - returns true if a PC is aboard a raft and is doing the "paddle" action, and so on.
there are also render calls for drawing a PC in the world, on the world map, and the local map.
the AI uses six different type of target selection routines that iterate though the list of PCs looking for potential targets. I'm surprised it isn't more, given that there's something like 14 types of AI in the game.