<?phpclassPerson{privatefloat$mentalEnergy=100.0;privatearray$decisionsToday=[];privatearray$habits=[];privatearray$decisionWeights=['trivial'=>0.5,// What socks to wear'minor'=>2.0,// What to eat for lunch'moderate'=>5.0,// Whether to go to the gym'major'=>15.0,// Whether to accept a job offer'critical'=>25.0// Whether to move to a new city];/** * Represents the person's ability to make a decision based on their current mental energy * and the complexity of previous decisions made that day */publicfunctionmakeDecision(string$type,string$context):?bool{if(!array_key_exists($type,$this->decisionWeights)){thrownew InvalidArgumentException("Unknown decision type");}// Check if this is a habitual decisionif($this->isHabitualDecision($context)){return$this->followHabit($context);}$energyCost=$this->calculateDecisionEnergyCost($type);// Apply decision fatigue factors$energyCost*=$this->getTimeFatigueFactor();$energyCost*=$this->getDecisionStackFactor();if($this->mentalEnergy<$energyCost){return$this->defaultToEasiestOption();}$this->mentalEnergy-=$energyCost;$this->decisionsToday[]=['type'=>$type,'context'=>$context,'energyCost'=>$energyCost,'timeOfDay'=>time()];return$this->evaluateOptions($type,$context);}/** * Calculate how much harder decisions become as the day progresses */privatefunctiongetTimeFatigueFactor():float{$hourOfDay=(int)date('H');return1+($hourOfDay/24)*0.5;}/** * Calculate how each subsequent decision becomes harder due to cognitive load */privatefunctiongetDecisionStackFactor():float{$recentDecisions=array_filter($this->decisionsToday,function($decision){returntime()-$decision['timeOfDay']<3600;// Within last hour});return1+(count($recentDecisions)*0.1);}/** * When mental energy is too low, default to whatever requires least energy */privatefunctiondefaultToEasiestOption():bool{// People tend to:// - Say "no" to new things// - Stick with defaults// - Choose whatever's presented first// - Postpone if possiblereturnfalse;}/** * Restore mental energy through rest */publicfunctionrest(int$minutes):void{$restorationRate=0.5;// Mental energy points per minute$this->mentalEnergy=min(100.0,$this->mentalEnergy+($minutes*$restorationRate));}/** * Convert a decision into a habit to reduce future mental load */publicfunctionformHabit(string$context,bool$defaultChoice):void{$this->habits[$context]=['choice'=>$defaultChoice,'strength'=>0];}/** * Strengthen a habit through repetition */privatefunctionstrengthenHabit(string$context):void{if(isset($this->habits[$context])){$this->habits[$context]['strength']=min(100,$this->habits[$context]['strength']+1);}}}