|
1 | 1 | from agents import Direction |
| 2 | +from agents import ReflexVacuumAgent, ModelBasedVacuumAgent, TrivialVacuumEnvironment |
2 | 3 |
|
3 | 4 | def test_move_forward(): |
4 | 5 | d = Direction("up") |
@@ -38,3 +39,26 @@ def test_add(): |
38 | 39 | assert l1.direction == Direction.U |
39 | 40 | assert l2.direction == Direction.D #fixed |
40 | 41 |
|
| 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