Example #1
0
 def move_idk(self):
     adj = self.world.adjacents(self.pos)
     if self.goal in adj:
         return
     adj = [pos for pos in adj if not (pos in self.bad)]
     if adj == []:
         for pos in self.bad:
             gridpy.remove(pos)
         self.bad = {}
         adj = [pos for pos in adj if not (pos in self.bad)]
         #gridpy._debug(adj)
     adj.sort(key=lambda pos: self.world.distance(pos, self.goal.pos))
     while len(adj) > 0 and adj[0] == self.last_pos:
         self.bad[adj[0]] = True
         gridpy.plot(gridpy.YELLOW, adj[0])
         del adj[0]
     if len(adj) > 0:
         self.last_pos = self.pos
         self.move_to(adj[0])
Example #2
0
#gridpy.set_style(gridpy.NONE)

gridpy.title("A simple demo")
gridpy.show()

def cycle(list):
    while True:
        for item in list:
            yield item

rainbow = cycle([
    gridpy.CYAN,
    gridpy.YELLOW,
    gridpy.MAGENTA,
    gridpy.RED,
    gridpy.GREEN,
    gridpy.BLUE,
    gridpy.WHITE,
    gridpy.GREY,
])

while True:
    for c in xrange(gridpy.cols()):
        color = rainbow.next()
        for r in xrange(gridpy.rows()):
            location = (c, r)
            gridpy.plot(color, location)
            gridpy.update()
            gridpy.remove(location)
    #gridpy.clear()
Example #3
0
 def remove(self, pos):
     del self.items[pos]
     gridpy.remove(pos)