summaryrefslogtreecommitdiff
path: root/src/simulation/actions.test.js
diff options
context:
space:
mode:
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([]);
+});