From 78f2f5f4b1ccd58bbdef0d5e5d2dd026ac4ad668 Mon Sep 17 00:00:00 2001 From: sanine Date: Sat, 11 Nov 2023 13:58:56 -0600 Subject: add postprocessing rule to freeze agents --- src/simulation/postprocess.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/simulation/postprocess.js (limited to 'src/simulation/postprocess.js') diff --git a/src/simulation/postprocess.js b/src/simulation/postprocess.js new file mode 100644 index 0000000..d50839e --- /dev/null +++ b/src/simulation/postprocess.js @@ -0,0 +1,18 @@ +'use strict'; + +export const postprocess = [ + (world) => ({ + ...world, + agents: world.agents.map(a => { + const {x, y} = a; + if ( + world.lattice[y][x].type === 'mutable' || + world.lattice[y][x].type === 'active' + ) { + return { ...a, flags: {...a.flags, frozen: true } }; + } else { + return a; + } + }), + }), +]; -- cgit v1.2.1