Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Cooperative Cuisine Environment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Social Cognitive Systems
CoCoSy
Cooperative Cuisine Environment
Commits
1ced66cc
Commit
1ced66cc
authored
1 year ago
by
Fabian Heinrich
Browse files
Options
Downloads
Patches
Plain Diff
Adjusted copying of graph in restriction
parent
cac99c40
No related branches found
No related tags found
1 merge request
!89
Resolve "simple pathfinding"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cooperative_cuisine/configs/agents/random_agent.py
+6
-2
6 additions, 2 deletions
cooperative_cuisine/configs/agents/random_agent.py
cooperative_cuisine/state_representation.py
+6
-5
6 additions, 5 deletions
cooperative_cuisine/state_representation.py
with
12 additions
and
7 deletions
cooperative_cuisine/configs/agents/random_agent.py
+
6
−
2
View file @
1ced66cc
...
...
@@ -175,7 +175,7 @@ async def agent():
try
:
path
=
networkx
.
astar_path
(
restrict_movement_graph
(
graph
=
movement_graph
.
copy
()
,
graph
=
movement_graph
,
player_positions
=
[
p
[
"
pos
"
]
for
p
in
state
[
"
players
"
]
...
...
@@ -207,6 +207,8 @@ async def agent():
do_movement
=
True
else
:
# no paths available
print
(
"
NO PATHS
"
)
# task_type = None
# task_args = None
do_movement
=
False
...
...
@@ -251,6 +253,7 @@ async def agent():
await
websocket
.
recv
()
else
:
# Target reached here.
print
(
"
TARGET REACHED
"
)
task_type
=
None
task_args
=
None
case
"
INTERACT
"
:
...
...
@@ -307,7 +310,8 @@ async def agent():
...
if
not
task_type
:
task_type
=
random
.
choice
([
"
GOTO
"
,
"
PUT
"
,
"
INTERACT
"
])
# task_type = random.choice(["GOTO", "PUT", "INTERACT"])
task_type
=
random
.
choice
([
"
GOTO
"
])
threshold
=
datetime
.
now
()
+
timedelta
(
seconds
=
TIME_TO_STOP_ACTION
)
if
task_type
==
"
GOTO
"
:
# counter_type = random.choice(list(counters.keys()))
...
...
This diff is collapsed.
Click to expand it.
cooperative_cuisine/state_representation.py
+
6
−
5
View file @
1ced66cc
...
...
@@ -222,7 +222,7 @@ def create_movement_graph(state: StateRepresentation, diagonal=True) -> Graph:
for
dj
in
range
(
-
1
,
2
):
x
,
y
=
i
+
di
,
j
+
dj
if
(
0
<
x
<
width
0
<
=
x
<
width
and
0
<
y
<
height
and
free_space
[
x
,
y
]
and
(
di
,
dj
)
!=
(
0
,
0
)
...
...
@@ -244,7 +244,7 @@ def create_movement_graph(state: StateRepresentation, diagonal=True) -> Graph:
)
else
:
for
x
,
y
in
[(
i
-
1
,
j
),
(
i
+
1
,
j
),
(
i
,
j
-
1
),
(
i
,
j
+
1
)]:
if
0
<
x
<
width
and
0
<
y
<
height
and
free_space
[
x
,
y
]:
if
0
<
=
x
<
width
and
0
<
=
y
<
height
and
free_space
[
x
,
y
]:
graph
.
add_edge
(
(
i
,
j
),
(
x
,
y
),
...
...
@@ -266,11 +266,12 @@ def restrict_movement_graph(
Returns: The modified graph without nodes where players stand.
"""
copied
=
graph
.
copy
()
for
pos
in
player_positions
:
tup
=
tuple
(
np
.
array
(
pos
).
round
().
astype
(
int
))
if
tup
in
graph
.
nodes
.
keys
():
graph
.
remove_node
(
tup
)
return
graph
if
tup
in
copied
.
nodes
.
keys
():
copied
.
remove_node
(
tup
)
return
copied
def
create_json_schema
()
->
dict
[
str
,
Any
]:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment