From 0c6a121e85755be454bfd777f5091dc22be061a0 Mon Sep 17 00:00:00 2001 From: Timotheus Kampik Date: Sun, 30 Jun 2024 15:22:50 +0200 Subject: [PATCH] add additional test --- spec/src/agent/Agent.spec.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/spec/src/agent/Agent.spec.js b/spec/src/agent/Agent.spec.js index d3117b2..4142ee8 100644 --- a/spec/src/agent/Agent.spec.js +++ b/spec/src/agent/Agent.spec.js @@ -300,4 +300,34 @@ describe('Agent / next(), configuration object-based', () => { newAgent.next(newBeliefs2) expect(newAgent.beliefs.isSlippery.value).toBe(false) }) + + it('should correctly execute the EUMAS 2024 paper example', () => { + const beliefs = { + ...Belief('isRaining', false), + ...Belief('isSlippery', false) + } + + const plans = [ + Plan( + beliefs => beliefs.isRaining, + () => [{ action: 'take_umbrella' }] + ), + Plan( + beliefs => beliefs.isSlippery, + () => [{ action: 'dress_shoes_with_profile' }] + ) + ] + + const newAgent = new Agent('myAgent', beliefs, {}, plans) + expect(newAgent.next({ ...Belief('isRaining', true) })[0][0].action).toEqual('take_umbrella') + + const update = { + ...Belief('isRaining', true, 1), + ...Belief('isSlippery', true, 0) + } + const execution = newAgent.next(update) + expect(execution[0][0].action).toEqual('take_umbrella') + expect(execution[1][0].action).toEqual('dress_shoes_with_profile') + + }) })