Explore when a high-risk aggressive strategy produces a greater reproductive payoff than playing it safe.
Strategy A · Play It Safe
Die roll
Outcome
Payoff
1
Mating opportunity
+1
2–6
No mating opportunity
0
No injury risk.
Strategy B · Take the Risk
Die roll
Outcome
Payoff
1–2
Wins competition
+3
3–4
Loses competition
0
5–6
Seriously injured
Skip 1 round
Injured individuals miss subsequent opportunities.
Simulation settings
Individuals per strategyNumber of roundsSafe success rewardRisky success rewardRounds skipped after injuryAdditional injury penalty (offspring-equivalent)
Results
Safe: mean payoff—
Risky: mean net payoff—
Risky advantage—
Risky wins across simulations—
Cumulative mean payoff per individual
SafeRisky
Distribution of individual outcomes
Teaching notes & assumptions
Every active individual rolls an independent fair six-sided die each round. A safe player succeeds on 1; a risky player succeeds on 1–2, loses on 3–4, and is injured on 5–6. Injuries prevent participation in the specified number of subsequent rounds. Each individual retains the same strategy across all rounds. The model does not simulate death, population growth, inheritance, or competition between simulated individuals. A user-defined additional injury penalty is subtracted from net payoff; negative net payoffs are possible and are not literally negative numbers of offspring.
Theoretical immediate payoff per active round is (safe reward)/6 for Strategy A and (risky reward − injury penalty)/3 for Strategy B. Because injuries cause missed rounds, these immediate values are not the full multi-round expectations. The model illustrates a possible evolutionary trade-off; it does not establish that aggression is always adaptive.
(()=>{‘use strict’;const $=id=>document.getElementById(id),form=$(‘form’);const f=x=>Number.isFinite(x)?x.toFixed(2):’—’;function read(){let p={};for(let k of [‘n’,’rounds’,’safe’,’risk’,’skip’,’cost’]){let field=form.elements.namedItem(k);if(field.value.trim()===”)throw Error(‘Please fill in every setting.’);p[k]=Number(field.value);if(!Number.isFinite(p[k])||p[k]Number(field.max))throw Error(‘Please use values within the indicated ranges.’)}if(p.n<1||p.rounds<1||!Number.isInteger(p.n)||!Number.isInteger(p.rounds)||!Number.isInteger(p.skip))throw Error('Individuals, rounds and skipped rounds must be whole numbers.');return p}function sim(p,keep){let a=new Float64Array(p.n),b=new Float64Array(p.n),miss=new Uint16Array(p.n),sa=[0],sb=[0],ta=0,tb=0;for(let t=0;t<p.rounds;t++){for(let i=0;i<p.n;i++){if(Math.random()<1/6){a[i]+=p.safe;ta+=p.safe}if(miss[i]){miss[i]–;continue}let roll=Math.floor(Math.random()*6);if(roll=4){b[i]-=p.cost;tb-=p.cost;miss[i]=p.skip}}sa.push(ta/p.n);sb.push(tb/p.n)}return{sa,sb,ma:ta/p.n,mb:tb/p.n,a:keep?Array.from(a):null,b:keep?Array.from(b):null}}function chart(z,p){const svg=$(‘chart’),W=800,H=330,L=65,R=25,T=18,B=48;let low=Math.min(0,…z.sa,…z.sb),high=Math.max(0,…z.sa,…z.sb);if(low===high)high=low+1;let x=t=>L+(W-L-R)*t/p.rounds,y=v=>T+(H-T-B)*(high-v)/(high-low);let s=”;for(let j=0;j<=5;j++){let v=low+(high-low)*j/5,Y=y(v);s+=`${f(v)}`}for(let j=0;j<=5;j++){let t=Math.round(p.rounds*j/5);s+=`${t}`}function path(arr){return arr.map((v,i)=>(i?’L’:’M’)+x(i).toFixed(2)+’,’+y(v).toFixed(2)).join(‘ ‘)}s+=`Round`;svg.innerHTML=s}function histogram(arr,title,color){let min=Math.min(…arr),max=Math.max(…arr);if(min===max)max=min+1;let bins=Array(15).fill(0);for(let v of arr)bins[Math.min(14,Math.floor((v-min)/(max-min)*15))]++;let peak=Math.max(1,…bins);let section=document.createElement(‘div’);section.innerHTML=`
${title}
${bins.map(v=>``).join(”)}
${f(min)}${f(max)}
`;return section}function show(z,p,win,repeated){$(‘meanSafe’).textContent=f(z.ma);$(‘meanRisk’).textContent=f(z.mb);$(‘difference’).textContent=(z.mb-z.ma>=0?’+’:”)+f(z.mb-z.ma);$(‘winRate’).textContent=win===null?’—’:(win*100).toFixed(1)+’%’;chart(z,p);let dist=$(‘distributions’);dist.replaceChildren();if(z.a){dist.append(histogram(z.a,’Play It Safe’,’#247e91′),histogram(z.b,’Take the Risk’,’#d78332′))}else{dist.textContent=’Individual distributions are displayed for a single simulated population.’}let winner=z.mb>z.ma?’the risky strategy’:z.mb(reps===1?2000000:100000))throw Error(reps===1?’Limit individuals × rounds to 2 million.’:’For 1,000 simulations, limit individuals × rounds to 100,000.’);if(reps===1){show(sim(p,true),p,null,false);return}let sa=Array(p.rounds+1).fill(0),sb=Array(p.rounds+1).fill(0),ma=0,mb=0,wins=0;for(let i=0;iz.ma)wins++;for(let j=0;jx/1000),sb:sb.map(x=>x/1000),ma:ma/1000,mb:mb/1000},p,wins/1000,true)}catch(e){$(‘error’).textContent=e.message}}form.addEventListener(‘submit’,e=>{e.preventDefault();run(1)});$(‘repeat’).addEventListener(‘click’,()=>run(1000));$(‘reset’).addEventListener(‘click’,()=>{form.reset();run(1)});run(1)})();