-
Notifications
You must be signed in to change notification settings - Fork 0
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
Improve notebook controller API #114
Conversation
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.
Thanks! See my comments in the code. Also:
- could be renamed debug_mode or something similar: Yes
- Seems like the old function works better, can you also try this on your computer ? : Can you send me the code to run?
@@ -127,7 +126,9 @@ def __init__(self, config): | |||
self.active_behaviors = {} | |||
self.eating_range = 10 | |||
self.diet = [] | |||
# TODO : see if we keep both |
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.
No need It I think. Is has_eaten_since(time=1)
equivalent to the previous has_eaten()
?
Maybe also avoid the work "meal", I'd like to keep a low-level biological flavor in this library. Maybe time_since_last_consumption
?
# execute behaviors of agents | ||
if entity.etype == EntityType.AGENT: | ||
entity.behave(self.time) | ||
# TODO: see if we do this in a dedicated function or not | ||
# increment time since last meal for all alive agents | ||
entity.time_since_last_meal += 1 |
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.
Shouldn't this be inside the routine instead?
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.
In general we should avoid specific mechanisms within the generic run loop, they should all be in routines
|
||
:return: True if the agent has eaten since the given time, False otherwise | ||
""" | ||
return self.time_since_last_meal < time |
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.
Double check this will work as expected (init of the variable, comparison operator..)
|
||
# finally stop the simulation | ||
self.stop() | ||
self.pause() |
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.
To discuss
|
||
def stop(self): | ||
"""Stop the simulation | ||
"""Stop the simulation and detach all routines |
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.
Should also detach all behaviors?
|
||
def eating_routine_fn(controller): | ||
"""make agents of the simulation eating the entities in their diet | ||
def eating_routine_classic(controller): |
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.
Could rename it eating_range_routine
Description
Improve notebook controller API on various points:
run
catch_error
flag to either automatically catch errors for routines or not (could be renamed debug_mode or something similar). You can launch it like that with the run function of the controller:While updating the new eating function, I got this (old is the old eating routine function, new the one I did, and Clem the one you did):
Session 5:
Session neuroevo_ABC:
Seems like the old function works better, can you also try this on your computer ?