Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for table_driven_agent_program and Random_agent_program #770

Merged
merged 8 commits into from
Feb 27, 2018
16 changes: 16 additions & 0 deletions tests/test_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ def test_add():
assert l1.direction == Direction.U
assert l2.direction == Direction.D

def test_RandomAgentProgram() :
#create a list of all the actions a vacuum cleaner can perform
list = ['Right', 'Left', 'Suck', 'NoOp']
# create a program and then an object of the RandomAgentProgram
program = RandomAgentProgram(list)

agent = Agent(program)
# create an object of TrivialVacuumEnvironment
environment = TrivialVacuumEnvironment()
# add agent to the environment
environment.add_thing(agent)
# run the environment
environment.run()
# check final status of the environment
assert environment.status == {(1,0): 'Clean' , (0,0): 'Clean'}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a space after the commas in the tuples.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The case is same in both the cases t.e, in randomAgentProgram and randomVacuumAgent. Both do choose randomly from the given actions. But as the run method executes the step method a 1000 times, so there is almost 100 percent chance that the assertion will be true always. However, another way of doing this can be declaring actions as an attribute of the function statement and then just executing the step statement once and checking if the action does belong to the given list of actions then the program runs fine. @MrDupin Comments?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, sounds good.

There are some conflicts with the README now, can you fix them? Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed them @MrDupin


def test_RandomVacuumAgent() :
# create an object of the RandomVacuumAgent
Expand All @@ -67,6 +82,7 @@ def test_RandomVacuumAgent() :
# check final status of the environment
assert environment.status == {(1,0):'Clean' , (0,0) : 'Clean'}


def test_TableDrivenAgent() :
#create a table that would consist of all the possible states of the agent
loc_A, loc_B = (0, 0), (1, 0)
Expand Down