Esempio n. 1
0
 def make_scan_data_available(self, lawn_mdata):
     """ This method makes the surrounding scan info available to all the puppies"""
     for puppy in self.puppy_list:
         scanned_loc = Location.scanned_location_list(puppy.location)
         scanned_content = list()
         for loc in scanned_loc:
             if lawn_mdata.get(loc) == None:
                 scanned_content.append(const.FENCE)
             else:
                 scanned_content.append(lawn_mdata.get(loc))
         puppy.scanned_data = scanned_content
Esempio n. 2
0
 def make_scan_data_available(self, lawn_mdata):
     """ This method makes the surrounding scan info available to all the lawnmowers"""
     for lawnmower in self.lawnmowers:
         curr_loc = lawnmower.get_lawnmower_current_location()
         scanned_loc = Location.scanned_location_list(curr_loc)
         scanned_content = list()
         for loc in scanned_loc:
             if lawn_mdata.get(loc) == None:
                 scanned_content.append(const.FENCE)
             else:
                 scanned_content.append(lawn_mdata.get(loc))
         lawnmower.scanned_data = scanned_content
         lawnmower.loc_content = lawn_mdata.get(lawnmower.current_location)
Esempio n. 3
0
    def move(self):
        #print("Scan by Puppy: ", self.scanned_data)
        scan_list = self.scanned_data
        loc_list = Location.scanned_location_list(self.location)
        #print "loc list : ", loc_list
        possible_move = list()
        for i in range(8):
            if scan_list[i] == const.GRASS or scan_list[i] == const.EMPTY:
                possible_move.append(loc_list[i])

        if len(possible_move):
            loc_id = random.randint(0, (len(possible_move) - 1))
            self.set_obstacle_location(possible_move[loc_id])
            print("Puppy: moved to ", possible_move[loc_id])
            return possible_move[loc_id]

        return [0, 0]