Skip to content

Commit fa7440f

Browse files
roberthoenignorvig
authored andcommitted
Add test for TableDrivenAgentProgram. (aimacode#749)
Fixes aimacode#748.
1 parent c13408d commit fa7440f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/test_agents.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,20 @@ def test_compare_agents() :
208208
assert performance_ReflexVacummAgent <= performance_ModelBasedVacummAgent
209209

210210

211+
def test_TableDrivenAgentProgram():
212+
table = {(('foo', 1),): 'action1',
213+
(('foo', 2),): 'action2',
214+
(('bar', 1),): 'action3',
215+
(('bar', 2),): 'action1',
216+
(('foo', 1), ('foo', 1),): 'action2',
217+
(('foo', 1), ('foo', 2),): 'action3',
218+
}
219+
agent_program = TableDrivenAgentProgram(table)
220+
assert agent_program(('foo', 1)) == 'action1'
221+
assert agent_program(('foo', 2)) == 'action3'
222+
assert agent_program(('invalid percept',)) == None
223+
224+
211225
def test_Agent():
212226
def constant_prog(percept):
213227
return percept

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy