int main(int argc, char **argv) { char *filename; int opt; int correct_args = 1; while ((opt = getopt(argc, argv, "spljP:Q:xn")) != -1) { switch ((char)opt) { case 'n': set_no_backups(); break; default: correct_args = 0; break; } } filename = argv[optind]; if (!filename || !correct_args) { print_help(argv[0]); exit(1); } set_filename(filename); yyin = fopen(filename, "r"); if (yyin == NULL) { fprintf(stderr, "Error: file not found.\n"); exit(2); } yyparse(); if (can_generate()) { generate_prolog(); generate_body(); generate_epilogue(); /* generate_c_constraints_prolog(); generate_c_constraints_body(); generate_c_constraints_epilogue(); */ } else { printf("No code generated.\n"); return 1; } return 0; }
map_location pathfind::find_vacant_tile(const gamemap& map, const std::vector<team>& teams, const unit_map& units, const map_location& loc, const unit* pass_check) { if (!map.on_board(loc)) return map_location(); std::set<map_location> pending_tiles_to_check, tiles_checked; pending_tiles_to_check.insert(loc); // Iterate out 50 hexes from loc for (int distance = 0; distance < 50; ++distance) { //Copy over the hexes to check and clear the old set std::set<map_location> tiles_checking; tiles_checking.swap(pending_tiles_to_check); //Iterate over all the hexes we need to check BOOST_FOREACH (const map_location &loc, tiles_checking) { tiles_checked.insert(loc); // If the unit cannot reach this area or it's not a castle but should, skip it. if (!pass_check || can_generate(map, teams, units, *pass_check, loc)) { // If the hex is empty, return it. if (units.find(loc) == units.end()) { return loc; } } map_location adjs[6]; get_adjacent_tiles(loc, adjs); BOOST_FOREACH (const map_location &loc, adjs) { if (!map.on_board(loc)) continue; // Add the tile to be checked if it hasn't already been and // isn't being checked. if (tiles_checked.find(loc) == tiles_checked.end()) { pending_tiles_to_check.insert(loc); } } } }