Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4bac571

Browse files
articuno12norvig
authored andcommitted
Added testcase for ReflexVacuumAgent and ModelBasedVacuumAgent (#394)
* Added testcase for agents.py * spacing around commas was wrong
1 parent 4548aae commit 4bac571

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/test_agents.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from agents import Direction
2+
from agents import ReflexVacuumAgent, ModelBasedVacuumAgent, TrivialVacuumEnvironment
23

34
def test_move_forward():
45
d = Direction("up")
@@ -38,3 +39,26 @@ def test_add():
3839
assert l1.direction == Direction.U
3940
assert l2.direction == Direction.D #fixed
4041

42+
def test_ReflexVacuumAgent() :
43+
# create an object of the ReflexVacuumAgent
44+
agent = ReflexVacuumAgent()
45+
# create an object of TrivialVacuumEnvironment
46+
environment = TrivialVacuumEnvironment()
47+
# add agent to the environment
48+
environment.add_thing(agent)
49+
# run the environment
50+
environment.run()
51+
# check final status of the environment
52+
assert environment.status == {(1,0):'Clean' , (0,0) : 'Clean'}
53+
54+
def test_ModelBasedVacuumAgent() :
55+
# create an object of the ModelBasedVacuumAgent
56+
agent = ModelBasedVacuumAgent()
57+
# create an object of TrivialVacuumEnvironment
58+
environment = TrivialVacuumEnvironment()
59+
# add agent to the environment
60+
environment.add_thing(agent)
61+
# run the environment
62+
environment.run()
63+
# check final status of the environment
64+
assert environment.status == {(1,0):'Clean' , (0,0) : 'Clean'}

0 commit comments

Comments
 (0)