summaryrefslogtreecommitdiff
path: root/life2/game/index.js
diff options
context:
space:
mode:
authorNicolas Paul <n@nc0.fr>2024-03-18 08:55:45 +0100
committerNicolas Paul <n@nc0.fr>2024-03-18 08:55:45 +0100
commit5b7be9c3b28701e3f62d56547345c226b5d64390 (patch)
tree5340bc71be3331067776f86272bf79b4f0484f30 /life2/game/index.js
parent86928ce3d140e0772f46ca5ca70339c7571586a6 (diff)
Add stats calculation within the game loop
This patch changes the behavior of the calculation loop of a board (nextState) to keep track of the changes that happened during the round (number of cells that died or were born in a given team). These stats may be accessed by called the getStats() method on a World instance, which returns a !Stats object: const world = Life2.World(...); // ... const stats = world.getStats(); displayStats(stats); Close: https://github.com/nc0fr/life2/issues/8 Signed-off-by: Nicolas Paul <n@nc0.fr>
Diffstat (limited to 'life2/game/index.js')
-rw-r--r--life2/game/index.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/life2/game/index.js b/life2/game/index.js
index b8e8f9c..5d9277e 100644
--- a/life2/game/index.js
+++ b/life2/game/index.js
@@ -25,4 +25,4 @@ export {Board, Grid} from './board';
export {Cell} from './cell';
export {Rule, RuleFunction} from './rule';
export {RulesManager} from './rules_manager';
-export {World} from './world';
+export {Stats, World} from './world';