-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[1/2] Customers #35
base: main
Are you sure you want to change the base?
[1/2] Customers #35
Conversation
…s for container to robotouille.py, made new env json
…ng still buggy regarding stacking predicates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for the immense effort on this! I've left a couple of comments and have requested changes just so I can take another look at your responses and minor changes.
backend/customer.py
Outdated
order to them. | ||
""" | ||
|
||
customers = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
turn these into instance variables so we don't have networking issues
backend/domain.py
Outdated
if not self._are_valid_types(pred.types, object_types): | ||
raise ValueError(f"Predicate {pred.name} has invalid types.") | ||
|
||
for action in self.actions: | ||
for action in action_def: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
combine for loop into 1 more for loop
for action_def in [action_def, npc_action_def]:
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
edited accordingly
backend/gamemode.py
Outdated
@@ -0,0 +1,52 @@ | |||
from backend.customer import Customer | |||
class GameMode(object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for future, you can import ABC class to make abstract class. look at this reference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
used ABC for Gamemode and SpecialEffect
backend/movement/movement.py
Outdated
player_destinations = [data.path[-1] for name, data in Movement.metadata.items() if data.path and name != player.name] | ||
player_customer_locations = [p.pos for p in Player.players.values() if p != player] | ||
player_customer_locations += [c.pos for c in Customer.customers.values() if c != customer and c.in_game] | ||
# player_customer_destinations = [data.path[-1] for name, data in Movement.metadata.items() if data.path and name != player.name and name != customer.name] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete
backend/movement/movement.py
Outdated
player_customer_locations += [c.pos for c in Customer.customers.values() if c != customer and c.in_game] | ||
# player_customer_destinations = [data.path[-1] for name, data in Movement.metadata.items() if data.path and name != player.name and name != customer.name] | ||
player_customer_destinations = [] | ||
for name, data in Movement.metadata.items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is unclear, comment more and make it clearer
renderer/canvas.py
Outdated
@@ -500,30 +524,33 @@ def _get_player_sprite(self, direction): | |||
AssertionError: If the direction is invalid | |||
""" | |||
if direction == (0, 1): | |||
return self.config["player"]["robot"]["back"] | |||
return self.config[type]["robot"]["back"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so ['customer']['robot'][...]
is a customer asset? customer isn't a robot. regardless we are hardcoding the "robot" asset anyways; either make this clearer that we are hardcoding by removing ["robot"] and renaming assets or put a TODO to fix this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the function to take in a name argument
renderer/canvas.py
Outdated
@@ -486,12 +509,13 @@ def _draw_stations(self, surface): | |||
self._draw_image(surface, asset_info["name"], np.array([j, i - offset]) * self.pix_square_size, self.pix_square_size) | |||
|
|||
|
|||
def _get_player_sprite(self, direction): | |||
def _get_player_or_customer_image_name(self, direction, type): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking throughout the codebase and repeatedly seeing player_or_customer
is tiring. it would be good for us to rename this to some catch all like character (customer is a non-playable character while player is a playable character).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced with character
@@ -10,6 +10,15 @@ | |||
} | |||
}, | |||
|
|||
"customer": { | |||
"robot": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may as well remove the "robot" key for the time being until we have different assets to make this hardcoding more evident.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed it to girl so that the choose_character_image_name() function can take in a name
from domain.domain_builder import build_domain | ||
from utils.robotouille_utils import trim_item_ID | ||
from backend.gamemodes.classic import Classic | ||
from .env_utils import build_identity_predicates, build_location_predicates, build_stacking_predicates, build_goal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for organizing this better. we'll eventually want to reintegrate PDDL and since these are used by builder.py
it's good to keep them in one place and switch between creating PDDL predicates or our State predicates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noted!
robotouille/env.py
Outdated
animate (bool): Whether or not to animate the movement of the players. | ||
|
||
Returns: | ||
gamemode(GameMode): The gamemmode of the environment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space between gamemode (GameMode)
and misspelled gamemode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added space and fixed typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving additional comment after testing the customer environments.
"goal": [ | ||
{ | ||
"predicate": "iscookable", | ||
"args": ["lettuce"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also just played through these and realized the goal is unrealizable. What is the plan for checking that these environments are done?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, did this to make it easier to debug. Edited the goals accordingly to close when all customers have finished eating.
Overview
In this PR, I implement Gamemodes and Customers into Robotouille.
Previously, stepping in the environment was controlled using the
step()
function within theState
class. However, this was problematic because it was controlling more than just updates to the state, especially with new modules like Movement. Now, there is a new module calledGameMode
that controls all modules within Robotouille.The
GameMode
class also lets Robotouille have win conditions. In this PR, I implement a basic gamemode called `Classic' where the player must serve a number of customers within a certain amount of time.Changes Made
Customers
Customer
class which keeps track about information about the customers and steps them in the environmentdomain.py
anddomain_builder.py
to now keep track ofnpc_actions
, all actions that the npc can do as defined in the domainmovement.py
to also move customersstate.py
to keep track of customers and customer_actionsrecipes.json
where recipes can be specifiedrobotouille.json
to include Customer type, predicates, and actionsbuilder.py
andobject_enmus.py
to include Customer typecustomer.json
andmulti_customer.json
to test customersrenderer.py
,canvas.py
,robotouille_env.py
androbotouille_config.json
to render customersGameMode
GameMode
class that serves as the overall control of the game, keeps track of win conditions, and steps all the modules in the gameClassic
subclass where a player must satisfy all recipes before a given timestate.py
toclassic.py
env_utils.py
to prevent circular imports when creating the GameMode and Customersrobotouille_simulator.py
to passpygame.time
into the gamemode classChanges to Containers
robotouille.json
so that containers can now be picked up and placed with items on itinput.json
canvas.py
to properly render containers and items stacked on containersChanges to Robotouille Domain
Test Coverage
Tested with all environments
Next Steps
Screenshots