Skip to content
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

How can I get incomplete subtasks in the play mode? #10

Open
IsaacXu0808 opened this issue May 30, 2024 · 0 comments
Open

How can I get incomplete subtasks in the play mode? #10

IsaacXu0808 opened this issue May 30, 2024 · 0 comments

Comments

@IsaacXu0808
Copy link

I try to use STRIPSWorld.get_subtasks to check the incomplete subtasks (given the arglist and recipes from the env) in the GamePlay after each keyboard event, just like in RealAgent. But it always shows all the subtasks instead of the incomplete subtasks. So, how should I get incomplete subtasks in the play mode?

Modification in main.py:

game = GamePlay(env.filename, env.world, env.sim_agents, env.recipes, env.arglist)

Modifications In GamePlay.py

def __init__(self, filename, world, sim_agents, recipes, arglist):
      self.recipes = recipes
      self.arglist = arglist
...
if event.key in KeyToTuple.keys():
      action = KeyToTuple[event.key]
      self.current_agent.action = action
      interact(self.current_agent, self.world)
      # After a movement
      sw = STRIPSWorld(world=self.world, recipes=self.recipes)
      subtasks = sw.get_subtasks(max_path_length=self.arglist.max_num_subtasks)
      all_subtasks = [subtask for path in subtasks for subtask in path]
      print('Subtasks:', all_subtasks, '\n')

Finding incomplete subtasks in Agent.py:

def get_subtasks(self, world):
      self.sw = STRIPSWorld(world, self.recipes)
      # [path for recipe 1, path for recipe 2, ...] where each path is a list of actions.
      subtasks = self.sw.get_subtasks(max_path_length=self.arglist.max_num_subtasks)
      all_subtasks = [subtask for path in subtasks for subtask in path]
      return all_subtasks
...
def setup_subtasks(self, env):
        self.incomplete_subtasks = self.get_subtasks(world=env.world)
        self.delegator = BayesianDelegator(
                agent_name=self.name,
                all_agent_names=env.get_agent_names(),
                model_type=self.model_type,
                planner=self.planner,
                none_action_prob=self.none_action_prob)

Sample output in the console (the returned subtasks never change even if dishes are delivered):

Delivered Plate-ChoppedTomato!
Subtasks: [Merge(Lettuce, Plate), Deliver(Lettuce-Plate-Tomato), Merge(Tomato, Plate), Merge(Lettuce, Plate-Tomato), Merge(Tomato, Lettuce-Plate), Merge(Tomato, Lettuce), Chop(Tomato), Chop(Lettuce), Merge(Lettuce-Tomato, Plate)]

Subtasks: [Merge(Lettuce, Plate), Deliver(Lettuce-Plate-Tomato), Merge(Tomato, Plate), Merge(Lettuce, Plate-Tomato), Merge(Tomato, Lettuce-Plate), Merge(Tomato, Lettuce), Chop(Tomato), Chop(Lettuce), Merge(Lettuce-Tomato, Plate)]

Subtasks: [Merge(Lettuce, Plate), Deliver(Lettuce-Plate-Tomato), Merge(Tomato, Plate), Merge(Lettuce, Plate-Tomato), Merge(Tomato, Lettuce-Plate), Merge(Tomato, Lettuce), Chop(Tomato), Chop(Lettuce), Merge(Lettuce-Tomato, Plate)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant