コード例 #1
0
ファイル: same-gnome.c プロジェクト: cstrahan/aduni
static void
check_game_over (void)
{
	int cleared=1;
	int x,y;
	
	for(x = 0; x < STONE_COLS; x++)
		for(y = 0 ; y < STONE_LINES; y++) {
			if (!field [x][y].color)
				continue;
			cleared = 0;
			if(x+1 < STONE_COLS) 
				if(field[x][y].color == field[x+1][y].color)
					return;
			if(y+1 < STONE_LINES) 
				if(field[x][y].color == field[x][y+1].color)
					return;
		}
	if (cleared){
		set_score (score+1000);
		end_of_game (_("The Same Gnome"));
	}
	else
		end_of_game(_("The Same Gnome"));
}
コード例 #2
0
ファイル: startrek.c プロジェクト: z88dk/z88dk
void
resign_commision(void)
{
  printf("There were %d Klingon Battlecruisers left at the end\n", k9);
  printf("of your mission.\n\n");

  end_of_game();
}
コード例 #3
0
ファイル: startrek.c プロジェクト: z88dk/z88dk
void
won_game(void)
{
  printf("Congradulations, Captain!  The last Klingon Battle Cruiser\n");
  printf("menacing the Federation has been destoyed.\n\n");
 
  if (t - t0 > 0)
    printf("Your efficiency rating is %4.2f\n", 1000 * pow(k7 / (t - t0), 2));

  end_of_game();
}
コード例 #4
0
ファイル: game.c プロジェクト: SunnyDjinn/GenOthello
Game* play_ai(Game* game) {
	
	if(!game)
		return NULL;
	
	/* If the game doesn't imply the computer, no need to play */
	if(!is_computer_game(game))
		return game;
	
	/* If the turn is not to the computer, no need to play */
	if(!((game->turn == BLACK && game->p1.player_type == COMPUTER) || (game->turn == WHITE && game->p2.player_type == COMPUTER)))
		return game;
	
	short turn = game->turn;

	printf("Loading...\n");
	
	/* Finding the best move to play */
	short position = min_max(YES, game, game->turn, GLOBAL_DEPTH, GLOBAL_DEPTH, SHRT_MIN, SHRT_MAX, game->coefs);
	
	/* If the move is not legal or the coordinates don't have the good format, which should not happen */
	if(move_processing(game, UNKNOWN, position) != 1) {
		return game;
	}
	
	destroy_end_boards_tab(game);
	destroy_end_moves_tab(game);
	
	update_othellier(game);
	
	clear_screen();
	display_othellier(game);

	/* If the end of the game is reached, performing and end of game action */
	if(end_of_game(game))
		game = end_of_game_action(game);
		
	else if(game->turn == turn) {
		printf("### %s passe son tour !###\n\n", game->turn==BLACK?game->p2.player_name:game->p1.player_name);
		printf("Au tour de %s de jouer :\n", game->turn==BLACK?game->p1.player_name:game->p2.player_name);
		game = play_ai(game);
	}
	
	else
		printf("Au tour de %s de jouer : \n", game->turn==BLACK?game->p1.player_name:game->p2.player_name);
	
	/* Playing another time if it's a C_VS_C game */
	game = play_ai(game);
	
	return game;
}
コード例 #5
0
static void check_game_over (HWND hwnd)
{
    int cleared=1;
    int x,y;
    
    for(x = 0; x < STONE_COLS; x++)
        for(y = 0 ; y < STONE_LINES; y++) {
            if (!field [x][y].color)
                continue;
            cleared = 0;
            if(x+1 < STONE_COLS) 
                if(field[x][y].color == field[x+1][y].color)
                    return;
            if(y+1 < STONE_LINES) 
                if(field[x][y].color == field[x][y+1].color)
                    return;
        }
    if (cleared)
        set_score (score+1000);
    end_of_game(hwnd, _(SM_ST_SAMEGAME));
}
コード例 #6
0
ファイル: game.c プロジェクト: SunnyDjinn/GenOthello
Game* end_of_game_action(Game* game) {
	
	short gameType;
	
	/* If the game has not reached the end, there is no action to realize */
	if(!end_of_game(game))
		return NULL;
	
	/* Else, informs players the game is over */
	printf("Plus aucun coup possible : fin du jeu\n");
	
	/* If the black player has more pawn, he wins */
	if(game->oth->piecesNb[BLACK] > (game->oth->piecesNb[WHITE]))
		printf("\n%s a gagné !\n", game->p1.player_name);
		
	/* Else, if the white one has more pawn, he wins */
	else if(game->oth->piecesNb[BLACK] < (game->oth->piecesNb[WHITE]))
		printf("%s a gagné !\n", game->p2.player_name);
		
	/* Else, the two players are dead heat */
	else
		printf("%s et %s sont ex-aequo !\n", game->p1.player_name, game->p2.player_name);
		
	printf("Score : %d - %d\n", game->oth->piecesNb[BLACK], game->oth->piecesNb[WHITE]);
	
	/* Asking the players if they want to save the game */ 
	ask_save_game(game);
	
	/* Freeing the game */
	destroy_game(game);
	game = NULL;
	
	/* Asking the players if they want to play another time */
	if(ask_new_game() == YES) {
		
		/* If so, initializing the game, the players' names ans the board */
		game = init_game();
		
		/* Choosing the game type (H vs H or H vs C) */
		gameType = choose_game_type();
	
		/* If the game type is Human vs Human */
		if(gameType == H_VS_H) {
			/* Asking for the two players' names */
			enter_players_names(game);
		}
	
		/* If the game type is Human vs Computer */
		else if(gameType == H_VS_C) {
		
			/* Choosing the color of the human player, and asking for his name */
			gameType = choose_player_color();
			enter_one_name(game, gameType);
		
			/* Giving the computer the other player and giving it a name */
			give_computer_name(game, (gameType+1)%2);
		}
		
		else if(gameType == C_VS_C) {
		
		/* Giving the computer the other player and giving it a name */
			give_computer_name(game, 0);
			give_computer_name(game, 1);
		}
		clear_screen();
		display_othellier(game);
		printf("Au tour de %s de jouer :\n", game->turn==BLACK?game->p1.player_name:game->p2.player_name);
		game = play_ai(game);
	}
	/* Otherwise, clearing the screen and returning NULL */
	else
		clear_screen();

	return game;
}