def test_simple_path(self): """ Test that a simple path can be found """ level = (LevelBuilder().with_floor_tile(FLOOR_TILE).with_wall_tile( EMPTY_TILE).with_solid_wall_tile(WALL_TILE).build()) path, connections, updated = a_star( start=(1, 1), goal=(5, 1), a_map=level, adjacent_nodes=free_locations_around) assert_that(path, contains((1, 1), (2, 1), (3, 1), (4, 1), (5, 1)))
def test_simple_path(self): """ Test that a simple path can be found """ level = ( LevelBuilder() .with_floor_tile(FLOOR_TILE) .with_wall_tile(EMPTY_TILE) .with_solid_wall_tile(WALL_TILE) .build() ) path, connections, updated = a_star( start=(1, 1), goal=(5, 1), a_map=level, adjacent_nodes=free_locations_around ) assert_that(path, contains((1, 1), (2, 1), (3, 1), (4, 1), (5, 1)))
def test_going_around_wall(self): """ Test that path can be found around a wall """ level = (LevelBuilder().with_floor_tile(FLOOR_TILE).with_wall_tile( EMPTY_TILE).with_solid_wall_tile(WALL_TILE).with_wall_at( (12, 8)).with_wall_at((12, 9)).with_wall_at( (12, 10)).with_wall_at((12, 11)).with_wall_at( (12, 12)).with_size((20, 20)).build()) path, connections, updated = a_star( start=(10, 10), goal=(15, 10), a_map=level, adjacent_nodes=free_locations_around) assert_that( path, is_( continuous_path(start=(10, 10), destination=(15, 10), level=level)))
def test_going_around_wall(self): """ Test that path can be found around a wall """ level = ( LevelBuilder() .with_floor_tile(FLOOR_TILE) .with_wall_tile(EMPTY_TILE) .with_solid_wall_tile(WALL_TILE) .with_wall_at((12, 8)) .with_wall_at((12, 9)) .with_wall_at((12, 10)) .with_wall_at((12, 11)) .with_wall_at((12, 12)) .with_size((20, 20)) .build() ) path, connections, updated = a_star( start=(10, 10), goal=(15, 10), a_map=level, adjacent_nodes=free_locations_around ) assert_that(path, is_(continuous_path(start=(10, 10), destination=(15, 10), level=level)))