Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
SPADE-BDI
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jpalanca
SPADE-BDI
Commits
00928232
Commit
00928232
authored
Mar 27, 2019
by
serfrape
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjust compatibility with spade 3.1.0 and add examples
parent
54799e60
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
5 deletions
+71
-5
boss.asl
examples/boss.asl
+19
-0
control.py
examples/control.py
+32
-0
ejemplo.py
examples/ejemplo.py
+3
-3
slave.asl
examples/slave.asl
+13
-0
bdi.py
spade_bdi/bdi.py
+4
-2
No files found.
examples/boss.asl
0 → 100644
View file @
00928232
!start.
type(dec).
+!start <-
-start;
!obj2.
+!obj2: type(inc) <-
.send("slave_1@localhost", tell, incrementar(0));
.send("slave_2@localhost", tell, incrementar(0));
.wait(2000);
!obj2.
+!obj2: type(dec) <-
.send("slave_1@localhost", tell, decrementar(0));
.send("slave_2@localhost", tell, decrementar(0));
.wait(2000);
!obj2.
\ No newline at end of file
examples/control.py
0 → 100644
View file @
00928232
from
spade_bdi.bdi
import
BDIAgent
from
spade.template
import
Template
from
spade.behaviour
import
PeriodicBehaviour
from
datetime
import
datetime
from
spade.agent
import
Agent
class
BossAgent
(
BDIAgent
):
async
def
setup
(
self
):
template
=
Template
(
metadata
=
{
"performative"
:
"BDI"
})
self
.
add_behaviour
(
self
.
BDIBehaviour
(),
template
)
template
=
Template
(
metadata
=
{
"performative"
:
"Modify"
})
self
.
add_behaviour
(
self
.
Modify
(
period
=
5
,
start_at
=
datetime
.
now
()),
template
)
class
Modify
(
PeriodicBehaviour
):
async
def
run
(
self
):
tipo
=
self
.
agent
.
bdi
.
get_belief_value
(
"type"
)[
0
]
if
tipo
==
'inc'
:
self
.
agent
.
bdi
.
set_belief
(
'type'
,
'dec'
)
else
:
self
.
agent
.
bdi
.
set_belief
(
'type'
,
'inc'
)
b
=
BDIAgent
(
"slave_1@localhost"
,
"bdisimple"
,
"slave.asl"
)
b
.
start
()
c
=
BDIAgent
(
"slave_2@localhost"
,
"bdisimple3"
,
"slave.asl"
)
c
.
start
()
a
=
BossAgent
(
"Boss@localhost"
,
"bdiboss"
,
"boss.asl"
)
a
.
start
()
print
(
"started"
)
examples/ejemplo.py
View file @
00928232
...
...
@@ -6,7 +6,7 @@ from spade.agent import Agent
class
ExampleAgent
(
BDIAgent
):
def
setup
(
self
):
async
def
setup
(
self
):
template
=
Template
(
metadata
=
{
"performative"
:
"BDI"
})
self
.
add_behaviour
(
self
.
BDIBehaviour
(),
template
)
template
=
Template
(
metadata
=
{
"performative"
:
"B1"
})
...
...
@@ -38,8 +38,8 @@ class ExampleAgent(BDIAgent):
tipo
=
self
.
agent
.
bdi
.
get_belief_value
(
"tipo"
)[
0
]
if
tipo
==
'inc'
:
self
.
agent
.
bdi
.
set_belief
(
'tipo'
,
'dec'
)
#
else:
#
self.agent.bdi.set_belief('tipo', 'inc')
else
:
self
.
agent
.
bdi
.
set_belief
(
'tipo'
,
'inc'
)
a
=
ExampleAgent
(
"Agent@localhost"
,
"bditest"
,
"ejemplo.asl"
)
...
...
examples/slave.asl
0 → 100644
View file @
00928232
contador(0).
+incrementar(Inc) <-
.print("increasing");
?contador(X);
-+contador(X+1);
-incrementar(_).
+decrementar(Dec) <-
.print("decreasing");
?contador(X);
-+contador(X+1);
-decrementar(_).
spade_bdi/bdi.py
View file @
00928232
...
...
@@ -16,7 +16,7 @@ PERCEPT_TAG = frozenset(
class
BDIAgent
(
Agent
):
def
setup
(
self
):
async
def
setup
(
self
):
template
=
Template
(
metadata
=
{
"performative"
:
"BDI"
})
self
.
add_behaviour
(
self
.
BDIBehaviour
(),
template
)
...
...
@@ -24,6 +24,7 @@ class BDIAgent(Agent):
# print("OVERRIDEN")
if
type
(
behaviour
)
==
self
.
BDIBehaviour
:
self
.
bdi
=
behaviour
# print("ADDING BDI BEHAVIOUR")
super
()
.
add_behaviour
(
behaviour
,
template
)
def
__init__
(
self
,
jid
,
password
,
asl
,
*
args
,
**
kwargs
):
...
...
@@ -46,7 +47,7 @@ class BDIAgent(Agent):
"args"
:
str
(
term
.
args
[
2
]
.
args
)})
msg
=
Message
(
to
=
receiver
,
body
=
body
,
metadata
=
mdata
)
self
.
agent
.
submit
(
self
.
send
(
msg
))
print
(
"SENT!!!"
)
#
print("SENT!!!")
yield
@self.actions.add
(
".custom_action"
,
1
)
...
...
@@ -155,6 +156,7 @@ class BDIAgent(Agent):
with
open
(
self
.
agent
.
asl_file
)
as
source
:
self
.
bdi_agent
=
self
.
env
.
build_agent
(
source
,
self
.
actions
)
self
.
bdi_agent
.
name
=
self
.
agent
.
jid
async
def
run
(
self
):
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment