Ejemplo n.º 1
0
from nav import Nav

AI = Nav()
#print(AI.location)
#AI.markWall(3)
#AI.markVisited((4,4))
x = AI.calculate()
'''
 0,0 --> 1,0
UP
1. blackout() --> void
2. Undo action
3. calculate() --> will give you a list of commands
4. proceed

when you call black out
1. wall off dest., mark as visited
2. Revert back to previous position (0,0)
2. calculate(): calculate how to go to next closest unvisited square
3. Return a set of commands

'''
Ejemplo n.º 2
0
    '''imgCenter = cam.getImage()
    imgLeft = cam_left.getImage()
    imgRight = cam_right.getImage()
    letterCenter = Visual.getLetter(imgCenter)'''
    #cam.saveImage("visionCenter.png", 100)
    #cam_left.saveImage("visionLeft.png", 100)
    #cam_right.saveImage("visionRight.png", 100)
    '''img = cv2.imread("visionCenter.png")
    testThreshold(img)    '''

    # letterRight = Visual.getLetter()
    # letterLeft = Visual.getLetter()

    successful = False
    while not successful:
        commands = AI.calculate()  # Get commands
        if len(commands) == 0:
            print('FINISHED MAZE!')
            sendEndGame()
            exit(0)
        if (len(commands) > 1):  # Backtracking (BFS)
            clearVictims()
            for i in range(len(commands)):
                if (i == len(commands) - 1):  # Last command
                    successful = goTileWithVictim(commands[i])
                else:
                    successful = goTile(commands[i])
                    frontObs = False
                update_sensors()
        else:
            successful = goTileWithVictim(commands[0], frontObs)