Skip to content

Commit

Permalink
Ensure recovery from NaN circularity and user satisfactions indices
Browse files Browse the repository at this point in the history
  • Loading branch information
porst17 committed Dec 19, 2023
1 parent 7249b57 commit 78813d8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@ async function init(): Promise<CircularEconomyApi> {
circularityIndexElement.innerText = `${(circularityIndex * 100).toFixed(
1,
)}%`;
if (!Number.isFinite(circularityIndexTarget)) {
// Reset to make it possible to recover from NaN
circularityIndex = 0.0;
}

const userSatisfactionTarget =
phonesInUse < phoneGoal
Expand All @@ -426,6 +430,10 @@ async function init(): Promise<CircularEconomyApi> {
userSatisfactionElement.innerText = `${(userSatisfaction * 100).toFixed(
1,
)}%`;
if (!Number.isFinite(userSatisfactionTarget)) {
// Reset to make it possible to recover from NaN
userSatisfaction = 0.0;
}
}

function stepSimulation(deltaMs: number) {
Expand Down

0 comments on commit 78813d8

Please sign in to comment.