コード例 #1
0
ファイル: perf_test.py プロジェクト: sutt/exercises
def select_function(s_function):
    ''' input: s_function (string)
        output: [optional] usually a GameLog but really completely dynamic
        This string choses a way to:
             init Game(), param's for play(), possible return value.'''

    if s_function == "baseline":

        game = Game(s_instructions=ss)
        game.play(king_in_check_on=False)

    if s_function == "naive_check":

        game = Game(s_instructions=ss)
        game.play()

    if s_function == "test_copy":

        game = Game(s_instructions=ss)
        game.play(king_in_check_on=False, king_in_check_test_copy=True)

    if s_function == "test_copy_apply":

        game = Game(s_instructions=ss)
        game.play(king_in_check_on=False, king_in_check_test_copy_apply=True)

    if s_function == "test_c_apply_2":

        game = Game(s_instructions=ss)
        game.play(king_in_check_on=False, king_in_check_test_copy_apply_2=True)

    if s_function == "test_c_apply_3":

        game = Game(s_instructions=ss)
        game.play(king_in_check_on=False, king_in_check_test_copy_apply_3=True)

    if s_function == "test_c_apply_4":

        game = Game(s_instructions=ss)
        game.play(king_in_check_on=False, king_in_check_test_copy_apply_4=True)

    if s_function == "baseline_tt":

        game = Game(s_instructions=ss,
                    b_log_turn_time=True,
                    b_log_num_available=True)
        game.play(king_in_check_on=False)
        return game.get_gamelog()

    if s_function == "naive_check_tt":

        game = Game(s_instructions=ss,
                    b_log_turn_time=True,
                    b_log_num_available=True)
        game.play(king_in_check_on=True)
        return game.get_gamelog()

    if s_function == "baseline_long":

        game = Game(s_instructions=ss_long,
                    b_log_turn_time=True,
                    b_log_num_available=True)
        game.play(king_in_check_on=False)
        return game.get_gamelog()

    if s_function == "naive_long":

        game = Game(s_instructions=ss_long,
                    b_log_turn_time=True,
                    b_log_num_available=True)
        game.play(king_in_check_on=True)
        return game.get_gamelog()

    if s_function == "optimal1_long":

        game = Game(s_instructions=ss_long,
                    b_log_turn_time=True,
                    b_log_num_available=True)
        game.play(king_in_check_on=False, king_in_check_optimal=True)
        return game.get_gamelog()

    if s_function == "optimal2_long":

        game = Game(s_instructions=ss_long,
                    b_log_turn_time=True,
                    b_log_num_available=True)
        game.play(king_in_check_on=False, king_in_check_optimal_2=True)
        return game.get_gamelog()

    if s_function == "check_optimal":

        game = Game(s_instructions=ss)
        game.play(king_in_check_on=False, king_in_check_optimal=True)

    if s_function == "check_optimal_2":

        game = Game(s_instructions=ss)
        game.play(king_in_check_on=False, king_in_check_optimal_2=True)

    return None  #to show that the function is no returning a test exit data
コード例 #2
0
ファイル: run.py プロジェクト: sutt/exercises
                ,test_exit_moves = 1000
                )
    
    ret = game.play()
    
    if game.i_turn == 1000:
        print '1000 turn game'
    else:
        
        outcome, board, pieces = ret

        print 'Outcome: ', str(outcome)
        
        display.print_board_letters(pieces)

        log = game.get_gamelog()
        move_log = log.get_log_move()

        print 'Game Turn on exit: ', str(game.i_turn)
        print 'Len of Log Moves:  ', str(len(move_log))

if run_type == '20random':
    
    for t in range(20):
        game = Game(manual_control = ()
                    ,b_display_never_print = True
                    ,b_log_move = False
                    ,test_exit_moves = 1000
                    )
        
        ret = game.play()