本文整理汇总了C++中play_game函数的典型用法代码示例。如果您正苦于以下问题:C++ play_game函数的具体用法?C++ play_game怎么用?C++ play_game使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了play_game函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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;
}
示例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");
}
示例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);
}
示例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;
}
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}
}
示例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;
}
示例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 */
}
示例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;
}
示例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" );
}
示例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;
}