-
Notifications
You must be signed in to change notification settings - Fork 9
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
Adding pickup and drop action to the agent #36
Comments
Yes, and the type of that field needs to be added as a parameter type. |
Proposed solution:
|
Did not see this proposed solution before my PR, my bad. I implemented in |
As pointed out in the suggestion by @sriyash421 and implemented in #38 by @landrumb , I agree that an agent would have an @sriyash421 you are right in conceptualizing @landrumb Are you suggesting we create a new abstract type ( Instead, I suggest to use a function like Also, in the |
I didn't think of considering other attributes when I made the I like your idea of overloading functions that describe the behavior of different structs, but my one reservation would be that this would not be as readable. I like the idea of keeping all the information about a given struct together with its declaration, either as inheritance or an attribute. A good way to reduce overhead while making the methods as simple as possible for environments where only one inventory space is needed would be to define another object with an array attribute, and overload |
It depends. I am not so sure that we have a clear-cut winner.
If we use subtyping for properties, a user won't be able to create a new property or alter an existing property for their own case (say if they want to change the pickability of an object type). Something similar with using fields if a user wants to add new properties to an object type. But attributes are actually good as long as the users don't mind defining their own object structs if they want some extra properties. Attributes would allow for each instance of an object to have its own field value for the same property (which is pretty general actually). One potential challenge could be to store each instance (with all it's field values) somewhere. But as long as we don't have too many instances or fields per object type, and if we keep object types immutable, my hunch is that this should not conflict with the efficiency offered by using a BitArray representation. Right now we are using singleton parametric types to create Doors with different colors. The rest of the properties like pickability of each door would be the same for all Doors, for example. This means that we cannot have different properties for the same object type, something that is offered by using fields. On the other hand, if we wish to keep properties standardized across object instances (which would be singletons, as we have had so far), then using functions makes sense. |
Really thoughtful discussions! I'll also add my thoughts here.
@landrumb I also agree that whether or not an object can be picked up is an important attribute. But creating an extra abstract class inheriting from AbstractObject may have some potential issues. For example, we may have another important attribute to specify whether an object is able to be opened (like Door or Box). But a box with a key inside can be both picked up and be opened. This leads to a diamond inheritance
But Julia only supports single inheritance. So usually we use traits to address this issue. (In case you are not familiar with the concept of Traits, you can read the links mentioned in the first paragraph of SimpleTraits.jl) And I think here a method of
Agree! We can add different kinds of agents for different environments. |
The environments in #34 #32 #26, need the agent to pick up and drop objects present in the environment. So I think we need to add an object field to the agent(considering it can pick up only one thing at a time). Currently, the door key env handles this by assuming that the agent picks up the key as it moves over its tile.
The text was updated successfully, but these errors were encountered: