• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ play_game函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中play_game函数的典型用法代码示例。如果您正苦于以下问题:C++ play_game函数的具体用法?C++ play_game怎么用?C++ play_game使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了play_game函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

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;
}
开发者ID:trevornunes,项目名称:HuGo,代码行数:51,代码来源:hugo.c


示例2: start_game

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);
}
开发者ID:anuragpallaprolu,项目名称:crepo,代码行数:25,代码来源:fgets.c


示例3: main

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;
}
开发者ID:joelthelion,项目名称:uct,代码行数:25,代码来源:bot_bot.cpp


示例4: main

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"); 

}
开发者ID:arcturus611,项目名称:dailyprogrammer,代码行数:32,代码来源:c159e_rock_paper_scissors_lizard_spock.c


示例5: menu

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);
}
开发者ID:Poncholay,项目名称:TekDefense,代码行数:28,代码来源:menu.c


示例6: main

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;
	}
}
开发者ID:YuChen-Qian,项目名称:Exercise,代码行数:30,代码来源:c9ppex8.c


示例7: main

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();

}	
开发者ID:peterkrieg,项目名称:cpractice,代码行数:33,代码来源:craps.c


示例8: start_new_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;
}
开发者ID:tanay,项目名称:tetriz,代码行数:27,代码来源:gameplay.c


示例9: main

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;
}
开发者ID:jdrs,项目名称:hangman_c,代码行数:26,代码来源:hangman.c


示例10: gtk_file_chooser_get_filename

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();
	}
}
开发者ID:Plombo,项目名称:hugo,代码行数:29,代码来源:callbacks.c


示例11: main

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;     
}
开发者ID:reinka,项目名称:coding,代码行数:27,代码来源:pr8.c


示例12: main

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 */
}
开发者ID:Brainiarc7,项目名称:ralink_sdk,代码行数:59,代码来源:blue.c


示例13: main

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;
}
开发者ID:EinsamHauer,项目名称:vindinium-cpp-sdk,代码行数:58,代码来源:client.cpp


示例14: match

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" );
}
开发者ID:Matthew-Byl,项目名称:senior-project,代码行数:18,代码来源:main.cpp


示例15: main

int main(int argc, char **argv) {
    (void)argc;
    (void)argv;

    init_move_tables();
    init_score_tables();

    play_game(find_best_move);
    return 0;
}
开发者ID:fenderstr,项目名称:2048-ai,代码行数:10,代码来源:2048.cpp


示例16: main

int main(void)
{
	setup_game();
	
	play_game();
	
	end_game();
	
	return 0;
}
开发者ID:davinnovation,项目名称:Hi_game,代码行数:10,代码来源:Hi_concept_game.cpp


示例17: main

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*/
}
开发者ID:kal444,项目名称:xiang-qi,代码行数:55,代码来源:blue.c


示例18: newgame_menu

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;
}
开发者ID:mdragonborn,项目名称:Snake-Battle,代码行数:11,代码来源:display.c


示例19: play_game

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;
}
开发者ID:jbytheway,项目名称:konig,代码行数:11,代码来源:realgame.cpp


示例20: main

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;
}
开发者ID:Tener,项目名称:tradgames,代码行数:11,代码来源:SampleAgent.c



注:本文中的play_game函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ play_music函数代码示例发布时间:2022-05-30
下一篇:
C++ playVideo函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap