| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -510,14 +510,16 @@ def execute_action(self, agent, action): | |
| agent.direction += Direction.L | ||
| elif action == 'Forward': | ||
| agent.bump = self.move_to(agent, agent.direction.move_forward(agent.location)) | ||
| # elif action == 'Grab': | ||
| # things = [thing for thing in self.list_things_at(agent.location) | ||
| # if agent.can_grab(thing)] | ||
| # if things: | ||
| # agent.holding.append(things[0]) | ||
| elif action == 'Grab': | ||
| things = [thing for thing in self.list_things_at(agent.location)] | ||
| if agent.can_grab(things[0]): | ||
| if things: | ||
| agent.holding.append(things[0]) | ||
| self.delete_thing(things[0]) | ||
| elif action == 'Release': | ||
| if agent.holding: | ||
| agent.holding.pop() | ||
| dropped = agent.holding.pop() | ||
| self.add_thing(dropped, location=agent.location) | ||
|
|
||
| def default_location(self, thing): | ||
| location = self.random_location_inbounds() | ||
| Expand Down Expand Up | @@ -569,10 +571,11 @@ def random_location_inbounds(self, exclude=None): | |
| def delete_thing(self, thing): | ||
| """Deletes thing, and everything it is holding (if thing is an agent)""" | ||
| if isinstance(thing, Agent): | ||
| for obj in thing.holding: | ||
| super().delete_thing(obj) | ||
| for obs in self.observers: | ||
| obs.thing_deleted(obj) | ||
| # for obj in thing.holding: | ||
| # super().delete_thing(obj) | ||
| # for obs in self.observers: | ||
| # obs.thing_deleted(obj) | ||
|
Comment thread
Outdated
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI don't see a reason to comment these lines out. Even though the second line is redundant, the observers of the environment still need to be informed about each thing being deleted.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualityif we delete all of the agent holdings with del thing.holding, and thanks to python memory management. All instants of the agent's holding would vanish from memory even in the observer list. Tell me what you think.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThe observers of the environment need to be updated about all the things getting deleted along with the agent. I have not seen observers used anywhere, so it depends upon the maintainers of the project to keep or exclude it!
Sorry, something went wrong.
All reactions
|
||
| del thing.holding | ||
|
|
||
| super().delete_thing(thing) | ||
| for obs in self.observers: | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis line if things should be on the top otherwise things[0] (accessed in the line above) would raise an exception!
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualityyes that is true
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.