diff --git a/Example.md b/Example.md index b697dcf..e7d43d8 100644 --- a/Example.md +++ b/Example.md @@ -49,7 +49,7 @@ Der Beispielagent kann Rechenaufgaben lösen, dabei ist das Rätsel eine einfach "question": "x * y =", "solutions_before": [] }, - "solution": null, + "solution": [], "data": [ { "type": "text", diff --git a/Implement.md b/Implement.md index 4a9b25c..5baa0fd 100644 --- a/Implement.md +++ b/Implement.md @@ -43,6 +43,10 @@ Die Zusammenführung findet nur innerhalb von Rätseln mit der gleichen ID statt Falls `REQUIRE_FULL_EXTRACT=true` so muss sichergestellt werden, dass auch alle Agenten (also für jeden Datensatz) irgendwann eine Extraktion bestimmt wird, andernfalls wartet das Management ewig. Bei `REQUIRE_FULL_EXTRACT=false` bekommt der Agent zum Lösen ein Rätsel dann evtl. doppelt, jeweils mit weiteren Extraktionen. +Mit `REQUIRE_FULL_SOLVE` kann (ähnlich zu `REQUIRE_FULL_EXTRACT`) das Management angewiesen werden, von allen Agenten (in `AGENTS_SOLVE`) eine Lösung abzuwarten, bevor diese Lösungen (gebündelt) an den Gatekeeper zum Prüfen weitergeleitet werden. +Auch hier muss bei `REQUIRE_FULL_SOLVE=true` sichergestellt werden, dass alle Agenten auch (in `AGENTS_SOLVE`) irgendwann eine Lösung ausgeben. +Außerdem darf die Lösung von zwei Agenten nicht komplett identisch sein, d.h., wenn Lösung, Erklärung und benutzte Dateien einer Lösung gleich sind, so wird sie als die selbe Lösung angesehen und das Management würde z.B. auf eine *weitere* Lösung warten. + Ein Agent kann eine Antwort aber auch nicht nur stoppen, sondern auch für später aufheben (via ). So kann ein Agent z.B. auf die Lösung einer Unteraufgabe warten und erst anschließend seine Antwort an das Management senden. diff --git a/docker-compose.yml b/docker-compose.yml index 2ab8b86..1ddd2a1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,7 +17,9 @@ services: # limit to prevent messages in never ending cycles - MESSAGE_MAX_CONTACTS=100 # wait for all extraction agents to return results before solving a riddle - - REQUIRE_FULL_EXTRACT=false + - REQUIRE_FULL_EXTRACT=true + # wait for all solve agents to return a solutions before giving to gatekeeper + - REQUIRE_FULL_SOLVE=true # how to access management (the host name is the name of the service in this file) - MANAGEMENT_URL=http://management # *register* the agents to the management diff --git a/src/validate/agent.py b/src/validate/agent.py index bb657cb..cfbc297 100644 --- a/src/validate/agent.py +++ b/src/validate/agent.py @@ -9,7 +9,7 @@ # https://www.gnu.org/licenses/gpl-3.0.txt import re -from typing import Callable +from typing import Callable, List from ums.agent import GatekeeperAgent from ums.utils import Riddle, RiddleSolution, AgentMessage @@ -21,9 +21,12 @@ class SimpleSolveAgent(GatekeeperAgent): # do not send a response, if this is not a calculator riddle! return not self.stop_response - def handle(self, solution: RiddleSolution, riddle: Riddle) -> RiddleSolution: + def handle(self, solution: List[RiddleSolution], riddle: Riddle) -> List[RiddleSolution]: self.stop_response = False + # iterate over all poss. solutions + return [self._check_single_solution(s) for s in solution] + def _check_single_solution(self, solution:RiddleSolution) -> RiddleSolution: # first check for errors if solution.solution == "Error": solution.accepted = True