diff --git a/tests/test_search.py b/tests/test_search.py index 04cb2db35..23f8b0f43 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -201,6 +201,50 @@ def GA_GraphColoringInts(edges, fitness): return genetic_algorithm(population, fitness) +def test_simpleProblemSolvingAgent(): + class vacuumAgent(SimpleProblemSolvingAgentProgram): + def update_state(self, state, percept): + return percept + + def formulate_goal(self, state): + goal = [state7, state8] + return goal + + def formulate_problem(self, state, goal): + problem = state + return problem + + def search(self, problem): + if problem == state1: + seq = ["Suck", "Right", "Suck"] + elif problem == state2: + seq = ["Suck", "Left", "Suck"] + elif problem == state3: + seq = ["Right", "Suck"] + elif problem == state4: + seq = ["Suck"] + elif problem == state5: + seq = ["Suck"] + elif problem == state6: + seq = ["Left", "Suck"] + return seq + + state1 = [(0, 0), [(0, 0), "Dirty"], [(1, 0), ["Dirty"]]] + state2 = [(1, 0), [(0, 0), "Dirty"], [(1, 0), ["Dirty"]]] + state3 = [(0, 0), [(0, 0), "Clean"], [(1, 0), ["Dirty"]]] + state4 = [(1, 0), [(0, 0), "Clean"], [(1, 0), ["Dirty"]]] + state5 = [(0, 0), [(0, 0), "Dirty"], [(1, 0), ["Clean"]]] + state6 = [(1, 0), [(0, 0), "Dirty"], [(1, 0), ["Clean"]]] + state7 = [(0, 0), [(0, 0), "Clean"], [(1, 0), ["Clean"]]] + state8 = [(1, 0), [(0, 0), "Clean"], [(1, 0), ["Clean"]]] + + a = vacuumAgent(state1) + + assert a(state6) == "Left" + assert a(state1) == "Suck" + assert a(state3) == "Right" + + # TODO: for .ipynb: """ 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