Esempio n. 1
0
    # draw room labels
    for row in range(cells):
        for col in range(cells):
            if grid[row][col] > 1:
                text = font.render(chr(65+grid[row][col]-2),True,black)
                screen.blit(text, [col*side,row*side])
   
    # helper things for bot
    bx,by = bot.getLoc()
    flatgrid = [i for l in grid for i in l]
    gridpts = [(x,y) for y in range(cells) for x in range(cells)]
    flatgrid = zip(gridpts,flatgrid)

    # make array of (loc, val) tuples for all goals in grid
    goals = [(l,v) for (l,v) in flatgrid if v > 1]
    bot.setGoals(goals)

    # make array of bot surroundings...'lasers' in cardinal directions
    botRange = 4
    surr = []
    #consider drawing botrange? (showing horizontal, vertical, etc. 'beams')
    # Generate points to analyze in surroundings
    
    for i in range(botRange):
        surr.append((bx+i,by))
        surr.append((bx-i,by))
        surr.append((bx,by+i))
        surr.append((bx,by-i))
        surr.append((bx-i,by-i))
        surr.append((bx+i,by-i))
        surr.append((bx-i,by+i))