Commit 85f38e39 by serfrape

Support mutating BDI intentions buffer.

parent 47d798c5
from spade_bdi.bdi import BDIAgent from spade_bdi.bdi import BDIAgent
a = BDIAgent("ReceiverAgent@localhost", "receiverpasswd", "receiver.asl") a = BDIAgent("BDIReceiverAgent@localhost", "receiverpasswd", "receiver.asl")
a.start() a.start()
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
+!start <- +!start <-
.print("sending a message ..."); .print("sending a message ...");
.send("ReceiverAgent@localhost", achieve, hello("Hello World!")); .send("BDIReceiverAgent@localhost", achieve, hello("Hello World!"));
.print("sent a message"). .print("sent a message").
\ No newline at end of file
from spade_bdi.bdi import BDIAgent from spade_bdi.bdi import BDIAgent
a = BDIAgent("SenderAgent@localhost", "senderpasswd", "sender.asl") a = BDIAgent("BDISenderAgent@localhost", "senderpasswd", "sender.asl")
a.start() a.start()
...@@ -9,5 +9,5 @@ contador(0). ...@@ -9,5 +9,5 @@ contador(0).
+decrementar(Dec) <- +decrementar(Dec) <-
.print("decreasing"); .print("decreasing");
?contador(X); ?contador(X);
-+contador(X+1); -+contador(X-1);
-decrementar(_). -decrementar(_).
...@@ -11,7 +11,6 @@ from spade.behaviour import CyclicBehaviour ...@@ -11,7 +11,6 @@ from spade.behaviour import CyclicBehaviour
from spade.agent import Agent from spade.agent import Agent
from spade.template import Template from spade.template import Template
from spade.message import Message from spade.message import Message
from .ontology import X, Y, Z
PERCEPT_TAG = frozenset( PERCEPT_TAG = frozenset(
[pyson.Literal("source", (pyson.Literal("percept"), ))]) [pyson.Literal("source", (pyson.Literal("percept"), ))])
...@@ -92,7 +91,7 @@ class BDIAgent(Agent): ...@@ -92,7 +91,7 @@ class BDIAgent(Agent):
"""Set an agent's belief. If it already exists, updates it.""" """Set an agent's belief. If it already exists, updates it."""
new_args = () new_args = ()
for x in args: for x in args:
if type(x) == str: if type(x) == str:
new_args += (pyson.Literal(x),) new_args += (pyson.Literal(x),)
else: else:
new_args += (x,) new_args += (x,)
...@@ -225,10 +224,11 @@ class BDIAgent(Agent): ...@@ -225,10 +224,11 @@ class BDIAgent(Agent):
# self.agent.bdi_agent.call(trigger, goal_type, # self.agent.bdi_agent.call(trigger, goal_type,
# tagged_message, intention) # tagged_message, intention)
if self.agent.bdi_intention_buffer: if self.agent.bdi_intention_buffer:
for i in self.agent.bdi_intention_buffer: temp_intentions = deque(self.agent.bdi_intention_buffer)
for i in temp_intentions:
self.agent.bdi_agent.call(i[0], i[1], i[2], i[3]) self.agent.bdi_agent.call(i[0], i[1], i[2], i[3])
self.agent.bdi_agent.step() self.agent.bdi_agent.step()
self.agent.bdi_intention_buffer = deque() self.agent.bdi_intention_buffer.popleft()
else: else:
self.agent.bdi_agent.step() self.agent.bdi_agent.step()
......
# -*- coding: utf-8 -*-
"""Console script for spade_bdi."""
import sys
import click
@click.command()
def main(args=None):
"""Console script for spade_bdi."""
click.echo("Replace this message by putting your code into "
"spade_bdi.cli.main")
click.echo("See click documentation at http://click.pocoo.org/")
return 0
if __name__ == "__main__":
sys.exit(main()) # pragma: no cover
TEAM_NONE: int = 0
TEAM_ALLIED: int = 100
TEAM_AXIS: int = 200
PERFORMATIVE: str = "performative"
NAME: str = "name"
TYPE: str = "type"
TEAM: str = "team"
MAP: str = "map"
QTY: str = "qty"
ANGLE: str = "angle"
DISTANCE: str = "distance"
HEALTH: str = "health"
AMMO: str = "ammo"
DEC_HEALTH: str = "dec_health"
AIM: str = "aim"
SHOTS: str = "shots"
X: str = "x"
Y: str = "y"
Z: str = "z"
VEL_X: str = "velx"
VEL_Y: str = "vely"
VEL_Z: str = "velz"
HEAD_X: str = "headx"
HEAD_Y: str = "heady"
HEAD_Z: str = "headz"
FOV: str = "FOV"
PACKS: str = "PACKS"
MEDIC_SERVICE: str = "medic"
AMMO_SERVICE: str = "ammo"
BACKUP_SERVICE: str = "backup"
PERFORMATIVE_BDI: str = "bdi"
PERFORMATIVE_GAME: str = "game"
PERFORMATIVE_PACK_TAKEN: str = "pack_taken"
PERFORMATIVE_PACK: str = "pack"
PERFORMATIVE_SERVICES: str = "services"
PERFORMATIVE_INFORM: str = "inform"
PERFORMATIVE_PACK_LOST: str = "pack_lost"
PERFORMATIVE_SHOT: str = "shot"
PERFORMATIVE_SIGHT: str = "sight"
PERFORMATIVE_DATA: str = "data"
MANAGEMENT_SERVICE: str = "management"
PERFORMATIVE_INIT: str = "init"
PERFORMATIVE_OBJECTIVE: str = "objective"
PERFORMATIVE_GET: str = "get"
PERFORMATIVE_CFM: str = "cfm"
PERFORMATIVE_CFA: str = "cfa"
PERFORMATIVE_CFB: str = "cfb"
ACTION: str = "ACTION"
CREATE: str = "CREATE"
DESTROY: str = "DESTROY"
PERFORMATIVE_REGISTER_AGENT: str = "register_agent"
PERFORMATIVE_DEREGISTER_AGENT: str = "deregister_agent"
PERFORMATIVE_REGISTER_SERVICE: str = "register"
PERFORMATIVE_DEREGISTER_SERVICE: str = "deregister_service"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment