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

fixed grabbing behaviour in agent #1148

Merged
merged 5 commits into from
Mar 18, 2020
Merged

Conversation

omar-3
Copy link
Contributor

@omar-3 omar-3 commented Jan 7, 2020

When a thing is grabbed, it would be hidden from the environment. When released or the agent is removed it would be added to environment again at the same location of the agent. For the issue of grabbed thing movement, it is already implemented. No test has failed.

Have I missed something?

Copy link
Contributor

@tirthasheshpatel tirthasheshpatel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I have suggested a couple of improvements. Can you please review them?

agents.py Outdated
elif action == 'Grab':
things = [thing for thing in self.list_things_at(agent.location)]
if agent.can_grab(things[0]):
if things:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line if things should be on the top otherwise things[0] (accessed in the line above) would raise an exception!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes that is true

agents.py Outdated
# for obj in thing.holding:
# super().delete_thing(obj)
# for obs in self.observers:
# obs.thing_deleted(obj)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if 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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 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!

@tirthasheshpatel
Copy link
Contributor

I think this will also need some tests to be added

@omar-3
Copy link
Contributor Author

omar-3 commented Jan 7, 2020

I think this will also need some tests to be added

Ahh I realized that after making the pull request, the tests would be easy I guess.

@omar-3
Copy link
Contributor Author

omar-3 commented Jan 7, 2020

could anyone help me understand why the checks have failed? It fails for python3.4 only

@tirthasheshpatel
Copy link
Contributor

could anyone help me understand why the checks have failed? It fails for python3.4 only

It has nothing to do with the pr. Just close and reopen and the tests will hopefully pass...

@omar-3 omar-3 closed this Jan 7, 2020
@omar-3 omar-3 reopened this Jan 7, 2020
@omar-3 omar-3 closed this Jan 7, 2020
@omar-3 omar-3 reopened this Jan 7, 2020
@tirthasheshpatel
Copy link
Contributor

tirthasheshpatel commented Jan 7, 2020

Turns out pyyaml has removed support for python 3.4. This is a issue for keras. We don't need to worry about it.

@tirthasheshpatel
Copy link
Contributor

Here's the upstream issue on keras. gh-13674

@omar-3
Copy link
Contributor Author

omar-3 commented Jan 7, 2020

I guess it is better if I open an issue.

@tirthasheshpatel
Copy link
Contributor

@Okhaledzaki I don't think this is our issue but I will leave it upto the maintainers to decide!

This was referenced Jan 8, 2020
agents.py Outdated
@@ -967,21 +967,16 @@ def execute_action(self, agent, action):

agent.bump = False
if action == 'TurnRight':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the if statement could be streamlined if we rewrote it as:

if action in ['TurnRight', 'TurnLeft', 'Forward']:
            super().execute_action(agent,action)
            agent.performance -= 1
elif action == 'Grab':
            super().execute_action(agent,action)

I think the above looks a bit better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had that in mind, but I thought to myself that being more articulate and reasonably redundant in code would help the student retaining the information that is my case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But actually seeing it, it really didn't help much.

Copy link
Collaborator

@antmarakis antmarakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor typos.

agents.py Outdated
super().execute_action(agent,action)
agent.performance -= 1
elif action == 'Grab':
if action in ['TurnRight', 'TurnLeft', 'Forward','Grab']:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space is needed after the last comma.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@omar-3
Copy link
Contributor Author

omar-3 commented Feb 21, 2020

something has broken in the deeplearning module @antmarakis :"D

@antmarakis antmarakis closed this Feb 23, 2020
@antmarakis antmarakis reopened this Feb 23, 2020
@omar-3 omar-3 closed this Feb 24, 2020
@omar-3 omar-3 reopened this Feb 24, 2020
@omar-3 omar-3 closed this Feb 24, 2020
@omar-3 omar-3 reopened this Feb 24, 2020
@omar-3
Copy link
Contributor Author

omar-3 commented Feb 27, 2020

@antmarakis The tests have all passed finally phew

agents.py Outdated
if len(things):
agent.holding.append(things[0])
if action in ['TurnRight', 'TurnLeft', 'Forward', 'Grab']:
super().execute_action(agent,action)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need a space after the comma, to comply with the overall project style.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@omar-3 omar-3 requested a review from antmarakis March 6, 2020 17:52
@antmarakis antmarakis merged commit f502be9 into aimacode:master Mar 18, 2020
@omar-3 omar-3 deleted the fix-grab-agent branch April 21, 2020 18:44
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

Successfully merging this pull request may close these issues.

3 participants