Anpassungen REQUIRE_FULL_SOLVE
This commit is contained in:
parent
789b2db221
commit
c0aafe41b4
@ -49,7 +49,7 @@ Der Beispielagent kann Rechenaufgaben lösen, dabei ist das Rätsel eine einfach
|
|||||||
"question": "x * y =",
|
"question": "x * y =",
|
||||||
"solutions_before": []
|
"solutions_before": []
|
||||||
},
|
},
|
||||||
"solution": null,
|
"solution": [],
|
||||||
"data": [
|
"data": [
|
||||||
{
|
{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
|
@ -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.
|
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.
|
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 <http://localhost:8080/docs/ums/agent/agent.html#BasicAgent.before_response>).
|
Ein Agent kann eine Antwort aber auch nicht nur stoppen, sondern auch für später aufheben (via <http://localhost:8080/docs/ums/agent/agent.html#BasicAgent.before_response>).
|
||||||
So kann ein Agent z.B. auf die Lösung einer Unteraufgabe warten und erst anschließend seine Antwort an das Management senden.
|
So kann ein Agent z.B. auf die Lösung einer Unteraufgabe warten und erst anschließend seine Antwort an das Management senden.
|
||||||
|
|
||||||
|
@ -17,7 +17,9 @@ services:
|
|||||||
# limit to prevent messages in never ending cycles
|
# limit to prevent messages in never ending cycles
|
||||||
- MESSAGE_MAX_CONTACTS=100
|
- MESSAGE_MAX_CONTACTS=100
|
||||||
# wait for all extraction agents to return results before solving a riddle
|
# 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)
|
# how to access management (the host name is the name of the service in this file)
|
||||||
- MANAGEMENT_URL=http://management
|
- MANAGEMENT_URL=http://management
|
||||||
# *register* the agents to the management
|
# *register* the agents to the management
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
# https://www.gnu.org/licenses/gpl-3.0.txt
|
# https://www.gnu.org/licenses/gpl-3.0.txt
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from typing import Callable
|
from typing import Callable, List
|
||||||
|
|
||||||
from ums.agent import GatekeeperAgent
|
from ums.agent import GatekeeperAgent
|
||||||
from ums.utils import Riddle, RiddleSolution, AgentMessage
|
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!
|
# do not send a response, if this is not a calculator riddle!
|
||||||
return not self.stop_response
|
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
|
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
|
# first check for errors
|
||||||
if solution.solution == "Error":
|
if solution.solution == "Error":
|
||||||
solution.accepted = True
|
solution.accepted = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user