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
2c239fc4
Commit
2c239fc4
authored
Apr 10, 2019
by
serfrape
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the .goto action for PyGomas
parent
3e01403e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
5 deletions
+75
-5
bdi.py
spade_bdi/bdi.py
+21
-5
ontology.py
spade_bdi/ontology.py
+54
-0
No files found.
spade_bdi/bdi.py
View file @
2c239fc4
# -*- coding: utf-8 -*-
from
spade.behaviour
import
CyclicBehaviour
import
asyncio
import
json
from
ast
import
literal_eval
from
loguru
import
logger
import
pyson
import
pyson.runtime
import
pyson.stdlib
import
asyncio
from
spade.behaviour
import
CyclicBehaviour
from
spade.agent
import
Agent
from
spade.template
import
Template
from
spade.message
import
Message
import
json
from
ast
import
literal_eval
from
loguru
import
logger
from
.ontology
import
X
,
Y
,
Z
PERCEPT_TAG
=
frozenset
(
[
pyson
.
Literal
(
"source"
,
(
pyson
.
Literal
(
"percept"
),
))])
PRECISION_Z
=
0.5
PRECISION_X
=
0.5
class
BDIAgent
(
Agent
):
...
...
@@ -62,6 +65,19 @@ class BDIAgent(Agent):
msg
=
Message
(
to
=
receiver
,
body
=
body
,
metadata
=
mdata
)
self
.
agent
.
submit
(
self
.
send
(
msg
))
yield
#
@self.agent.bdi_actions.add
(
".goto"
,
3
)
def
_goto
(
agent
,
term
,
intention
):
"""Sets the PyGomas destination. Expects args to be x,y,z"""
args
=
pyson
.
grounded
(
term
.
args
,
intention
.
scope
)
absx
=
abs
(
args
[
0
]
-
self
.
agent
.
movement
.
position
.
x
)
absz
=
abs
(
args
[
2
]
-
self
.
agent
.
movement
.
position
.
z
)
if
(
absx
<
PRECISION_X
)
and
(
absz
<
PRECISION_Z
):
self
.
agent
.
movement
.
position
.
x
=
args
[
0
]
self
.
agent
.
movement
.
position
.
z
=
args
[
2
]
yield
@self.agent.bdi_actions.add
(
".custom_action"
,
1
)
def
_custom_action
(
agent
,
term
,
intention
):
...
...
spade_bdi/ontology.py
0 → 100644
View file @
2c239fc4
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"
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