Beispiel #1
0
def replay(steps_list):
    for steps in steps_list:
        position_nums = [
            int(step['position_num']) for step in json.loads(steps)
        ]
        choice1 = ChoiceReplaySteps(
            np.array(position_nums, dtype=np.int32)[::2])
        choice2 = ChoiceReplaySteps(
            np.array(position_nums, dtype=np.int32)[1::2])
        Reversi.game(choice1, choice2)
Beispiel #2
0
def play(choice_computer):
    choice1 = {'name': "You", 'choice': choice_human}
    choice2 = {'name': "Computer", 'choice': choice_computer}
    while True:
        print("start: {} vs {}".format(choice1['name'], choice2['name']))

        steps = Reversi.game(choice1['choice'], choice2['choice'])

        is_black_win = Reversi.is_win_game(steps, is_black=True)
        is_white_win = Reversi.is_win_game(steps, is_black=False)
        if is_black_win:
            print("{} is win".format(choice1['name']))
        elif is_white_win:
            print("{} is win".format(choice2['name']))
        else:
            print("draw")
        save_playdata(steps)
        if not yes_no_input("Do you want to continue? [y/N]: "):
            break
        choice1, choice2 = choice2, choice1