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
4
Issues
4
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
serfrape
SPADE-BDI
Commits
db843562
Commit
db843562
authored
Jun 12, 2019
by
serfrape
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to send tell messages with no args
parent
9df8a2dc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
24 deletions
+12
-24
bdi.py
spade_bdi/bdi.py
+12
-24
No files found.
spade_bdi/bdi.py
View file @
db843562
...
...
@@ -103,13 +103,9 @@ class BDIAgent(Agent):
else
:
self
.
agent
.
bdi_intention_buffer
.
append
((
pyson
.
Trigger
.
removal
,
pyson
.
GoalType
.
belief
,
belief
,
pyson
.
runtime
.
Intention
()))
# self.agent.bdi_agent.call(pyson.Trigger.removal, pyson.GoalType.belief, belief,
# pyson.runtime.Intention())
if
not
found
:
self
.
agent
.
bdi_intention_buffer
.
append
((
pyson
.
Trigger
.
addition
,
pyson
.
GoalType
.
belief
,
term
,
pyson
.
runtime
.
Intention
()))
# self.agent.bdi_agent.call(pyson.Trigger.addition, pyson.GoalType.belief, term,
# pyson.runtime.Intention())
def
remove_belief
(
self
,
name
,
*
args
):
"""Remove an existing agent's belief."""
...
...
@@ -122,19 +118,16 @@ class BDIAgent(Agent):
term
=
pyson
.
Literal
(
name
,
tuple
(
new_args
),
PERCEPT_TAG
)
self
.
agent
.
bdi_intention_buffer
.
append
((
pyson
.
Trigger
.
removal
,
pyson
.
GoalType
.
belief
,
term
,
pyson
.
runtime
.
Intention
()))
# self.agent.bdi_agent.call(pyson.Trigger.removal, pyson.GoalType.belief, term,
# pyson.runtime.Intention())
def
get_belief
(
self
,
key
,
pyson_format
=
False
):
def
get_belief
(
self
,
key
,
source
=
False
):
"""Get an agent's existing belief. The first belief matching
<key> is returned. Keep <pyson_format> False to strip pyson
formatting."""
<key> is returned. Keep <source> False to strip source."""
key
=
str
(
key
)
for
beliefs
in
self
.
agent
.
bdi_agent
.
beliefs
:
if
beliefs
[
0
]
==
key
:
raw_belief
=
(
str
(
list
(
self
.
agent
.
bdi_agent
.
beliefs
[
beliefs
])[
0
]))
if
')[source'
in
raw_belief
and
not
pyson_format
:
if
')[source'
in
raw_belief
and
not
source
:
raw_belief
=
raw_belief
.
split
(
'['
)[
0
]
.
replace
(
'"'
,
''
)
belief
=
raw_belief
...
...
@@ -150,28 +143,25 @@ class BDIAgent(Agent):
else
:
return
None
def
get_beliefs
(
self
,
pyson_format
=
False
):
"""Get agent's beliefs.Keep <pyson_format> False to strip pyson
formatting."""
def
get_beliefs
(
self
,
source
=
False
):
"""Get agent's beliefs.Keep <source> False to strip source."""
belief_list
=
[]
for
beliefs
in
self
.
agent
.
bdi_agent
.
beliefs
:
try
:
raw_belief
=
(
str
(
list
(
self
.
agent
.
bdi_agent
.
beliefs
[
beliefs
])[
0
]))
if
')[source('
in
raw_belief
and
not
pyson_format
:
if
')[source('
in
raw_belief
and
not
source
:
raw_belief
=
raw_belief
.
split
(
'['
)[
0
]
.
replace
(
'"'
,
''
)
belief_list
.
append
(
raw_belief
)
except
IndexError
:
pass
return
belief_list
def
print_beliefs
(
self
,
pyson_format
=
False
):
"""Print agent's beliefs.Keep <pyson_format> False to strip pyson
formatting."""
print
(
"PRINTING BELIEFS"
)
def
print_beliefs
(
self
,
source
=
False
):
"""Print agent's beliefs.Keep <source> False to strip source."""
for
beliefs
in
self
.
agent
.
bdi_agent
.
beliefs
.
values
():
for
belief
in
beliefs
:
if
')[source('
in
str
(
belief
)
and
not
pyson_format
:
if
')[source('
in
str
(
belief
)
and
not
source
:
belief
=
str
(
belief
)
.
split
(
'['
)[
0
]
.
replace
(
'"'
,
''
)
print
(
belief
)
...
...
@@ -218,13 +208,11 @@ class BDIAgent(Agent):
pyson
.
Literal
(
"source"
,
(
pyson
.
Literal
(
str
(
msg
.
sender
)),
)))
self
.
agent
.
bdi_intention_buffer
.
append
((
trigger
,
goal_type
,
tagged_message
,
intention
))
# self.agent.bdi_agent.call(trigger, goal_type,
# tagged_message, intention)
if
self
.
agent
.
bdi_intention_buffer
:
temp_intentions
=
deque
(
self
.
agent
.
bdi_intention_buffer
)
for
trigger
,
goal_type
,
t
agged_message
,
intention
in
temp_intentions
:
for
trigger
,
goal_type
,
t
erm
,
intention
in
temp_intentions
:
self
.
agent
.
bdi_agent
.
call
(
trigger
,
goal_type
,
t
agged_message
,
intention
)
trigger
,
goal_type
,
t
erm
,
intention
)
self
.
agent
.
bdi_agent
.
step
()
self
.
agent
.
bdi_intention_buffer
.
popleft
()
else
:
...
...
@@ -247,5 +235,5 @@ async def parse_literal(msg):
args
=
tuple
(
new_args
)
else
:
args
=
None
args
=
''
return
functor
,
args
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