Skip to content

Syntax for select and to_list #22

Answered by jofmi
fl-hat asked this question in Q&A
Jun 23, 2021 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Hi @fl-hat !

Please make sure to update to the latest version (0.1.2), as to_list is a new feature.

I think it should work with the following:

nearby_agents = self.mymodel.space.select(midpoint, search_radius)
nearby_agents = nearby_agents.to_list()

Or with just one line:

nearby_agents = self.mymodel.space.select(midpoint, search_radius).to_list()

To improve performance, you could consider to put your resources in a separate Space, so that you don't have to select the resources (i.e. your third line of code) every time. E.g. you could have an agent_space and a resource_space.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@fl-hat
Comment options

@jofmi
Comment options

Answer selected by jofmi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants