/* Initialize all pilots */ void reinit_pilots(void) { int plr,r; dllist_free(pilot_list,NULL); pilot_list = 0; for(plr=0;plr<4;plr++) { memset (&players[plr].pilot, 0, sizeof (Pilot)); init_walker(&players[plr].pilot.walker); players[plr].pilot.walker.physics.radius = PILOT_STD_RADIUS; for (r = 0; r < 3; r++) players[plr].pilot.sprite[r] = pilot_sprite[plr][r]; players[plr].pilot.attack_vector = makeVector(1,0); } }
/* Create a basic ground critter */ static struct Critter *make_base_gc(SDL_Surface **gfx,float x,float y) { struct Critter *c = make_base(gfx); c->type = GROUNDCRITTER; init_walker(&c->walker); c->physics.x = x; c->physics.y = y; c->physics.radius = 6; c->physics.mass = 12; c->walker.walking = rand()%2?-1:1; c->walker.walkspeed = 1; c->walker.slope = 5; c->ship = 0; c->timer = 1; c->timerfunc = gc_dosomething; c->die = gc_die; return c; }
int main (int argc, char **argv) { int solver, direction = NORTH, steps = 0; maze_t* maze; walker_t* walker; if (argc < 2){ printf("Error: filename should be an argument"); return 0; } maze = read_maze(argv[1]); walker = init_walker(maze); printf("[0] Random solver\n[1] Left-hand solver\n[2] Breadcrum solver\n" "Choice: "); scanf("%d", &solver); while ((*maze).solved != 1){ switch(solver){ case 0: direction = random_solver(maze, walker, direction); break; case 1: direction = left_hand_solver(maze, walker, direction); break; case 2: direction = breadcrum_solver(maze, walker, direction); break; default: printf("Error: that's not a choice\n"); return 0; } steps++; print_maze(maze); if (steps >= MAX_STEPS) break; } if ((*maze).solved == 1) printf("Found exit in %d steps\n", steps); else printf("\nCould not find exit after %d steps\n", steps); return 0; }
/* * In this function the input gets checked and the other functions are called * in the correct order. */ int main (int argc, char **argv) { maze_t* maze; char *solver[] = {"random solver", "smart random solver", "left wall solver", "right wall solver" }; walker_t* walker; int i, count, dir, printmaze; if (argc < 2) { printf("The filename of the maze should be passed as an argument\n"); return 0; } if (argc > 2) { i = atoi(argv[2]); if (i < 0) { printf("Don't use negative numbers"); return 0; } } else i = 0; if (argc > 3) { printmaze = atoi(argv[3]); } else printmaze = 1; for(; i < AMNT_SOLVERS; i++) { srand(SEED); dir = NORTH; maze = read_maze(argv[1]); walker = init_walker(maze); count = 0; while (count < MAX_STEPS) { count++; switch(i) { case 0: dir = random_solver(maze, walker); break; case 1: dir = smart_random_solver_1(maze, walker, dir); break; case 2: dir = left_wall_solver(maze, walker, dir); break; case 3: dir = right_wall_solver(maze, walker, dir); break; } if(printmaze) { print_maze(maze, walker->row, walker->col); printf("%d\n", count); } if (at_exit(maze, walker)) break; } if (count < MAX_STEPS) printf("Found exit using the %s after %d steps\n", solver[i], count); printf("Press key to continue\n"); getchar(); } return 0; }
int main (int argc, char **argv) { program_name = argv[0]; /* Set locale according to user's wishes. */ setlocale (LC_ALL, ""); /* Tell program which translations to use and where to find. */ bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); for (;;) { int optc = getopt_long (argc, argv, "i:x:l:m:d:p:", long_options, (int *) 0); if (optc < 0) break; switch (optc) { case 0: break; case 'i': include_languages (optarg); break; case 'x': exclude_languages (optarg); break; case 'l': language_save_arg (optarg); break; case 'm': lang_map_file_name = optarg; break; case 'd': set_default_language (optarg); break; case 'p': if (cw_dlink == 0) cw_dlink = init_walker (&idh); prune_file_names (optarg, cw_dlink); break; default: usage (); } } if (show_version) { printf ("%s - %s\n", program_name, PACKAGE_VERSION); exit (0); } if (show_help) help_me (); argc -= optind; argv += optind; if (argc == 0) { static char dot[] = "."; static char *dotp = dot; argc = 1; argv = &dotp; } language_getopt (); if (cw_dlink == 0) cw_dlink = init_walker (&idh); parse_language_map (lang_map_file_name); while (argc--) { struct file_link *flink = parse_file_name (*argv++, cw_dlink); if (flink) walk_flink (flink, 0); } mark_member_file_links (&idh); obstack_init (&tokens_obstack); scan_files (&idh); return 0; }