def miner_to_ore(self, entity, ore): entity_pt = entity.get_position() if not ore: return ([entity_pt], False) ore_pt = ore.get_position() if actions.adjacent(entity_pt, ore_pt): entity.set_resource_count(1 + entity.get_resource_count()) actions.remove_entity(self, ore) return ([ore_pt], True) else: new_pt = self.next_position(entity_pt, ore_pt) return (self.move_entity(entity, new_pt), False)
def miner_to_ore(self, world, ore): entity_pt = self.get_position() if not ore: return ([entity_pt], False) ore_pt = ore.get_position() if actions.adjacent(entity_pt, ore_pt): self.set_resource_count(1 + self.get_resource_count()) worldmodel.remove_entity(world, ore) return ([ore_pt], True) else: new_pt = actions.next_position(world, entity_pt, ore_pt) return (worldmodel.move_entity(world, self, new_pt), False)
def _to_other(self,world, ore): # to ore special....this is also an action entity_pt = self.get_position() if not ore: return ([entity_pt], False) ore_pt = ore.get_position() if actions.adjacent(entity_pt, ore_pt): self.set_resource_count(1 + self.get_resource_count()) world.remove_entity_schedule(ore) return ([ore_pt], True) else: new_pt = world.next_position(entity_pt, ore_pt) return (world.move_entity(self, new_pt), False)
def _to_other(self, world, smith): # to smith special entity_pt = self.get_position() if not smith: return ([entity_pt], False) smith_pt = smith.get_position() if actions.adjacent(entity_pt, smith_pt): smith.set_resource_count(smith.get_resource_count() + self.get_resource_count()) self.set_resource_count(0) return ([], True) else: new_pt = world.next_position(entity_pt, smith_pt) return (world.move_entity(self, new_pt), False)
def miner_to_ore(self, world, ore): #minernot full class entity_pt = self.get_position() if not ore: #am I next to ore?? return ([entity_pt], False) ore_pt = ore.get_position() if actions.adjacent(entity_pt, ore_pt): self.set_resource_count(1 + self.get_resource_count()) actions.remove_entity(world, ore) return ([ore_pt], True) else: new_pt = actions.next_position(world, entity_pt, ore_pt) return (world.move_entity(self, new_pt), False)
def miner_to_ore(self, world, ore): #not full class entity_pt = self.get_position() if not ore: return ([entity_pt], False) ore_pt = ore.get_position() if actions.adjacent(entity_pt, ore_pt): self.set_resource_count(1 + self.get_resource_count()) actions.remove_entity(ore, world) return ([ore_pt], True) else: new_pt = actions.next_position(world, entity_pt, ore_pt) return (world.move_entity(self, new_pt), False)
def miner_to_ore(world, entity, ore): entity_pt = get_position(entity) if not ore: return ([entity_pt], False) ore_pt = get_position(ore) if actions.adjacent(entity_pt, ore_pt): set_resource_count(entity, 1 + get_resource_count(entity)) actions.remove_entity(world, ore) return ([ore_pt], True) else: new_pt = actions.next_position(world, entity_pt, ore_pt) return (worldmodel.move_entity(world, entity, new_pt), False)
def miner_to_ore(self, world, ore): entity_pt = self.position if not ore: return ([entity_pt], False) ore_pt = ore.position if actions.adjacent(entity_pt, ore_pt): self.set_resource_count( 1 + self.resource_count) actions.remove_entity(world, ore) return ([ore_pt], True) else: new_pt = world.next_position(entity_pt, ore_pt) return (world.move_entity(self, new_pt), False)
def miner_to_smith(self, world, smith): entity_pt = self.get_position() if not smith: return ([entity_pt], False) smith_pt = smith.get_position() if actions.adjacent(entity_pt, smith_pt): smith.set_resource_count(smith.get_resource_count() + self.get_resource_count()) self.set_resource_count(0) return ([], True) else: new_pt = actions.next_position(world, entity_pt, smith_pt) return (worldmodel.move_entity(world, self, new_pt), False)
def miner_to_ore(self, entity, ore): entity_pt = entity.get_position() if not ore: return ([entity_pt], False) ore_pt = ore.get_position() if actions.adjacent(entity_pt, ore_pt): entity.set_resource_count( 1 + entity.get_resource_count()) self.world_remove_entity(ore) return ([ore_pt], True) else: new_pt = self.next_position(entity_pt, ore_pt) return (self.move_entity(entity, new_pt), False)
def miner_to_smith(self, entity, smith): entity_pt = entity.get_position() if not smith: return ([entity_pt], False) smith_pt = smith.get_position() if actions.adjacent(entity_pt, smith_pt): smith.set_resource_count(smith.get_resource_count() + entity.get_resource_count()) entity.set_resource_count(0) return ([], True) else: new_pt = self.next_position(entity_pt, smith_pt) return (self.move_entity(entity, new_pt), False)
def miner_to_smith(world, entity, smith): entity_pt = get_position(entity) if not smith: return ([entity_pt], False) smith_pt = get_position(smith) if actions.adjacent(entity_pt, smith_pt): set_resource_count( smith, get_resource_count(smith) + get_resource_count(entity)) set_resource_count(entity, 0) return ([], True) else: new_pt = actions.next_position(world, entity_pt, smith_pt) return (worldmodel.move_entity(world, entity, new_pt), False)
def blob_to_vein(self, world, vein): entity_pt = self.get_position() if not vein: return ([entity_pt], False) vein_pt = vein.get_position() if actions.adjacent(entity_pt, vein_pt): actions.remove_entity(vein, world) return ([vein_pt], True) else: new_pt = actions.blob_next_position(world, entity_pt, vein_pt) old_entity = world.get_tile_occupant(new_pt) if isinstance(old_entity, Ore): actions.remove_entity(old_entity, world) return (world.move_entity(self,new_pt), False)
def miner_to_smith(self, world, smith): entity_pt = self.get_position() if not smith: return ([entity_pt], False) smith_pt = smith.get_position() if actions.adjacent(entity_pt, smith_pt): smith.set_resource_count( smith.get_resource_count() + self.get_resource_count()) self.set_resource_count(0) return ([], True) else: new_pt = actions.next_position(world, entity_pt, smith_pt) return (world.move_entity(self, new_pt), False)
def miner_to_smith(self, entity, smith): entity_pt = entity.get_position() if not smith: return ([entity_pt], False) smith_pt = smith.get_position() if actions.adjacent(entity_pt, smith_pt): smith.set_resource_count( smith.get_resource_count() + entity.get_resource_count()) entity.set_resource_count(0) return ([], True) else: new_pt = self.next_position( entity_pt, smith_pt) return (self.move_entity( entity, new_pt), False)
def _to_other(self,world,vein): # special entity_pt = self.get_position() if not vein: return ([entity_pt], False) vein_pt = vein.get_position() if actions.adjacent(entity_pt, vein_pt): world.remove_entity_schedule(vein) return ([vein_pt], True) else: new_pt = world.blob_next_position(entity_pt, vein_pt) old_entity = world.get_tile_occupant(new_pt) if isinstance(old_entity, Ore): # do i need to change isinstance? world.remove_entity_schedule(old_entity) return (world.move_entity(self, new_pt), False)
def blob_to_vein(self, entity, vein): entity_pt = entity.get_position() if not vein: return ([entity_pt], False) vein_pt = vein.get_position() if actions.adjacent(entity_pt, vein_pt): self.world_remove_entity( vein) return ([vein_pt], True) else: new_pt = self.blob_next_position( entity_pt, vein_pt) old_entity = self.get_tile_occupant( new_pt) if isinstance(old_entity, entities.Ore): self.remove_entity( old_entity) return (self.move_entity( entity, new_pt), False)
def miner_to_smith(self, world, smith): #is the miner next to smith miner full class entity_pt = self.get_position() if not smith: #am i next to smith return ([entity_pt], False) smith_pt = smith.get_position() if actions.adjacent(entity_pt, smith_pt): smith.set_resource_count( smith.get_resource_count() + self.get_resource_count()) self.set_resource_count(0) return ([], True) else: new_pt = actions.next_position(world, entity_pt, smith_pt) return (world.move_entity(self, new_pt), False)
def blob_to_vein(self, world, vein): #blob trying to move to vein. nearest vein place in blob entity_pt = self.get_position() if not vein: #no veins on board return ([entity_pt], False) vein_pt = vein.get_position() if actions.adjacent(entity_pt, vein_pt): #next to vein actions.remove_entity(vein, world) return ([vein_pt], True) else: new_pt = actions.blob_next_position(world, entity_pt, vein_pt) #only passing blob's position, place blob_next_position leave as function because works on points and world or miner because function of miner old_entity = world.get_tile_occupant(new_pt) if isinstance(old_entity, Ore): actions.remove_entity(old_entity, world) return (world.move_entity(self, new_pt), False)
def blob_to_vein(self, entity, vein): entity_pt = entity.get_position() if not vein: return ([entity_pt], False) vein_pt = vein.get_position() if actions.adjacent(entity_pt, vein_pt): actions.remove_entity(self, vein) return ([vein_pt], True) else: new_pt = self.blob_next_position(entity_pt, vein_pt) old_entity = self.get_tile_occupant(new_pt) if isinstance(old_entity, entities.Ore): actions.remove_entity(self, old_entity) return (self.move_entity(entity, new_pt), False)
def blob_to_vein(world, entity, vein): entity_pt = get_position(entity) if not vein: return ([entity_pt], False) vein_pt = get_position(vein) if actions.adjacent(entity_pt, vein_pt): actions.remove_entity(world, vein) return ([vein_pt], True) else: new_pt = entity.blob_next_position(world, entity_pt, vein_pt) old_entity = worldmodel.get_tile_occupant(world, new_pt) if isinstance(old_entity, Ore): actions.remove_entity(world, old_entity) return (worldmodel.move_entity(world, entity, new_pt), False)