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
3c53c7e4
Commit
3c53c7e4
authored
1 year ago
by
Fabian Heinrich
Browse files
Options
Downloads
Patches
Plain Diff
Dosctrings
parent
9281b49e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#47963
passed
1 year ago
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cooperative_cuisine/orders.py
+9
-8
9 additions, 8 deletions
cooperative_cuisine/orders.py
cooperative_cuisine/state_representation.py
+75
-2
75 additions, 2 deletions
cooperative_cuisine/state_representation.py
with
84 additions
and
10 deletions
cooperative_cuisine/orders.py
+
9
−
8
View file @
3c53c7e4
...
...
@@ -55,6 +55,7 @@ from cooperative_cuisine.hooks import (
ORDER_EXPIRED
,
)
from
cooperative_cuisine.items
import
Item
,
Plate
,
ItemInfo
from
cooperative_cuisine.state_representation
import
OrderState
log
=
logging
.
getLogger
(
__name__
)
"""
The logger for this module.
"""
...
...
@@ -279,16 +280,16 @@ class OrderManager:
if
order
.
meal
.
name
==
meal
.
name
:
return
order
,
index
def
order_state
(
self
)
->
list
[
dict
]:
def
order_state
(
self
)
->
list
[
OrderState
]:
"""
Similar to the `to_dict` in `Item` and `Counter`. Relevant for the state of the environment
"""
return
[
{
"
id
"
:
order
.
uuid
,
"
category
"
:
ORDER_CATEGORY
,
"
meal
"
:
order
.
meal
.
name
,
"
start_time
"
:
order
.
start_time
.
isoformat
(),
"
max_duration
"
:
order
.
max_duration
.
total_seconds
(),
}
OrderState
(
id
=
order
.
uuid
,
category
=
ORDER_CATEGORY
,
meal
=
order
.
meal
.
name
,
start_time
=
order
.
start_time
.
isoformat
(),
max_duration
=
order
.
max_duration
.
total_seconds
(),
)
for
order
in
self
.
open_orders
]
...
...
This diff is collapsed.
Click to expand it.
cooperative_cuisine/state_representation.py
+
75
−
2
View file @
3c53c7e4
...
...
@@ -4,110 +4,183 @@ Type hint classes for the representation of the json state.
import
json
from
datetime
import
datetime
from
enum
import
Enum
from
typing
import
Any
from
pydantic
import
BaseModel
from
typing_extensions
import
Literal
,
TypedDict
class
OrderState
(
TypedDict
):
"""
Format of the state representation of an order.
"""
id
:
str
"""
ID of the order.
"""
category
:
Literal
[
"
Order
"
]
"""
Category of the order.
"""
meal
:
str
"""
Name of the ordered meal.
"""
start_time
:
datetime
# isoformat str
"""
Time of the creation of the order.
"""
max_duration
:
float
"""
Maximum duration of the order.
"""
class
EffectState
(
TypedDict
):
"""
Format of the state representation of an effect.
"""
id
:
str
"""
ID of th effect.
"""
type
:
str
"""
Type of the effect.
"""
progress_percentage
:
float
|
int
"""
Progressed percentage of the effect.
"""
inverse_progress
:
bool
"""
Progress in reverse.
"""
class
ItemState
(
TypedDict
):
"""
Format of the state representation of an item.
"""
id
:
str
"""
ID of the item.
"""
category
:
Literal
[
"
Item
"
]
|
Literal
[
"
ItemCookingEquipment
"
]
"""
Category of the item.
"""
type
:
str
"""
Type of the item.
"""
progress_percentage
:
float
|
int
"""
Progressed percentage of the item.
"""
inverse_progress
:
bool
"""
Progress in reverse.
"""
active_effects
:
list
[
EffectState
]
"""
Active effects of the item.
"""
# add ItemType Meal ?
class
CookingEquipmentState
(
TypedDict
):
"""
Format of the state representation of cooking equipment.
"""
content_list
:
list
[
ItemState
]
"""
List of contents of the cooking equipment.
"""
content_ready
:
None
|
ItemState
"""
Is the content ready to be released?
"""
class
CounterState
(
TypedDict
):
"""
Format of the state representation of a counter.
"""
id
:
str
"""
ID of the counter.
"""
category
:
Literal
[
"
Counter
"
]
"""
Category of the counter.
"""
type
:
str
"""
Type of the counter.
"""
pos
:
list
[
float
]
"""
Position of the counter.
"""
orientation
:
list
[
float
]
"""
Orientation / facing direction of the counter, currently only visual.
"""
occupied_by
:
None
|
list
[
ItemState
|
CookingEquipmentState
]
|
ItemState
|
CookingEquipmentState
"""
What is occupying the counter, what is lying/standing on it.
"""
active_effects
:
list
[
EffectState
]
"""
Active effects of the counter.
"""
# list[ItemState] -> type in ["Sink", "PlateDispenser"]
class
PlayerState
(
TypedDict
):
"""
Format of the state representation of a player.
"""
id
:
str
"""
ID of the player.
"""
pos
:
list
[
float
]
"""
Position of the player.
"""
facing_direction
:
list
[
float
]
"""
The direction the player is facing.
"""
holding
:
ItemState
|
CookingEquipmentState
|
None
"""
What the player is currently holding.
"""
current_nearest_counter_pos
:
list
[
float
]
|
None
"""
Position of the currently nearest counter to the player.
"""
current_nearest_counter_id
:
str
|
None
"""
ID of the currently nearest counter to the player.
"""
class
KitchenInfo
(
BaseModel
):
"""
B
asic information of the kitchen.
"""
"""
Format of the state representation of b
asic information of the kitchen.
"""
width
:
float
"""
Width of the kitchen. One counter counts as one unit of measurement.
"""
height
:
float
"""
Height of the kitchen. One counter counts as one unit of measurement.
"""
class
ViewRestriction
(
BaseModel
):
"""
Format of the state representation of a view restriction from the players perspectives.
Currently as a view cone, like a flashlight in the dark.
"""
direction
:
list
[
float
]
"""
Direction of what the player can see.
"""
position
:
list
[
float
]
"""
Starting position of the view cone.
"""
angle
:
int
# degrees
"""
Angle of the view cone.
"""
counter_mask
:
None
|
list
[
bool
]
"""
Mask of which counters are in view. Currently unused.
"""
range
:
float
|
None
"""
Range of the view.
"""
class
InfoMsgLevel
(
Enum
):
"""
Level of importance of the messages displayed to the players.
"""
Normal
=
"
Normal
"
Warning
=
"
Warning
"
Success
=
"
Success
"
class
InfoMsg
(
TypedDict
):
"""
Info messages for the players to be displayed.
"""
msg
:
str
"""
The actual message for the player.
"""
start_time
:
datetime
"""
Start time of the message.
"""
end_time
:
datetime
"""
End time of the message, when the message will disappear.
"""
level
:
InfoMsgLevel
"""
Importance level of the message.
"""
class
StateRepresentation
(
BaseModel
):
"""
The format of the returned state representation.
"""
players
:
list
[
PlayerState
]
"""
Information about the players in the environment.
"""
counters
:
list
[
CounterState
]
"""
Information about the counters in the environment.
"""
kitchen
:
KitchenInfo
"""
General information about the kitchen.
"""
score
:
float
|
int
"""
The score achieved by the players.
"""
orders
:
list
[
OrderState
]
"""
Current orders in the environment.
"""
ended
:
bool
"""
If the environment has ended.
"""
env_time
:
datetime
# isoformat str
"""
Current time of the environment, relative to the start time of the env.
"""
remaining_time
:
float
"""
Remaining time for the players to act in the environment.
"""
view_restrictions
:
None
|
list
[
ViewRestriction
]
"""
Restriction of the view for the players.
"""
served_meals
:
list
[
tuple
[
str
,
str
]]
"""
List of already served meals in the environment.
"""
info_msg
:
list
[
tuple
[
str
,
str
]]
"""
Info messages for the players to be displayed.
"""
# is added:
# all_players_ready: bool
def
create_json_schema
():
def
create_json_schema
()
->
dict
[
str
,
Any
]:
"""
Create a json scheme of the state representation of an environment.
"""
return
StateRepresentation
.
model_json_schema
()
...
...
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