Example #1
0
 def test_create(self):
     return
     for i in range(0, rlfl.MAX_PATHS):
         self.assertEqual(i, rlfl.path_fill_map(self.map, TORIGOS[1]))
     try:
         rlfl.path_fill_map(self.map, TORIGOS[1])
     except Exception as e:
         self.assertEqual(str(e), 'Unable to create pathmap: Too many maps')
         self.assertEqual(str(e.__class__), "<class 'rlfl.Error'>")
     else:
         self.fail('Expected Exception: Unable to create pathmap: Too many maps')
     rlfl.path_clear_all_maps(self.map)
     self.assertEqual(0, rlfl.path_fill_map(self.map, TORIGOS[1]))
Example #2
0
 def test_step_input(self):
     return
     pm = rlfl.path_fill_map(self.map, TORIGOS[1])
     test = (
         {
             'm': -1,
             'x': pm,
             'p': TORIGOS[1],
             's': 'Map not initialized'
         },
         {
             'm': self.map,
             'x': pm,
             'p': (-1, -1),
             's': 'Location out of bounds'
         },
         {
             'm': self.map,
             'x': -1,
             'p': TORIGOS[1],
             's': 'Uninitialized pathmap used'
         },
     )
     for i in test:
         try:
             pmap = rlfl.path_step_map(i['m'], i['x'], i['p'])
         except Exception as e:
             self.assertEqual(str(e), i['s'])
             self.assertEqual(str(e.__class__), "<class 'rlfl.Error'>")
         else:
             self.fail('Expected Exception: %s' % i['s'])
Example #3
0
 def test_input(self):
     test = (
         {
             'm': -1,
             'p': TORIGOS[1],
             's': 'Map not initialized'
         },
         {
             'm': self.map,
             'p': (-1, -1),
             's': 'Location out of bounds'
         },
     )
     for i in test:
         try:
             pmap = rlfl.path_fill_map(i['m'], i['p'])
         except Exception as e:
             self.assertEqual(str(e), i['s'])
             self.assertEqual(str(e.__class__), "<class 'rlfl.Error'>")
         else:
             self.fail('Expected Exception: %s' % i['s'])
     try:
         pmap = rlfl.path_fill_autoexplore_map(-1)
     except Exception as e:
         self.assertEqual(str(e), 'Map not initialized')
         self.assertEqual(str(e.__class__), "<class 'rlfl.Error'>")
     else:
         self.fail('Expected Exception: %s' % 'Map not initialized')
     try:
         pmap = rlfl.path_fill_custom_map(-1)
     except Exception as e:
         self.assertEqual(str(e), 'Map not initialized')
         self.assertEqual(str(e.__class__), "<class 'rlfl.Error'>")
     else:
         self.fail('Expected Exception: %s' % 'Map not initialized')
     try:
         rlfl.path_clear_map(-1, 0)
     except Exception as e:
         self.assertEqual(str(e), 'Map not initialized')
         self.assertEqual(str(e.__class__), "<class 'rlfl.Error'>")
     else:
         self.fail('Expected Exception: Map not initialized')
Example #4
0
                if self.map[row][col] != '#':
                    p = (row, col)
                    # Set non-wall grids as open and seen
                    rlfl.set_flag(self.mapnum, p, rlfl.CELL_SEEN) 
                    rlfl.set_flag(self.mapnum, p, rlfl.CELL_OPEN)

if __name__ == '__main__':
    example = Project_example()
    example.create_map('pmap')
    
    # Define origin
    origin = example.origos[6]
    
    # Create a path map. example.origos[6] is a point on the map
    # that is the origin
    path_map_n = rlfl.path_fill_map(example.mapnum, origin, 0.7)
    
    # Bootstrap
    p = example.origos[4]
    
    # Create a path at most 90 steps long TOWARDS origin
    path = []
    for i in range(90):
        p = rlfl.path_step_map(example.mapnum, path_map_n, p)
        path.append(p)
        if p == origin:
            break
    example.print_map(path, example.origos[1], origin)
    
    # clear the path map 
    rlfl.path_clear_map(example.mapnum, path_map_n)