Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _construct_tile(self, position, tile_name):
agent = Agent(self.id)
agent.construct_tile(tile_name, position)
self.advance_ip()
def __move_item(item_id, location):
if location[0] != 1 or len(location) != 4:
print "Error in position cordinate in script"
item = Nobject(item_id)
agent = Agent(self.id)
if not agent_holding_item(agent, item_id):
if not positions_equal(agent.position, item.position):
#print "1"
self.__move(item.position)
else:
#print "2"
self._pickup_item(item_id)
else:
if positions_equal(agent.position, position):
#print "3"
self._drop_item(item_id)
self.advance_ip() #exit condition
else:
#print "4"
self.__move(location)
if not agent_id in self.next_move: #execute immediately
agent = Agent(agent_id)
agent_command(agent, *params)
self.schedule(agent_id, self.last_time + agent.action_delay())
#set agent_next_move time
elif self.next_move[agent_id] <= self.last_time: #execute immediately
print "agent_command_scheduler, execute: this should never happen, race condition or off by one error"
agent = Agent(agent_id)
agent_command(agent, *params)
self.schedule(agent_id, self.last_time + agent.action_delay())
#next_move[agent_id] = self.last_time + agent.action_delay() #set agent_next_move time
else: #agent is already scheduled, pass to agent_msg que
#print "need to implement scheduler!"
## DELETE below when scheduler is ready !!! # ###
if False:
agent = Agent(agent_id)
agent_command(agent, *params)
else:
self.agent_controller.next_action(agent_id)
#self.schedule(agent_id, self.last_time + agent.action_delay())
pass
def construct_tile(self, agent_id, position, tile_name, **msg):
Agent(agent_id).construct_tile(position, tile_name)
pass
def agent_info(self, id, client_id, version = -1):
msg = {}
msg['msg'] = 'agent_info'
msg['id'] = id
msg['client_id'] = client_id
x = Agent(id)
msg['version'] = x.version
msg['value'] = x.serialize()
self.info_out_q.put((client_id,msg))
pass
def dig(self, agent_id, position, action = None, **msg):
if action == None:
action = "wall"
Agent(agent_id).dig(position, action)
pass
print "Share State Start"
not_singletons = []
to_share = [singleton for singleton in self.__dict__.items() if singleton[0] not in not_singletons]
def share(a,b):
name1, object1 = a[0], a[1]
name2, object2 = b[0], b[1]
if getattr(object1,name2,'xx') != 'xx':
#print 'Assigning',name2,'to',name1
setattr(object1,name2,object2)
[[share(singleton1,singleton2) for singleton2 in to_share] for singleton1 in to_share]
### INIT Templates ###
#Agent class init
Agent.world_map = self.world_map
Agent.delta = self.delta
Agent.agents = self.agents
Agent.objects = self.objects
Agent.world_time = self.world_time
Agent.dat = self.dat
#Object class init
Nobject.world_map = self.world_map
Nobject.delta = self.delta
Nobject.agents = self.agents
Nobject.objects = self.objects
Nobject.world_time = self.world_time
Nobject.dat = self.dat
#Crop class init
Crop.world_map = self.world_map
Crop.delta = self.delta
Crop.agents = self.agents
Crop.objects = self.objects
Crop.world_time = self.world_time