Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
 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)     
Пример #4
0
 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)
Пример #5
0
 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)
Пример #6
0
 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)
Пример #7
0
 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)
Пример #8
0
 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)
Пример #9
0
 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)
Пример #10
0
 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)
Пример #11
0
 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)
Пример #12
0
 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)
Пример #13
0
 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)
Пример #14
0
 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)
Пример #15
0
 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)
Пример #16
0
 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)
Пример #17
0
 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)
Пример #18
0
 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)
Пример #19
0
 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)
Пример #20
0
 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)
Пример #21
0
 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)