Esempio n. 1
0
def print_board(x_max=32,y_max=32):
    """note x_max and y_max are then number of tiles printed in that 
        direction"""
    for y in range(y_max):
        for x in range(x_max):
            print "%2x|" % tworld.get_tile(x,y)[0],
        print "\n",
        for x in range(x_max):
            print "%2x|" % tworld.get_tile(x,y)[1],
        print "\n",
    print "\n"
Esempio n. 2
0
 def update(self):
     '''update our state based on the things we can see'''
     
     if cfg.opts.agent_memoryless:
         self.init_board_knowledge()
 
     vision = cfg.opts.vision
     self.tick += 1
     
     x,y=get_chips_location()
     
     #if near edge, screen won't center around you
     x=max(min(x,31-vision),vision)
     y=max(min(y,31-vision),vision)
     
     self.chips_visable=0
     for x2 in range(max(0, x-vision), min(32, x+vision+1)):
         for y2 in range(max(0, y-vision), min(32, y+vision+1)):
             top, bot = tw.get_tile(x2, y2)
             self.top[y2][x2]=top
             self.bottom[y2][x2]=bot
             if top==tw.Exit or bot==tw.Exit:
                 self.can_see_goal = True
             if tw.ICChip in (top, bot):
                 self.chips_visable += 1
Esempio n. 3
0
def get_chips_location():
    chip = (tw.Chip_North, tw.Chip_West, tw.Chip_South, tw.Chip_East, tw.Swimming_Chip_West, tw.Swimming_Chip_East, tw.Swimming_Chip_North, tw.Swimming_Chip_South, tw.Pushing_Chip_North, tw.Pushing_Chip_West, tw.Pushing_Chip_East, tw.Pushing_Chip_South)
    for x in range(32):
        for y in range(32):
            top, bot = tw.get_tile(x,y)
            if top in chip:
                return (x,y)
    print "error chip isn't on the board?"
    print_board()