import {maximumSpeedMultiplier} from './ecology/movement.js?v=45'; import {basalMetabolismKJPerDay} from './ecology/metabolism.js?v=45'; const clamp=(v,a,b)=>Math.max(a,Math.min(b,v)); export const sizeSpeedBoost=maximumSpeedMultiplier; export const staminaLimit=(mass,gene)=>gene*Math.max(.2,mass/3); // Recovery is defined as a fraction of the individual's current stamina capacity per day. // The genome trait therefore controls recovery time without making large bodies take many days // simply because their absolute stamina pool is larger. export const staminaRecoveryFractionPerDay=(mass,gene)=>clamp((.46+.32*gene)*Math.pow(Math.max(.05,mass/3),-.035),.62,1.45); // Sprint/escape/chase drain is likewise capacity-relative. Routine travel does not consume // sprint stamina; only locomotion above the routine gait is charged here. export const sprintStaminaFractionPerDay=(speed,routineSpeed)=>.72+.48*clamp(speed/Math.max(1,routineSpeed)-1,0,2); // Returns kJ/day when speed is m/day. export const locomotionCost=(mass,speed)=>.018*Math.pow(Math.max(mass,.001),.684)*Math.max(0,speed); export const thermalFitness=(temperature,preferred,tolerance)=>Math.exp(-0.5*(((temperature-preferred)/Math.max(1,tolerance))**2)); export const metabolismKJPerDay=basalMetabolismKJPerDay; export const decayRate=temperature=>.018*Math.pow(1.88,(temperature-20)/10);