Exemplo n.º 1
0
    elif answer.lower() == 'west':
        if my_maze.getCurrent().getWest():
            my_maze.moveWest()
            print('You went', answer)
            print(my_maze.getCurrent())
        else:
            print('Direction invalid, try again')
            print(my_maze.getCurrent())
    elif answer.lower() == 'east':
        if my_maze.getCurrent().getEast():
            my_maze.moveEast()
            print('You went', answer)
            print(my_maze.getCurrent())
        else:
            print('Invalid direction, try again')
            print(my_maze.getCurrent())
    elif answer.lower() == 'south':
        if my_maze.getCurrent().getSouth():
            my_maze.moveSouth()
            print('You went', answer)
            print(my_maze.getCurrent())
        else:
            print('Invalid direction, try again')
            print(my_maze.getCurrent())
    elif answer.lower() == 'restart':
        my_maze.reset()
        print(my_rooms[0])
    if my_maze.atExit():
        print('You found the exit!')
        x = False
Exemplo n.º 2
0
#Room 4
my_rooms[7].setSouth(my_rooms[8])
my_rooms[8].setNorth(my_rooms[7])
#Room 4
my_rooms[8].setWest(my_rooms[9])
my_rooms[9].setEast(my_rooms[8])

my_rooms[9].setSouth(my_rooms[10])
my_rooms[10].setNorth(my_rooms[9])

if __name__ == '__main__':
    my_maze = Maze(my_rooms[0], my_rooms[10])
    while True:
        pos = my_maze.getCurrent()
        print(pos)
        my_maze.atExit()
        dir = input(
            'Enter direction to move north west east south restart\n').lower()
        if dir == 'north':
            my_maze.moveNorth()
        elif dir == 'south':
            my_maze.moveSouth()
        elif dir == 'east':
            my_maze.moveEast()
        elif dir == 'west':
            my_maze.moveWest()
        elif dir == 'restart':
            my_maze.reset()
        else:
            print('Invalid Input')