Пример #1
0
    def __init__(self, fileName, network_name):
        Rover.__init__(self)
        self.d = Data()
        self.userInterface = Pygame_UI()
        self.clock = pygame.time.Clock()
        self.FPS = 30
        self.image = None
        self.network_name = network_name
        self.quit = False
        self.paused = False
        self.angle = 0
        self.treads = [0, 0]
        self.timeStart = time.time()
        self.filename = fileName
        #fileName = glob.glob('/home/TF_Rover/RoverData/*.index')
        #fileName = fileName[0]

        if '1frame_Color' in self.filename:
            self.channs = 3
            self.im_method = 0
        elif '3frames' in self.filename:
            self.channs = 3
            self.im_method = 1
            self.framestack = np.zeros([1, 130, 320, self.FPS])
            self.stack = [0, 5, 15]
        elif '1frame_Gray' in self.filename:
            self.channs = 1
            self.im_method = 2

        self.network = input_data(shape=[None, 130, 320, self.channs])
        self.network = self.network_name(self.network, drop_prob=1.0)
        self.model = tflearn.DNN(self.network)
        self.model.load(self.filename)
        self.run()
Пример #2
0
    def process_rovers(self, instructions: list) -> list:
        """
        Read file and load the instructions
        """
        rovers = []

        line_number = 1

        boundaries = instructions[0].split(' ')

        #interate through all rover instructions and apply it to the coordinates
        while line_number < len(instructions):

            start_point = instructions[line_number].split(' ')

            instruction = instructions[line_number + 1].rstrip()

            line_number += 2

            rover = Rover(int(boundaries[0].rstrip()),
                          int(boundaries[1].rstrip()),
                          int(start_point[0].rstrip()),
                          int(start_point[1].rstrip()),
                          start_point[2].rstrip())

            rover.move_to_target(instruction)

            rovers.append(rover.to_dict())
        return rovers
Пример #3
0
def rotate_and_check_position(initial_coordinates, initial_direction, command, new_direction):
    rover = Rover(*initial_coordinates, direction=initial_direction)

    rover.move(command)
    assert rover.position == (initial_coordinates[0],   # x
                              initial_coordinates[1],   # y
                              new_direction)            # direction
Пример #4
0
 def test_rover_explore_with_only_move(self):
     land = LandGrid(5, 5)
     rover = Rover(land)
     expected_position = '1 4 N'
     rover.explore(1, 2, 'N', 'MM')
     ending_position = rover.get_rover_position()
     self.assertEqual(ending_position, expected_position)
Пример #5
0
def test_rover_invalid_command_doesnt_move():
    x, y, direction = 4, 2, "EAST"
    rover = Rover(position=(x, y, direction))
    with pytest.raises(ValueError):
        rover.send_command("FTF")

    assert rover.position == (x, y, direction)
Пример #6
0
def test_rover_multiple_commands_ending_position():
    rover = Rover()
    rover.commands('mf', 'mf', 'rr', 'mb', 'rr', 'mf', 'rl')
    assert rover.x == -1
    assert rover.y == 1
    assert rover.orientation == 'e'
    print(rover)
Пример #7
0
def main(argv=None):
    # parse command line options
    if argv is None:
        argv = sys.argv

    count = 0
    if len(argv) == 1:
        count = 1
    elif len(argv) > 1:
        if argv[1] == "-h" or argv[1] == "--help":
            print(textwrap.dedent(__doc__))
        elif argv[1].isdigit():
            count = int(argv[1])
        else:
            print "Invalid syntax: " + "".join((" " + s) for s in argv)
            print "Use -h or --help for Help"

    if count > 0:
        final_positions = ""
        try:
            plateau = MartianPlateau(raw_input("Plateau:"))
            for c in range(1, count + 1):
                rover = Rover(raw_input("Rover" + str(c) + " Landing:"),
                              plateau)
                output = rover.instruct(
                    raw_input("Rover" + str(c) + " Instructions:"))

                # Put together the final output for the program
                final_positions += "\nRover" + str(c) + ":" + output

            print final_positions

        except Exception as e:
            print e.message
            raise e
Пример #8
0
def test_rover_can_go_forward_twice_going_north():
    rov = Rover(
        pos=Vector(x=0, y=0), planet_size=Vector(x=10, y=10), dir=Direction.NORTH
    )
    rov.forward()
    rov.forward()
    assert rov.pos == Vector(x=0, y=2)
Пример #9
0
def test_stop_at_obstacle( command, position):
    obstacle1_coordinate = Coordinate(0, 4)
    obstacle2_coordinate = Coordinate(2 ,0)

    grid = Grid([obstacle1_coordinate, obstacle2_coordinate])
    rover_obj = Rover(grid)
    assert rover_obj.execute(command) == position
Пример #10
0
    def test_rover_move_when_it_can_not(self):
        rover = Rover(0, 0, 'S', self.plateau)
        rover.move()

        self.assertEqual(rover.x, 0)
        self.assertEqual(rover.y, 0)
        self.assertEqual(rover.orientation, ORIENTATION_MAP['S'])
Пример #11
0
 def test_receives_position_direction_and_map(self):
     map = PlanetMap(10, 10)
     rover = Rover(map, 0, 0, Direction.NORTH)
     self.assertIsNotNone(rover)
     self.assertEqual(rover.get_x(), 0)
     self.assertEqual(rover.get_y(), 0)
     self.assertEqual(rover.get_direction().value, 'N')
Пример #12
0
    def test_rover_can_move_and_turn_batch(self):
        grid = Grid(3, 3)
        location = Location(grid, 0, 0, direction.N)
        rover = Rover(location)

        rover.move(command.to_commands('ffrff'))
        self.assert_location(rover.location, 2, 2, direction.E)
Пример #13
0
def main(argv=None):
    # parse command line options
    if argv is None:
        argv = sys.argv

    count = 0
    if len(argv) == 1:
        count = 1
    elif len(argv) > 1:
        if argv[1] == "-h" or argv[1] == "--help":
            print (textwrap.dedent(__doc__))
        elif argv[1].isdigit():
            count = int(argv[1])
        else:
            print "Invalid syntax: " + "".join((" "+s) for s in argv)
            print "Use -h or --help for Help"

    if count > 0:
        final_positions = ""
        try:
            plateau = MartianPlateau(raw_input("Plateau:"))
            for c in range(1, count+1):
                rover = Rover(raw_input("Rover" + str(c) + " Landing:"), plateau)
                output = rover.instruct(raw_input("Rover" + str(c) + " Instructions:"))

                # Put together the final output for the program
                final_positions += "\nRover" + str(c) + ":" + output

            print final_positions

        except Exception as e:
            print e.message
            raise e
Пример #14
0
def move_and_check_position(initial_coordinates, initial_direction, command, offset):
    rover = Rover(*initial_coordinates, direction=initial_direction)

    rover.move(command)
    assert rover.position == ((initial_coordinates[0] + offset[0]) % rover.grid_x,  # x
                              (initial_coordinates[1] + offset[1]) % rover.grid_y,  # y
                              initial_direction)                   # direction
    def reset(self, lives: int, settings: dict, score: int):
        self._settings = settings
        self._arena = Arena((ARENA_W, ARENA_H))
        self._arena.add_to_score(score)
        Mountain(self._arena, (MOUNTAIN_X, MOUNTAIN_Y))
        Hill(self._arena, (HILL_X, HILL_Y), self._settings['level'])
        self._ground = Ground(self._arena, (GROUND_X, GROUND_Y), self._settings['difficulty'])
        self._start_time = time()
        self.bg_list = [Mountain, Hill, Ground]
        self._time_to_generate_alien = time()
        self._hero = []
        self._hero.append(Rover(self._arena, (ROVER_X, ROVER_Y), 1))
        if self._settings['mode'] == 'co-op':
            self._hero.append(Rover(self._arena, (ROVER_2_X, ROVER_2_Y), 2))

        self._start = time()
        self._playtime = 80
        self.hero_lives = lives
        self._aliens = []
        self._obstacles = []
        self._type_obstacles = [Rock, Hole]
        self._rand_x_bomb = 0
        self._time_to_generate_bomber = time()
        self._bomb_ready = False
        self._second = time()

        if self._settings['difficulty'] == 'Easy':
            self.OBS_RANGE = 400
        elif self._settings['difficulty'] == 'Normal':
            self.OBS_RANGE = 300
        else:
            self.OBS_RANGE = 200
Пример #16
0
    def test_rover_position_greater_than_plateau_should_raise_exception(self):
        rover = Rover(coord=(4, 0, 'E'))
        plateau = Plateau(upper_right=(3, 3), rovers=[rover])
        self.assertRaises(ValueError, plateau.rover_explore)

        rover = Rover(coord=(3, -1, 'E'))
        plateau = Plateau(upper_right=(3, 3), rovers=[rover])
        self.assertRaises(ValueError, plateau.rover_explore)
Пример #17
0
def main():
    rover = Rover()  # create rover
    bat = rover.get_battery_percentage(
    )  #Now that the rover is on and using the specific Rover class, you
    #can now type in the command for battery percentage (which can be found in the Rover class).
    print('Battery level: %d%%' %
          bat)  #Now tell it to give you the percentage.
    rover.close()  # close rover
Пример #18
0
def main():
    if len(sys.argv) != 2:
        print("Usage: ./rover-control.py [ip address]")
        sys.exit(1)

    ip = sys.argv[1]
    rover = Rover(ip)
    rover.run()
Пример #19
0
    def test_command_other_path(self):

        rover = Rover(P(0,0),'N')
        control = RemoteControl(rover)
        control.execute('ffrff')

        self.assertEqual(rover.get_position().x, 2)
        self.assertEqual(rover.get_position().y, 2)
Пример #20
0
    def test_should_be_able_to_turn_around(self):
        r = Rover(orientation=Orientation.North)

        r.turn(Turn.LEFT)
        r.turn(Turn.LEFT)
        r.turn(Turn.LEFT)
        r.turn(Turn.LEFT)
        self.assertEquals(r.orientation, Orientation.North)
Пример #21
0
    def test_command_string(self):

        rover = Rover(P(0,0),'N')
        control = RemoteControl(rover)
        control.execute('f')

        self.assertEqual(rover.get_position().x, 0)
        self.assertEqual(rover.get_position().y, 1)
Пример #22
0
 def test_fails_on_include(self):
     """
     tests that the parser fails on include lines (includes are no longer allowed)
     """
     
     r = Rover('')
     r.parse_config(StringIO('@include big_mess.csv'))
     self.assert_(len(r.config_errors) > 0)
Пример #23
0
    def test_fails_on_unsupported_vcs(self):
        """
        tests that the parser fails if an unsupported vcs is specified
        """

        r = Rover('')
        r.parse_config(StringIO('acme/project9, HEAD, blah'))
        self.assert_(len(r.config_errors) > 0)
Пример #24
0
    def test_rover_can_go_west_21_times_and_report_correct_output(self):
        rover = Rover(0, 0)
        for _ in range(20):
            rover.go_west()

        output = rover.output
        expected_output = {"x": -20, "y": 0}
        self.assertEqual(output['position'], expected_output)
Пример #25
0
 def __init__(self, mode):
     #self.file_name = 'filename'
     self.mode = mode
     self.image = None
     if (mode == "R"):
         Rover.__init__(self)
         # Receive images on another thread until closed
         self.is_active = True
         self.reader_thread = MediaThreadEx(self)
Пример #26
0
    def test_rover_load_repos(self):
        """Test that load repos correctly loads into factory_map"""

        r = Rover('')
        self.assertTrue('github' not in r.factory_map)

        repofile = StringIO("github, git, git://github.com/wgen/")
        r.load_repos(repofile)
        self.assertTrue('github' in r.factory_map)
Пример #27
0
    def test_command_top_left_from_S(self):
        map = Map(10,10)
        rover = Rover(P(0,0),'S',map)

        control = RemoteControl(rover)
        control.execute('t')

        self.assertEqual(rover.get_position().x, 10)
        self.assertEqual(rover.get_position().y, 10)
Пример #28
0
 def __init__(self, mode):
     #self.file_name = 'filename'
     self.mode = mode
     self.image = None
     if (mode == "R"):
         Rover.__init__(self)
         # Receive images on another thread until closed
         self.is_active = True
         self.reader_thread = MediaThreadEx(self)
Пример #29
0
 def test_fails_on_formatting_error(self):
     """
     tests that the parser fails if a config line is formatted incorrectly
     (e.g. wrong number of items)
     """
     
     r = Rover('')
     r.parse_config(StringIO('acme/project9, HEAD'))
     self.assert_(len(r.config_errors) > 0)
Пример #30
0
def move_and_check_position(initial_coordinates, initial_direction, command,
                            offset):
    rover = Rover(*initial_coordinates, direction=initial_direction)

    rover.move(command)
    assert rover.position == (
        (initial_coordinates[0] + offset[0]) % rover.grid_x,  # x
        (initial_coordinates[1] + offset[1]) % rover.grid_y,  # y
        initial_direction)  # direction
Пример #31
0
 def test_3(self):
     rover = Rover(5, 5)
     self.assertRaises(Exception, rover.setoperations, str("MMRMKLMMLM"))    # invalid character in commands
     rover.setstart('1 1 N')                                     # start the rover at 1 1
     rover.setoperations('MMMMMM')                               # move the rover out of bounds positively
     self.assertRaises(Exception, rover.operate)                 # execute the operation and throw an error
     rover.setstart('1 1 S')                                     # start the rover at 1 1 facing south
     rover.setoperations('MMM')                                  # move 3 spaces down
     self.assertRaises(Exception, rover.operate)                 # check for a negative exception
Пример #32
0
def rotate_and_check_position(initial_coordinates, initial_direction, command,
                              new_direction):
    rover = Rover(*initial_coordinates, direction=initial_direction)

    rover.move(command)
    assert rover.position == (
        initial_coordinates[0],  # x
        initial_coordinates[1],  # y
        new_direction)  # direction
Пример #33
0
    def test_move_forward_to_beyond_the_borders(self, m_logger):
        """
        If Rover exceed a border, a warning is raised.
        """
        rover = Rover(0, 0, Heading.W, self.plateau)
        rover.execute(Command.M)

        m_logger.assert_called_once_with(
            'Do you can go beyond the borders? '
            'Maybe you need to talk with mission control.')
Пример #34
0
class RoverTestCase:
    # initial creation of the roverobject:
    planet = Planet(100, 100)
    planet.addobstacle(0, 1)
    rover = Rover(0, 0, 'N', planet)

    givecommands = ['f', 'f', 'r', 'f',
                    'f']  # these are the commands that should be executed
    Rover.readcommands(rover, givecommands, planet)
    Rover.giveroverlocation(rover)
Пример #35
0
    def test_fails_on_unsupported_vcs(self):
        """
        tests that the parser fails if an unsupported vcs is specified
        """

        r = Rover('')
        r.parse_config(StringIO('acme/project9, HEAD, blah'))
        self.assertEqual('unknown repository: "acme/project9, HEAD, blah"'
                , r.config_errors[0])
        self.assertTrue(len(r.config_errors) <= 1)
Пример #36
0
    def test_rover_can_move(self):
        grid = Grid(3, 3)
        location = Location(grid, 1, 1, direction.W)
        rover = Rover(location)

        rover.move(command.F)
        self.assert_location(rover.location, 0, 1, direction.W)

        rover.move(command.F)
        self.assert_location(rover.location, 2, 1, direction.W)
Пример #37
0
    def test_rover_can_wrap(self):
        grid = Grid(3, 3)
        location = Location(grid, 0, 0, direction.N)
        rover = Rover(location)

        rover.move(command.B)
        self.assert_location(rover.location, 0, 2, direction.N)

        rover.move(command.to_commands('lf'))
        self.assert_location(rover.location, 2, 2, direction.W)
Пример #38
0
 def test_rover_right(self):
     r = Rover('Roverx', (0, 0), 'N')
     r.right()
     self.assertEqual(r.facing_diection, 'E', "right to N -> E")
     r.right()
     self.assertEqual(r.facing_diection, 'S', "right to E -> S")
     r.right()
     self.assertEqual(r.facing_diection, 'W', "right to S -> W")
     r.right()
     self.assertEqual(r.facing_diection, 'N', "right to W -> N")
Пример #39
0
    def start(self):
        # Welcome
        print('** Welcome to NASA\'s Rover Program **')

        # Get the maximum coordinates of the plateau
        plateaucoords = input(
            "Enter the plateau\'s maximum coordinates in 'X Y' format:\n")
        # Set the maximum coordinates of the plateau
        self.setplateau(plateaucoords)
        plateau = self.getplateau()

        # Get rover inputs
        roverstart = input(
            "Enter the Rover\'s start coordinates and heading in 'X Y H' format:\n"
        )
        roverinstructions = input(
            "Enter the Rover\'s instructions consisting of L, R and M in a string:\n"
        )
        # rovertwostart = input("Enter Rover Two\'s start coordinates and heading in 'X Y H' format:\n")
        # rovertwoinstructions = input("Enter Rover Two\'s start coordinates consisting of L, R and M in a string:\n")

        # Set up the rovers
        rover = Rover(plateau[0], plateau[1])
        rover.setstart(roverstart)
        rover.setoperations(roverinstructions)

        # Run the rovers
        rover.operate()

        # Print results
        print(rover.getposition())
Пример #40
0
 def test_fails_on_formatting_error(self):
     """
     tests that the parser fails if a config line is formatted incorrectly
     (e.g. wrong number of items)
     """
     
     r = Rover('')
     r.parse_config(StringIO('acme/project9, HEAD'))
     self.assertEqual('invalid config line: "acme/project9, HEAD"'
             , r.config_errors[0])
     self.assertTrue(len(r.config_errors) <= 1)
Пример #41
0
    def __init__(self):
        # Rover instances
        self.curiosity = Rover('curiosity')
        self.opportunity = Rover('opportunity')
        self.spirit = Rover('spirit')

        # Flags
        self.main_flag = True
        self.rover_flag = True

        self.choice = 0
Пример #42
0
    def test_rover_can_detect_obstacle(self):
        grid = Grid(3, 3)
        grid.place_obstacle(0, 2)

        location = Location(grid, 0, 0, direction.N)
        rover = Rover(location)

        rover.move(command.to_commands('fff'))
        self.assert_location(rover.location, 0, 1, direction.N)
        self.assertEquals(1, rover.last_moved_steps)
        self.assertTrue(rover.faced_obstacle)
Пример #43
0
def test_move_world():
    rovers = [
        Rover(Position(x=1, y=2, heading='N'), Plateau(max_x=5, max_y=5)),
        Rover(Position(x=3, y=3, heading='E'), Plateau(max_x=5, max_y=5))
    ]
    world = World(Plateau(5, 5))
    world.rovers = rovers
    world.instructions = ["LMLMLMLMM", "MMRMMRMRRM"]
    world.follow_instructions()
    assert world.rovers[0].position == Position(1, 3, 'N')
    assert world.rovers[1].position == Position(5, 1, 'E')
Пример #44
0
    def test_lower_bounds(self):
        rover = Rover("0 0 S")
        rover.send_instructions("M")
        self.assertEqual((0, 0), rover.get_position())

        rover.send_instructions("RM")
        self.assertEqual("W", rover.get_heading())
        self.assertEqual((0, 0), rover.get_position())
Пример #45
0
def init_rover(line):
    try:
        line = line.split()
        if len(line) != 3 or len(line[2]) != 1 or line[2] not in DIRECTIONS.keys():
            raise ValueError
        pos = [int(line[0]), int(line[1])]
        rover = Rover(pos, line[2])
    # ValueError also catch content not parsable as int
    except ValueError:
        bad_format("unsigned-integer unsigned-integer S|N|E|W")
    rover.assert_position_validity()
    return rover
Пример #46
0
def test_rover_move_single():
    plateau = MartianPlateau("10 10")
    start_locs = ["5 5 N", "5 5 E", "5 5 S", "5 5 W"]
    new_locs = [[5, 6, "N"], [6, 5, "E"], [5, 4, "S"], [4, 5, "W"]]

    for s, n in zip(start_locs, new_locs):
        rvr = Rover(s, plateau)
        output = rvr.instruct("M")
        print output
        assert rvr.get_x() == n[0]
        assert rvr.get_y() == n[1]
        assert rvr.get_facing() == n[2]
Пример #47
0
    def test_place_rover(self):
        mars = Mars("5 5")

        rover = Rover("1 1 N")
        mars.place_rover(rover)

        self.assertEqual([rover], mars.get_rovers())

        rover2 = Rover("6 1 N")
        mars.place_rover(rover2)

        self.assertEqual([rover], mars.get_rovers())
Пример #48
0
def test_if_rover_was_correctly_moved_over_boundary(Rover, Plateau):
    plat = Plateau(5, 5)
    rover = Rover(1, 2, 'N', plat)
    rover.change_position('M')
    assert rover.position_y == 3
    rover.change_position('M')
    assert rover.position_y == 4
    rover.change_position('M')
    rover.change_position('M')
    rover.change_position('M')
    assert rover.position_y == 5
    assert rover.position_x == 1
Пример #49
0
def test_rover_move_example():
    plateau = MartianPlateau("5 5")
    start_locs = ["1 2 N", "3 3 E", ]
    instructions = ["LMLMLMLMM","MMRMMRMRRM"]
    new_locs = [[1, 3, "N"], [5, 1, "E"]]

    for s, i, n in zip(start_locs,instructions, new_locs):
        rvr = Rover(s, plateau)
        output =rvr.instruct(i)

        assert rvr.get_x() == n[0]
        assert rvr.get_y() == n[1]
        assert rvr.get_facing() == n[2]
Пример #50
0
    def test_from_movement(self):
        rover = Rover(P(50,50),'N')

        rover.turn_right()

        rover.go_forward() # (51,50)
        rover.go_forward() # (52,50)

        rover.turn_left()

        rover.go_backward() # (52,49)
        rover.go_backward() # (52,48)

        self.assertEqual(rover.get_position().x, 52)
        self.assertEqual(rover.get_position().y, 48)
Пример #51
0
def test_rover_constructor_correct():
    """Tests calling inputting invalid coordinates to get_location()
    """
    landing_strings = ["02 2 N", "0 0 S", "33 44 E", "777 888 W"]
    landing_list = [[2, 2, "N"], [0, 0, "S"], [33, 44, "E"], [777, 888, "W"]]
    plateau = MartianPlateau("1000 1000")

    for landing, landing_l in zip(landing_strings, landing_list):
        try:
            rvr = Rover(landing, plateau)
            assert rvr.get_x() == landing_l[0]
            assert rvr.get_y() == landing_l[1]
            assert rvr.get_facing() == landing_l[2]
        except ImproperLanding:
            print landing
            assert False
Пример #52
0
def test_get_instruction_error():
    """Tests calling inputting invalid coordinates to get_location()
    """
    instr_strings =["l", "m", "r", "La", "L M", "M R", " LM ", "aM", "q    R"]
    plateau = MartianPlateau("1000 1000")
    rvr = Rover("100 100 N", plateau)

    for instr in instr_strings:
        try:
            rvr = Rover("100 100 N", plateau)
            rvr.instruct(instr)
        except ImproperInstruction:
            assert True
        else:
            print instr
            assert False
Пример #53
0
    def test_svn_exclude_naive(self):

        self.list_contents = {}
        self.list_contents['acme/project9/module'] = ['pk', 'cli', 'rab', 'api']

        r = Rover('')
        r.config_items = _list_as_rover_items(
                         [('acme/project9/module', 'HEAD', 'svn', 'http://foo.com'),
                          ('acme/project9/module/rab', 'HEAD', 'svn', 'http://bar.com')])
        r.resolve()
        
        expected = _list_as_rover_items(
                   [('acme/project9/module/pk', 'HEAD', 'svn', 'http://foo.com'),
                    ('acme/project9/module/cli', 'HEAD', 'svn', 'http://foo.com'),
                    ('acme/project9/module/api', 'HEAD', 'svn', 'http://foo.com'),
                    ('acme/project9/module/rab', 'HEAD', 'svn', 'http://bar.com')])
       
        self.assertEquals(r.config_items, expected)
Пример #54
0
    def test_mixed__no_overlap(self):

        r = Rover('')
        r.set_includes(['acme/app/test/java'])
        r.set_excludes(['acme/project9'])
        r.config_items = _list_as_rover_items(
                         [('acme/project9', 'HEAD', 'cvs'),
                          ('acme/app/src/java', 'HEAD', 'cvs'),
                          ('acme/app/test/java', 'HEAD', 'cvs')])

        r.apply_filters()

        expected = _list_as_rover_items(
                   [('acme/app/test/java', 'HEAD', 'cvs')])

        self.assertEquals(r.config_items, expected)
Пример #55
0
    def test_command_other_string(self):

        rover = Rover(P(0,0),'E')
        control = RemoteControl(rover)
        control.execute('f')

        self.assertEqual(rover.get_position().x, 1)
        self.assertEqual(rover.get_position().y, 0)

        control.execute('b')

        self.assertEqual(rover.get_position().x, 0)
        self.assertEqual(rover.get_position().y, 0)

        control.execute('ff')

        self.assertEqual(rover.get_position().x, 2)
        self.assertEqual(rover.get_position().y, 0)

        control.execute('lfff')

        self.assertEqual(rover.get_position().x, 2)
        self.assertEqual(rover.get_position().y, 3)
Пример #56
0
    def test_rover_can_turn(self):
        grid = Grid(3, 3)
        location = Location(grid, 0, 0, direction.W)
        rover = Rover(location)

        rover.move(command.R)
        self.assert_location(rover.location, 0, 0, direction.N)

        rover.move(command.L)
        self.assert_location(rover.location, 0, 0, direction.W)

        rover.move(command.L)
        self.assert_location(rover.location, 0, 0, direction.S)
Пример #57
0
    def test_mixed__overlap__include_greater(self):

        r = Rover('')
        r.set_includes(['acme/app'])
        r.set_excludes(['acme/app/src/java/com/example/app/command'])
        r.config_items = _list_as_rover_items(
                         [('acme/project9', 'HEAD', 'cvs'),
                          ('acme/app/src/java', 'HEAD', 'cvs'),
                          ('acme/app/test/java', 'HEAD', 'cvs')])

        r.apply_filters()

        expected = _list_as_rover_items(
                   [('acme/app/src/java !acme/app/src/java/com/example/app/command', 'HEAD', 'cvs'),
                    ('acme/app/test/java', 'HEAD', 'cvs')])

        self.assertEquals(r.config_items, expected)
Пример #58
0
    def test_create_rover(self):
        rover = Rover(P(10,2),'N')
        self.assertEqual(rover.get_position().x, 10)
        self.assertEqual(rover.get_position().y, 2)
        self.assertEqual(rover.get_aspect(), 'N')

        second_rover = Rover(P(15,29),'S')
        self.assertEqual(second_rover.get_position().x, 15)
        self.assertEqual(second_rover.get_position().y, 29)
        self.assertEqual(second_rover.get_aspect(), 'S')