summaryrefslogtreecommitdiff
path: root/src/simulation/actions.test.js
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-11-10 21:53:01 -0600
committersanine <sanine.not@pm.me>2023-11-10 21:53:01 -0600
commit86e1ab63d25ed6387c3bc4f5c07e9e041a1c7823 (patch)
tree09501817f06a09ccf38ce0223d598626a9a5b061 /src/simulation/actions.test.js
parent8252de1deb1a677a71108f6c5f8705d7c04a63fe (diff)
implement take_flag action
Diffstat (limited to 'src/simulation/actions.test.js')
-rw-r--r--src/simulation/actions.test.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/simulation/actions.test.js b/src/simulation/actions.test.js
index c5f35be..e0b29dc 100644
--- a/src/simulation/actions.test.js
+++ b/src/simulation/actions.test.js
@@ -8,6 +8,7 @@ const [
turn_left, turn_right,
place, trigger,
pretend_frozen, unfreeze,
+ take_flag,
...rest
] = actions;
@@ -246,3 +247,36 @@ test("unfreeze", () => {
expect(unfreeze.propose({agents}, agent1, [0])).toEqual([]);
});
+
+
+test("take flag", () => {
+ const agent = { id: 0, x: 0, y: 0, flags: { orientation: 'n' } };
+ const other1 = { id: 1, x: 0, y: -1, flags: { flag: true } };
+ const other2 = { id: 2, x: 0, y: 1, flags: { flag: false } };
+
+ const world = { agents: [ agent, other1, other2 ] };
+
+ expect(take_flag.propose(world, agent, [1])).toEqual([
+ { agent_changes: [
+ { agent_id: 1, flags: { flag: false } },
+ { agent_id: 0, flags: { flag: true } },
+ ]},
+ ]);
+
+ agent.flags.orientation = 's';
+ expect(take_flag.propose(world, agent, [1])).toEqual([
+ {
+ lattice_changes: [
+ {
+ x: 0, y: 1, from: 'flag', to: 'empty',
+ flags: { emit: [ 0, 0, 1, 0, 0, 0, 0, 0 ] },
+ },
+ ],
+ agent_changes: [
+ { agent_id: 0, flags: { flag: true } },
+ ]
+ },
+ ]);
+
+ expect(take_flag.propose(world, agent, [0])).toEqual([]);
+});