Esempio n. 1
0
 def test_route_y_down(self):
     code = """
     start at (90, 90)
     go south 10 blocks
     """
     create_route(code)
     route = Route.get_last_route()
     steps = [(s.x, s.y) for s in route.steps]
     assert steps[-1] == (90, 80)
Esempio n. 2
0
 def test_route_x_left(self):
     code = """
     start at (90, 90)
     go west 10 blocks
     """
     create_route(code)
     route = Route.get_last_route()
     steps = [(s.x, s.y) for s in route.steps]
     assert steps[-1] == (80, 90)
Esempio n. 3
0
def main():
    init_db()

    user_choice = input('''
            You can create routes and run robots in this app.
            The city map size 250 x 250 by default

            Please select mode:
                1. Predefined route (will be used system predefined route)
                2. User Input
            Anything else for exit
        ''')

    if int(user_choice) == 1:
        code = """
        start at (90, 90)
        go north 5 blocks
        turn right
        go west 25 blocks
        turn left
        go 3 blocks
        """
        create_route(code)
        route = Route.get_last_route()
        bender = Robot('Bender')
        steps = bender.follow_route(route)
        for x, y in steps:
            print('x={} y={}'.format(x, y))

    elif int(user_choice) == 2:
        command = input('>')
        route_created = create_route(command)
        if route_created:
            route = Route.get_last_route()
            bender = Robot('Bender')
            steps = bender.follow_route(route)
            for x, y in steps:
                print('x={} y={}'.format(x, y))
        else:
            print('Route errors')

    else:
        print('Good bye')
Esempio n. 4
0
 def test_turn_right(self):
     code = """
     start at (90, 90)
     go south 10 blocks
     turn right
     go 10 blocks
     """
     create_route(code)
     route = Route.get_last_route()
     steps = [(s.x, s.y) for s in route.steps]
     assert steps[-1] == (80, 80)