int main (int argc, char *argv[]) { int error; error = 0; error = initialisation (argc, argv); #if defined(GTK) if (!error) { if (game_asked ()) { while (play_game ()); } else { build_gtk_interface (argc, argv); } } #else // not defined(GTK) RomSelectStart(); if (!error) { if (game_asked ()) { while (1) { fprintf(stderr,"EMU START:\n"); play_game(); fprintf(stderr,"EMU END:\n"); } } else { printf ("No game specified\n"); } } #endif fprintf(stderr,"HuGo says bye!\n"); cleanup (); return 0; }
void start_game(char *fn) { char s[20]; FILE *fp; if((fp=fopen(fn, "rt")) == NULL) { message("Can't open file"); return; } fgets(s, sizeof(s), fp); chomp(s); if(strcmp(s, "TMAZE")) { message("Invalid map file (doesn't have signature)"); return; } if(read_in_mazes(fp)) { fclose(fp); return; } play_game(); fclose(fp); }
int main(int argc, char *argv[]) { std::cout.precision(2); std::cout.setf(std::ios::fixed,std::ios::floatfield); srand(static_cast<unsigned int>(time(nullptr))); Game game=OTHELLO; if (argc>1) game=parse_game(argv[1]); Board *board=choose_game(game); float p1time = static_cast<float>(1.); float p2time = static_cast<float>(1.); if (argc>2) p1time = parse_float(argv[2],p1time); if (argc>3) p2time = parse_float(argv[3],p2time); Player *player_a=new PlayerBot(PLAYER_1,p1time,0,0.2); Player *player_b=new PlayerBot(PLAYER_2,p2time,0,0.2); play_game(player_a,player_b,board); delete board; delete player_a; delete player_b; return 0; }
int main(int argc, char** argv){ start_game(); char continue_play; float player_loss_percent, player_win_percent, tie_percent; for(int count=0; count<MAX_GAMES; count++){ play_game(); who_wins(); if (count==MAX_GAMES-1){ printf("\nDo you wish to continue playing? y/n: "); scanf("%*[ \n\t]%c", &continue_play);// http://stackoverflow.com/questions/13542055/in-c-how-to-do-scanf-for-single-char if (tolower(continue_play)=='y'){ count = -1; } } } int total_count = player_loss_count+player_win_count +tie_count; player_loss_percent = 100*((float)player_loss_count/total_count); player_win_percent = 100*((float)player_win_count/total_count); tie_percent = 100-(player_win_percent+player_loss_percent); printf(" You won %d (%.1f%%) of %d games, lost %d (%.1f%c) and tied %d (%.1f%c)... ", player_win_count, player_win_percent, total_count, player_loss_count, player_loss_percent, '%', tie_count, tie_percent, '%'); if(player_win_percent>50) printf("Well done, congratulations!\n"); else if (player_win_percent<50) printf("Boohoo!\n"); else printf("Ah, you just got lucky\n"); }
int menu(t_assets *assets) { t_stats stats; int end; int play; int window; end = 0; play = 0; window = 0; srand(time(NULL)); while (!end) { if (Mix_PlayingMusic() != 1) Mix_PlayMusic(assets->sounds.menumusic, -1); events_menu(&play, &end, &window); show_menu(assets, &window, end, play); if (play) { init_stats(&stats); play_game(assets, &stats); show_stats(&stats); play = 0; Mix_PlayMusic(assets->sounds.menumusic, -1); } } return (0); }
int main(void) { char play_again; srand((unsigned) time(NULL)); if (play_game()){ win = win + 1; printf("You win!\n"); } else{ loss = loss + 1; printf("You lose!\n"); } printf("Play again?"); while ((play_again = getchar()) == '\n'){ } if (play_again == 'y' || play_again == 'Y'){ main(); } if (play_again == 'n' || play_again == 'N'){ printf("Wins: %d\tLosses: %d\n", win, loss); exit(0); } else{ printf("Invalid symbol\n"); return 0; } }
int main(){ // for(int i=0; i<20; i++){ // roll_dice(); // roll_dice(); // int result= 0; // result = roll_dice(); // printf("%d \n", result); // } play_game(); // printf("ASDGASDGASDG\n"); // play_game(); // printf("ASDGASDGASDG\n"); // play_game(); // printf("ASDGASDGASDG\n"); // play_game(); // printf("ASDGASDGASDG\n"); // play_game(); }
int start_new_game(void) { struct thread_data data = { NULL, 0, 0, PTHREAD_MUTEX_INITIALIZER, 0, 0 }; initialize_game_elements(); initialize_game_screen(); /* draw the next block, and the begin game message */ draw_next_block(next_block, next_block_orientation); if (draw_start_game() == FAILURE) return SUCCESS; draw_level_info(game_options.initial_level); /* create the worker thread */ if (pthread_create(&data.thread_id, NULL, worker_thread_fn, (void *)&data)) return FAILURE; /* the main thread for the core gameplay */ play_game(&data); pthread_join(data.thread_id, NULL); if (data.new_highscore) draw_highscore(global_highscore); return SUCCESS; }
static void enter_wait_mode(game_display& disp, const config& game_config, hero_map& heros, hero_map& heros_start, card_map& cards, config& gamelist, bool observe) { mp::ui::result res; game_state state; network_game_manager m; gamelist.clear(); statistics::fresh_stats(); gui2::tmp_side_wait dlg(heros, disp, *resources::game_map, game_config, gamelist, observe); dlg.show(disp.video()); switch (dlg.get_legacy_result()) { case gui2::tmp_side_wait::PLAY: res = mp::ui::PLAY; dlg.start_game(); state = dlg.get_state(); // lobby may modify hero's side_feature heros_start = heros; break; default: res = mp::ui::QUIT; } switch (res) { case mp::ui::PLAY: play_game(disp, state, game_config, heros, heros_start, cards, IO_CLIENT, preferences::skip_mp_replay() && observe); recorder.clear(); break; case mp::ui::QUIT: default: break; } }
int main(void) { char word[MAX_LEN + 1], category[MAX_LEN + 1], trivia[MAX_TRIVIA_LEN + 1], again; int games_played; game_init(); /* initialize the game with 7 lives */ for (;;) { get_word(word, category, trivia); /* generated a new word from the dictionary */ games_played = play_game(word, category, trivia); /* play the game */ printf("\nGames played: %d\n", games_played); printf("Play again? (y/n): "); again = getchar(); getchar(); if (again == 'n' || again == 'N') { system(CLEARSCREEN); break; } game_init(); } return 0; }
void on_ok_button1_clicked (GtkButton *button, gpointer user_data) { char* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fileselector_window)); DIR* dir = opendir(filename); if(dir != NULL) // selected file is a directory; change the directory { closedir(dir); gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fileselector_window), filename); } else // normal file selected; open the file and start the emulator { gtk_widget_hide(fileselector_window); CD_emulation = 0; strcpy( cart_name, gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fileselector_window))); /* * We need to flush any gtk events waiting to happen (like the widget hide * from above) to avoid a deadlock when starting a game fullscreen (at least * in linux). */ while (gtk_events_pending()) gtk_main_iteration(); play_game(); } }
int main(void) { bool play; int win = 0, lose = 0; char ch = 'y'; while(ch != 'n' && ch != 'N'){ play = play_game(); if(play){ printf("You win!\n"); win++; } else{ printf("You lose!\n"); lose++; } printf("Play again (y/n)? "); scanf(" %c", &ch); } printf("Wins: %d Losses: %d\n", win, lose); return 0; }
int main(int argc, char *argv[]) { CATCHALL(die); setlocale(LC_ALL, ""); initscr(); /* * We use COLOR_GREEN because COLOR_BLACK is wired to the wrong thing. */ start_color(); init_pair(RED_ON_WHITE, COLOR_RED, COLOR_WHITE); init_pair(BLUE_ON_WHITE, COLOR_BLUE, COLOR_WHITE); init_pair(BLACK_ON_WHITE, COLOR_BLACK, COLOR_WHITE); #ifndef COLOR_PAIR letters[0] = OR_COLORS('h', RED_ON_WHITE); /* hearts */ letters[1] = OR_COLORS('s', BLACK_ON_WHITE); /* spades */ letters[2] = OR_COLORS('d', RED_ON_WHITE); /* diamonds */ letters[3] = OR_COLORS('c', BLACK_ON_WHITE); /* clubs */ #if USE_CP437 glyphs[0] = PC_COLORS('\003', RED_ON_WHITE); /* hearts */ glyphs[1] = PC_COLORS('\006', BLACK_ON_WHITE); /* spades */ glyphs[2] = PC_COLORS('\004', RED_ON_WHITE); /* diamonds */ glyphs[3] = PC_COLORS('\005', BLACK_ON_WHITE); /* clubs */ #endif #endif #if USE_CP437 if (tigetstr("smpch")) suits = glyphs; #endif /* USE_CP437 */ cbreak(); if (argc == 2) srand((unsigned) atoi(argv[1])); else srand((unsigned) time((time_t *) 0)); init_vars(); do { deal_number++; shuffle(deck_size); deal_cards(); display_cards(deal_number); play_game(); } while ((deck_size = collect_discards()) != 0); game_finished(deal_number); die(SIGINT); /*NOTREACHED */ }
int main(int argc, char* argv[]) { signal(SIGINT, sigint_handler); #if !defined(NDEBUG) std::cout << "\t> Running in DEBUG mode" << std::endl; #endif #if defined(OPENMP_FOUND) omp_set_nested(true); std::cout << "\t> Running using OPENMP " << std::endl; std::cout << "\t\t> " << omp_get_max_threads() << " threads max" << std::endl; std::cout << "\t\t> " << omp_get_wtick()*1e9 << "ns tick" << std::endl; assert( omp_get_nested() ); #endif // test_random(); Rng rng; rng.seed(rand()); Options options = parse_options(argc, argv); typedef std::map<std::string, int> Wins; Wins wins; for (int kk=0; kk<options.number_of_games; kk++) { std::cout << std::endl << std::endl; std::cout << "****************************************" << std::endl; std::cout << "game " << kk << "/" << options.number_of_games << std::endl; const Game& game = play_game(options, rng); const int winner = game.state.get_winner(); if (winner < 0) wins["draw"]++; else { std::string winner_name = "bot"; if (game.hero_infos[winner].is_real_bot()) winner_name = game.hero_infos[winner].name; wins[winner_name]++; } std::cout << std::endl; std::cout << "after " << options.number_of_games << " games" << std::endl; for (Wins::const_iterator wi=wins.begin(), wie=wins.end(); wi!=wie; wi++) { if (wi->first == "draw") { std::cout << " " << wi->second << " draw" << std::endl; continue; } std::cout << " " << wi->second << " victory for " << wi->first << std::endl; } if (sigint_already_caught) break; } return 0; }
int main(int argc, char *argv[]) { FILE *out = stdout; struct options *options = options_alloc(argc, argv); if (options->error || options->help) { options_print_usage(options); return options->error? EXIT_FAILURE : EXIT_SUCCESS; } if (action_game == options->action) { play_game(options->rnd); } else if (action_tui == options->action) { run_tui(); } else { fprintf(out, "Fiends and Fortune\n"); switch (options->action) { case action_character: generate_character(options->rnd, out, options->character_method); break; case action_check: check(out, options->check_constant); break; case action_dungeon: if (options->dungeon_type_small) { generate_sample_dungeon(options->rnd, out); } else { generate_random_dungeon(options->rnd, out); } break; case action_each: generate_each_treasure(options->rnd, out); break; case action_magic: generate_magic_items(options->rnd, out, options->magic_count); break; case action_map: generate_map(options->rnd, out); break; case action_table: generate_treasure_type_table(out); break; case action_treasure: generate_treasure_type(options->rnd, out, options->treasure_type); break; default: fprintf(stderr, "%s: unrecognized option\n", options->command_name); break; } fprintf(out, "\n"); } options_free(options); alloc_count_is_zero_or_die(); return EXIT_SUCCESS; }
void match ( KalahPlayer top, KalahPlayer bottom ) { printf( "============ Game 1 ============\n" ); int game1 = play_game( top, bottom, TOP ); printf( "============ Game 2 ============\n" ); int game2 = play_game( top, bottom, BOTTOM ); printf( "================================\n\n" ); int top_score = game1 + game2; if ( top_score > ( MAX_SCORE / 2 ) ) printf( "TOP (%s) wins, %d to %d.\n", top.get_name(), top_score, MAX_SCORE - top_score ); else if ( top_score < ( MAX_SCORE / 2 ) ) printf( "BOTTOM (%s) wins, %d to %d.\n", bottom.get_name(), MAX_SCORE - top_score, top_score ); else printf( "TIE!\n" ); }
int main(int argc, char **argv) { (void)argc; (void)argv; init_move_tables(); init_score_tables(); play_game(find_best_move); return 0; }
int main(void) { setup_game(); play_game(); end_game(); return 0; }
int main(int argc, char *argv[]) { (void) signal(SIGINT, die); initscr(); /* * We use COLOR_GREEN because COLOR_BLACK is wired to the wrong thing. */ start_color(); init_pair(RED_ON_WHITE, COLOR_RED, COLOR_WHITE); init_pair(BLUE_ON_WHITE, COLOR_BLUE, COLOR_WHITE); init_pair(BLACK_ON_WHITE, COLOR_BLACK, COLOR_WHITE); #ifndef COLOR_PAIR letters[0] = 'h' | COLOR_PAIR(RED_ON_WHITE); /* hearts */ letters[1] = 's' | COLOR_PAIR(BLACK_ON_WHITE); /* spades */ letters[2] = 'd' | COLOR_PAIR(RED_ON_WHITE); /* diamonds */ letters[3] = 'c' | COLOR_PAIR(BLACK_ON_WHITE); /* clubs */ #if defined(__i386__) && defined(A_ALTCHARSET) glyphs[0] = '\003' | A_ALTCHARSET | COLOR_PAIR(RED_ON_WHITE); /* hearts */ glyphs[1] = '\006' | A_ALTCHARSET | COLOR_PAIR(BLACK_ON_WHITE); /* spades */ glyphs[2] = '\004' | A_ALTCHARSET | COLOR_PAIR(RED_ON_WHITE); /* diamonds */ glyphs[3] = '\005' | A_ALTCHARSET | COLOR_PAIR(BLACK_ON_WHITE); /* clubs */ #endif #endif #if defined(__i386__) && defined(A_ALTCHARSET) if (tigetstr("smpch")) suits = glyphs; #endif /* __i386__ && A_ALTCHARSET */ cbreak(); if (argc == 2) srand((unsigned)atoi(argv[1])); else srand((unsigned)time((time_t *)0)); init_vars(); do{ deal_number++; shuffle(deck_size); deal_cards(); display_cards(deal_number); play_game(); } while ((deck_size=collect_discards()) != 0); game_finished(deal_number); die(SIGINT); /*NOTREACHED*/ }
void newgame_menu(char logo[23][35], int colors[4]){ // izbor broja igraca int new_option=0,old_option=-1, key; int player_count=0, bot_count=-1, bot_level[2]={0}; int back=pick_player_number(&player_count,&bot_count,bot_level,logo); if (back) return; else play_game(player_count, bot_count, bot_level, colors, logo); //high score update ??? return; }
void angbandThread(void *arg) { bool new_game = FALSE; int show_score = 0; char player_name_aga[32]; /* Save the "program name" */ argv0 = (char*)arg; /* Use the "main-emx.c" support */ init_emx(); ANGBAND_SYS = "ibm"; /* Get the file paths */ init_stuff(); if (!emx_options((char**)&ANGBAND_DIR_USER, (char**)&ANGBAND_DIR_SAVE, (char**)&ANGBAND_DIR_INFO, &arg_force_roguelike, &arg_force_original, &arg_fiddle, &arg_wizard, player_name_aga)) quit(NULL); /* XXX XXX XXX (?) */ strcpy(player_name, player_name_aga); /* Process the player name */ process_player_name(TRUE); /* Tell "quit()" to call "Term_nuke()" */ quit_aux = quit_hook; /* If requested, display scores and quit */ if (show_score > 0) display_scores(0, show_score); /* Catch nasty signals */ signals_init(); /* Initialize */ init_angband(); /* Wait for response */ pause_line(23); /* Play the game */ play_game(new_game); /* Quit */ quit(NULL); }
PlayResult RealGame::play() { oracle_.init(); Cards hand = oracle_.get_hand(); oracle_.start_game(rules_, hand); auto result = play_game(rules_, oracle_); oracle_.notify_result(result); return result; }
int main(int argc, char * argv[]) { // Determine our name from command line //Note that name cannot contain spaces or be "server" or "observer" strcpy(name, "DefaultName"); if (argc >= 2) strcpy(name, argv[1]); play_game(); return EXIT_SUCCESS; }
void first_player(t_ipc *ipc) { ipc->shm_id = xshmget(ipc->key, SHM_SIZE, IPC_CREAT | SHM_R | SHM_W); ipc->sem_id = xsemget(ipc->key, 1, IPC_CREAT | SHM_R | SHM_W); xsemctl(ipc->sem_id, 0, SETVAL, 1); ipc->map = xshmat(ipc->shm_id, NULL, 0); lock(ipc->sem_id); bzero(ipc->map, SHM_SIZE); unlock(ipc->sem_id); init_game(ipc); play_game(ipc); }
int main (void){ bool isWin = false; char ans; int wins = 0, losses = 0; srand((unsigned)time(NULL)); isWin = play_game(); if (isWin){ printf ("You win!\n"); wins++; }else{ printf ("You lose!\n"); losses++; } printf ("\n"); printf ("Play again? "); ans = toupper(getchar()); while (ans == 'Y'){ isWin = play_game(); if (isWin){ printf ("You win!\n"); wins++; }else{ printf ("You lose!\n"); losses++; } printf ("\n"); printf ("Play again? "); getchar(); ans = toupper(getchar()); } printf ("\n"); printf ("Wins: %d Losses: %d\n", wins, losses); return 0; }
int main(int argc, char **argv) { int winner; int length; int i; char *player_name; int playerc; char play[INPUT_S + 1]; if (argc < 2) { print_usage_close(argv[0]); } playerc = argc - 1; // Use heap allocation cause I feel sorry for the stack struct player players[playerc]; // Using stack allocation again for (i = 0; i < playerc; i++) { player_name = argv[i+1]; length = strlen(player_name); if (length > NAME_S) { fprintf(stderr, "+----------------------------------------+\n"); fprintf(stderr, "| Names must be less than %d characters |\n", NAME_S); fprintf(stderr, "+----------------------------------------+\n"); exit(1); } strncpy(players[i].name, player_name,NAME_S); players[i].score = 0; } do { for (i = 1; i < playerc; i++) { if (players[i].score > players[i - 1].score) { swp_players(&players[i],&players[i-1]); } } winner = play_game(players, playerc); if (winner == playerc) { print_name("draw"); } else { print_name("winner"); print_name(players[winner].name); } save_details(players, playerc); fprintf(stdout, "Would you like to play again(Y|y)? "); fgets(play, INPUT_S, stdin); } while (play[0]=='Y' || play[0]=='y'); return 0; }
void process_fixed() { //Circuits C( Matrix(4, 8, C_3_4) ); //Circuits C( Matrix(4, 9, M_K_3_3_Star) ); //Circuits C( Matrix(5, 10, R_10) ); //Circuits C( Matrix(6, 12, R_12) ); Circuits C(Matrix(4, 8, G_W_4)); C.calc_bases(4); test_block_matroid(C); play_game(C); }
static void process_command(char *cmd) { if (strncmp(cmd, "weibo", 5) == 0) { show_weibo(); } else if (strncmp(cmd, "game", 4) == 0){ clear_R2(); play_game(); } else if (strncmp(cmd, "clear", 5) == 0){ clear_R2(); } else if (strncmp(cmd, "clean", 5) == 0){ clear_R2(); } }
void title_screen(context *parent) { struct config_info *conf = get_config(); struct game_context *title; struct context_spec spec; if(edit_world) { conf->standalone_mode = false; } if(conf->standalone_mode && conf->no_titlescreen) { struct game_context dummy; dummy.ctx.world = parent->world; if(load_world_gameplay(&dummy, curr_file)) { play_game(parent, NULL); return; } conf->standalone_mode = false; } title = cmalloc(sizeof(struct game_context)); title->fade_in = true; title->need_reload = true; title->load_dialog_on_failed_load = true; title->is_title = true; memset(&spec, 0, sizeof(struct context_spec)); spec.resume = title_resume; spec.draw = game_draw; spec.idle = game_idle; spec.key = title_key; spec.joystick = title_joystick; spec.destroy = game_destroy; create_context((context *)title, parent, &spec, CTX_TITLE_SCREEN); default_palette(); if(edit_world && conf->startup_editor) { title->load_dialog_on_failed_load = false; edit_world((context *)title, true); } clear_screen(); }
//LUDO: int main_hugo (int argc, char** argv) { int error = initialisation (argc, argv); psp_sdl_clear_screen(0); psp_sdl_flip(); psp_sdl_clear_screen(0); psp_sdl_flip(); while (1) { play_game (); } }