FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix #731: Add table and tests for TableDrivenVacuumAgent by apb7 · Pull Request #732 · aimacode/aima-python · GitHub

Repository navigation

2 changes: 1 addition & 1 deletion README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Here is a table of algorithms, the figure, name of the algorithm in the book and
| 2 | Model-Based-Vacuum-Agent | `ModelBasedVacuumAgent` | [`agents.py`][agents] | Done | Included |
| 2.1 | Environment | `Environment` | [`agents.py`][agents] | Done | Included |
| 2.1 | Agent | `Agent` | [`agents.py`][agents] | Done | Included |
| 2.3 | Table-Driven-Vacuum-Agent | `TableDrivenVacuumAgent` | [`agents.py`][agents] | | Included |
| 2.3 | Table-Driven-Vacuum-Agent | `TableDrivenVacuumAgent` | [`agents.py`][agents] | Done | Included |
| 2.7 | Table-Driven-Agent | `TableDrivenAgent` | [`agents.py`][agents] | | Included |
| 2.8 | Reflex-Vacuum-Agent | `ReflexVacuumAgent` | [`agents.py`][agents] | Done | Included |
| 2.10 | Simple-Reflex-Agent | `SimpleReflexAgent` | [`agents.py`][agents] | | Included |
Expand Down
12 changes: 6 additions & 6 deletions agents.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ def TableDrivenVacuumAgent():
((loc_A, 'Dirty'),): 'Suck',
((loc_B, 'Clean'),): 'Left',
((loc_B, 'Dirty'),): 'Suck',
((loc_A, 'Clean'), (loc_A, 'Clean')): 'Right',
((loc_A, 'Clean'), (loc_A, 'Dirty')): 'Suck',
# ...
((loc_A, 'Clean'), (loc_A, 'Clean'), (loc_A, 'Clean')): 'Right',
((loc_A, 'Clean'), (loc_A, 'Clean'), (loc_A, 'Dirty')): 'Suck',
# ...
((loc_A, 'Dirty'), (loc_A, 'Clean')): 'Right',
((loc_A, 'Clean'), (loc_B, 'Dirty')): 'Suck',
((loc_B, 'Clean'), (loc_A, 'Dirty')): 'Suck',
((loc_B, 'Dirty'), (loc_B, 'Clean')): 'Left',
((loc_A, 'Dirty'), (loc_A, 'Clean'), (loc_B, 'Dirty')): 'Suck',
((loc_B, 'Dirty'), (loc_B, 'Clean'), (loc_A, 'Dirty')): 'Suck'
}
return Agent(TableDrivenAgentProgram(table))

Expand Down
15 changes: 14 additions & 1 deletion tests/test_agents.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from agents import Direction
from agents import Agent
from agents import ReflexVacuumAgent, ModelBasedVacuumAgent, TrivialVacuumEnvironment, compare_agents,\
RandomVacuumAgent
RandomVacuumAgent, TableDrivenVacuumAgent


random.seed("aima-python")
Expand Down Expand Up @@ -94,6 +94,19 @@ def test_ModelBasedVacuumAgent() :
assert environment.status == {(1,0):'Clean' , (0,0) : 'Clean'}


def test_TableDrivenVacuumAgent() :
# create an object of the TableDrivenVacuumAgent
agent = TableDrivenVacuumAgent()
# create an object of the 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'}


def test_compare_agents() :
environment = TrivialVacuumEnvironment
agents = [ModelBasedVacuumAgent, ReflexVacuumAgent]
Expand Down

Back | FazBrowse Home | New Git URL