int main( int argc, char** argv ) { unsigned int my_seed = 1; t1 = create_terrain(); if ( argc > 1 ) my_seed = atoi( argv[1] ); if ( DO_PRINTF ) printf( "%s %d: seed: %u\n", argv[0], argc, my_seed ); generate_true_cost_map( t1, my_seed ); a1 = create_astar( t1 ); init_graphics( &argc, argv, t1 ); #ifdef DO_GRAPHICS glutMainLoop(); #else for( ; ; ) { #ifndef DO_GRAPHICS if ( path_done ) return 0; #endif my_idlea(); } #endif return 0; }
int main() { int array[15][25] = { {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}, {2,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2}, {2,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2}, {2,0,0,2,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,0,0,0,0,2}, {2,0,0,2,0,0,2,2,2,2,0,0,2,0,0,0,0,0,0,2,0,0,0,0,2}, {2,0,0,2,0,0,2,0,0,2,0,0,2,0,0,0,0,0,0,2,0,0,0,0,2}, {2,0,0,2,0,0,2,0,0,2,0,0,2,0,0,0,0,0,0,2,0,0,0,0,2}, {2,0,0,2,0,0,2,0,0,2,0,0,2,0,0,0,0,0,0,2,0,0,0,0,2}, {2,0,0,2,0,0,2,0,0,2,0,0,2,0,0,0,0,0,0,2,0,0,0,0,2}, {2,0,0,2,0,0,2,0,0,2,0,0,2,0,0,0,0,0,0,2,0,0,0,0,2}, {2,0,0,2,0,0,2,0,0,2,0,0,2,0,0,0,0,0,0,2,0,0,0,0,2}, {2,0,0,2,2,2,2,0,0,2,2,2,2,0,0,0,0,0,0,2,2,2,2,0,2}, {2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2}, {2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2}, {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}, }; struct maze_map *map = create_map((int*)array,25,15); struct A_star_procedure *astar = create_astar(maze_get_neighbors,maze_cost_2_neighbor,maze_cost_2_goal); show_maze(map,astar,1,1,4,10); show_maze(map,astar,1,1,11,10); show_maze(map,astar,1,1,4,1); destroy_map(&map); destroy_Astar(&astar); return 0; }
int luaNewBattleMap(lua_State *L){ string_t mapname = new_string(lua_tostring(L,-1)); struct mapdefine *def = get_mapdefine(mapname); if(def){ struct battlemap *map = calloc(1,sizeof(*map)); map->map = def->map; map->aoi = aoi_create(512,def->length,def->radius,&def->top_left,&def->bottom_right); map->astar = create_astar(_get_neighbors,_cost_2_neighbor,_cost_2_goal); PUSH_LUSRDATA(L,map); }else PUSH_NIL(L); return 1; }