Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@aiomas.expose
def bulk_get(self, ids, var):
return self.container.bulk_get_local(ids, var)
@aiomas.expose
def neighbors(self, position):
"""returns the neighbors around the position,
i.e. the values of the surrounding cells"""
x, y, z = position
if self.wraps:
return np.pad(self.state.grid, 1, mode='wrap')[
max(0, x):x+3,
max(0, y):y+3,
max(0, z):z+3].ravel()[self._wrap_mask]
else:
xs = [x]
ys = [y]
zs = [z]
if x > 0:
xs.append(x-1)
if x < self.width-1:
@aiomas.expose
def neighbors(self, position):
"""returns the neighbors around the position,
i.e. the values of the surrounding cells"""
x, y = position
if self.wraps:
return np.pad(self.state.grid, 1, mode='wrap')[
max(0, x):x+3,
max(0, y):y+3].ravel()[self._wrap_mask]
else:
xs = [x]
ys = [y]
if x > 0:
xs.append(x-1)
if x < self.width-1:
xs.append(x+1)
if y > 0:
@aiomas.expose
def states(self):
"""iterator over every agent state in the node"""
return self.container.states()
@aiomas.expose
async def setup_agents(self, *args, **kwargs):
"""call the 'setup' method on all agents"""
self.container.logger.debug('setting up agents! in manager')
await self.container.setup_agents(*args, **kwargs)
@aiomas.expose
def submit_var_update(self, var, value):
"""convenience method for updating a single state variable"""
self.submit_update(update_var, var, value)
@aiomas.expose
def get_state(self):
"""get the agent's state"""
return self.state
@aiomas.expose
def set_position(self, value, position):
"""set the value of a position in the grid.
this can be, for example, an agent address."""
x, y = position
self.state.grid[x, y] = value
@aiomas.expose
def update_agents(self, *args, **kwargs):
"""call the 'update' method on all agents"""
self.container.update_agents(*args, **kwargs)
@aiomas.expose
def vacancies(self, empty_val=0):
return np.vstack(np.where(self.state.grid == empty_val)).T