Exemple #1
0
//-------- Begin of function Game::run_main_menu_option --------//
//
// Run the selected game option.
//
void Game::run_main_menu_option(int optionId)
{
	//------- Single Player Game -------//

	if( optionId==1 )
	{
		single_player_menu();
	}

	//-------- Multiplayer Game ----------//

	if( optionId==2 )
	{
#ifndef DISABLE_MULTI_PLAYER
		game_mode = GAME_MULTI_PLAYER;
		multi_player_menu(NULL);
		// multi_player_game();
#endif
	}

	//----------- Encyclopedia -----------//

	if( optionId==3 )
	{
		game_mode = GAME_ENCYCLOPEDIA;
		view_encyclopedia();
	}

	//----------- Hall of Fame -----------//

	if( optionId==4 )
	{
		game_file_array.disp_hall_of_fame();
	}

	//------------- Credits -----------//

	// ####### begin Gilbert 2/9 #######//
	if( optionId==5 )
	{
		if( m.is_file_exist("TESTING2.SYS") )
		{
			game_mode = GAME_TEST;          // testing game instead
			test_game();
		}
		else
		{
			game_mode = GAME_CREDITS;
			view_credits();
		}
	}
	// ####### end Gilbert 2/9 #######//

	// ####### begin Gilbert 7/11 #########//
	if( optionId==6 )
	{
		sys.signal_exit_flag = 1;
	}
	// ####### end Gilbert 7/11 #########//
}
TEST(gogameab_basic_check, simple_ab_uniform) {
    uint8_t board_size = 5;
    int depth = 1;
    GoGame test_game(board_size);

    GoGameNN test_network(board_size, true);

    test_game.generate_moves(0);

    double best_move_value, temp_best_move_value = 0;
    GoMove best_move(test_game.get_board());

    best_move_value = -std::numeric_limits<double>::infinity();

    // For each possible move, calculate Alpha Beta
    for (const GoMove &element : test_game.get_move_list()) {
        GoGame temp_game(test_game);
        temp_game.make_move(element, 0);

        temp_best_move_value = scalable_go_ab_prune(test_network, temp_game, depth,
                               -std::numeric_limits<double>::infinity(),
                               std::numeric_limits<double>::infinity(), 1, false, 0);

        if (temp_best_move_value > best_move_value) {
            best_move_value = temp_best_move_value;
            best_move = element;
        }
    }

    EXPECT_NO_THROW(test_game.make_move(best_move, 0));
}
TEST(gogame_move_check, repeate_moves_history) {
    uint8_t board_size = 5;
    GoBoard test_board(board_size);

    test_board.board[1] = {0, get_mask(0), 0, get_mask(0), 0};
    test_board.board[2] = {0, get_mask(1), get_mask(0), get_mask(1), 0};
    test_board.board[3][2] = get_mask(1);

    GoGame test_game(test_board);

    // Make first move
    GoMove test_move1(test_game.get_board(), XYCoordinate(0, 2));
    test_move1.check_move(0);
    test_game.make_move(test_move1, 0);

    // Make capture
    GoMove test_move2(test_game.get_board(), XYCoordinate(2, 1));
    test_move2.check_move(1);
    test_game.make_move(test_move2, 1);

    // Attempt to make second capture which would reset board to a prior state
    GoMove test_move3(test_game.get_board(), XYCoordinate(2, 2));
    test_move3.check_move(0);

    // Check move is in move history
    EXPECT_EQ(true, test_game.check_move_history(test_move3));
}
int main(int argc, const char *argv[]) {
  program_name = argv[0];

  (void) argc;

  test_card();
  test_cursor();
  test_deck();
  test_gui();
  test_frame();
  test_game();
  test_keyboard();
  test_stack();
  test_test_helper();

  return(0);
}