<s> """<STR_LIT>""" <EOL> from random import Random <EOL> from hamcrest import assert_that , contains , is_ <EOL> from mockito import mock <EOL> from pyherc . ai import a_star <EOL> from pyherc . config . dsl import LevelContext <EOL> from pyherc . data import Portal , Model , find_free_space , wall_tile <EOL> from pyherc . data . geometry import free_locations_around <EOL> from pyherc . generators . level . partitioners import grid_partitioning <EOL> from pyherc . generators . level . portal import PortalAdder <EOL> from pyherc . generators . level . room . catacombs import CatacombsGenerator <EOL> from pyherc . test . builders import LevelBuilder <EOL> from pyherc . test . matchers import continuous_path <EOL> FLOOR_TILE = <NUM_LIT:100> <EOL> WALL_TILE = <NUM_LIT:200> <EOL> EMPTY_TILE = None <EOL> class TestAStar ( ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> """<STR_LIT>""" <EOL> super ( ) . __init__ ( ) <EOL> def test_simple_path ( self ) : <EOL> """<STR_LIT>""" <EOL> level = ( LevelBuilder ( ) <EOL> . with_floor_tile ( FLOOR_TILE ) <EOL> . with_wall_tile ( EMPTY_TILE ) <EOL> . with_solid_wall_tile ( WALL_TILE ) <EOL> . build ( ) ) <EOL> path , connections , updated = a_star ( start = ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> goal = ( <NUM_LIT:5> , <NUM_LIT:1> ) , <EOL> a_map = level , <EOL> adjacent_nodes = free_locations_around ) <EOL> assert_that ( path , contains ( ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> ( <NUM_LIT:2> , <NUM_LIT:1> ) , <EOL> ( <NUM_LIT:3> , <NUM_LIT:1> ) , <EOL> ( <NUM_LIT:4> , <NUM_LIT:1> ) , <EOL> ( <NUM_LIT:5> , <NUM_LIT:1> ) ) ) <EOL> def test_going_around_wall ( self ) : <EOL> """<STR_LIT>""" <EOL> level = ( LevelBuilder ( ) <EOL> . with_floor_tile ( FLOOR_TILE ) <EOL> . with_wall_tile ( EMPTY_TILE ) <EOL> . with_solid_wall_tile ( WALL_TILE ) <EOL> . with_wall_at ( ( <NUM_LIT:12> , <NUM_LIT:8> ) ) <EOL> . with_wall_at ( ( <NUM_LIT:12> , <NUM_LIT:9> ) ) <EOL> . with_wall_at ( ( <NUM_LIT:12> , <NUM_LIT:10> ) ) <EOL> . with_wall_at ( ( <NUM_LIT:12> , <NUM_LIT:11> ) ) <EOL> . with_wall_at ( ( <NUM_LIT:12> , <NUM_LIT:12> ) ) <EOL> . with_size ( ( <NUM_LIT:20> , <NUM_LIT:20> ) ) <EOL> . build ( ) ) <EOL> path , connections , updated = a_star ( start = ( <NUM_LIT:10> , <NUM_LIT:10> ) , <EOL> goal = ( <NUM_LIT:15> , <NUM_LIT:10> ) , <EOL> a_map = level , <EOL> adjacent_nodes = free_locations_around ) <EOL> assert_that ( path , is_ ( continuous_path ( start = ( <NUM_LIT:10> , <NUM_LIT:10> ) , <EOL> destination = ( <NUM_LIT:15> , <NUM_LIT:10> ) , <EOL> level = level ) ) ) </s>
