// File: tyhsu[P]Ewn/play.cpp
// Function: Play::contest_AI_mode()
void Play::contest_AI_mode()
{
    int is_right_upper_side;
    cout << "Whose AI is at the left upper section?" << endl;
    cout << "=>Who is A (1~6)? 0)Ours 1)Opponent's" << endl;
    cout << "Choose: ";
    cin >> is_right_upper_side;

    int is_init_board, is_switch;
    cout << "Do you need to set the board? 0)No 1)Yes" << endl;
    cout << "Choose: ";
    cin >> is_init_board;
    if (is_init_board == 1) {
        char board[5][5];
        do {
            cout << endl << "Please give values for the 5x5 array" << endl;
            char c;
            for (int i=0; i<5; i++) {
                for (int j=0; j<5; j++) {
                    cin >> c;
                    if (c == '0')
                        board[i][j] = 0;
                    else
                        board[i][j] = c;
                }
            }
            cout << "Are you ready to set the board? 0)No 1)Yes" << endl;
            cout << "Choose: ";
            cin >> is_init_board;
        } while (!is_init_board);

        cout << endl << "Whose turn is it now? 0)A 1)B" << endl;
        cout << "Choose: ";
        cin >> is_switch;
        this->game.set_board(board, is_switch);
    }
    cout << endl;
    this->game.print_board();

    EwnAI ewnAI;
    while (1) {
        int game_status;
        //The opponent's turn (A)
        if (is_right_upper_side && !this->game.get_is_switch()) {
            char chs_symbol;
            int direct;
            cout << endl << "Choose the chessman(1~6): ";
            cin >> chs_symbol;
            if (!(chs_symbol>='1' && chs_symbol<='6'))
                continue;

            cout << "Direction: 0)Right 1)Down 2)Right-down" << endl;
            cout << "Choose: ";
            cin >> direct;
            if (!(direct>=0 && direct<=2))
                continue;

            int is_recover;
            cout << "Do you want to recover? 0)No 1)Yes" << endl;
            cout << "Choose: ";
            cin >> is_recover;
            if (is_recover != 0)
                continue;

            game_status = this->game.update_game_status(make_pair(chs_symbol-'1', direct));
        }

        //The opponent's turn (B)
        else if (!is_right_upper_side && this->game.get_is_switch()) {
            char chs_symbol;
            int direct;
            cout << endl << "Choose the chessman(A~F): ";
            cin >> chs_symbol;
            if (!(chs_symbol>='A' && chs_symbol<='F'))
                continue;

            cout << "Direction: 0)Left 1)Up 2)Left-up" << endl;
            cout << "Choose: ";
            cin >> direct;
            if (!(direct>=0 && direct<=2))
                continue;

            int is_recover;
            cout << "Do you want to recover? 0)No 1)Yes" << endl;
            cout << "Choose: ";
            cin >> is_recover;
            if (is_recover != 0)
                continue;

            game_status = this->game.update_game_status(make_pair(chs_symbol-'A', direct));
        }

        //Our AI's turn
        else {
            char dice;
            cout << endl << "Set the dice(1~6): ";
            cin >> dice;
            if (!(dice>='1' && dice<='6'))
                continue;

            game_status = this->game.update_game_status(ewnAI.AI_move(this->game, dice-'1'));
        }

        this->game.print_board();
        //update: 0(game continues), 1(A wins), 2(B wins)
        if (game_status!=0) {
            cout << "====================================" << endl;
            if ((is_right_upper_side && game_status==1) || (!is_right_upper_side && game_status==2))
                cout << "The opponent is the winner!!!" << endl;
            else
                cout << "Our AI is the winner!!!" << endl;
            cout << "====================================" << endl;
            return;
        }
        this->game.switch_player();
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4d0, %rsp            # imm = 0x4D0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x420(%rbp)
movq 0xea27(%rip), %rdi      # 0x11fc8
leaq 0x9bf5(%rip), %rsi      # 0xd19d
callq 0x2150
movq %rax, %rdi
movq 0xea01(%rip), %rsi      # 0x11fb8
callq 0x2190
movq 0xea05(%rip), %rdi      # 0x11fc8
leaq 0x9bfa(%rip), %rsi      # 0xd1c4
callq 0x2150
movq %rax, %rdi
movq 0xe9df(%rip), %rsi      # 0x11fb8
callq 0x2190
movq 0xe9e3(%rip), %rdi      # 0x11fc8
leaq 0x9aa1(%rip), %rsi      # 0xd08d
callq 0x2150
movq 0xe9e0(%rip), %rdi      # 0x11fd8
leaq -0xc(%rbp), %rsi
callq 0x20a0
movq 0xe9c0(%rip), %rdi      # 0x11fc8
leaq 0x9bdb(%rip), %rsi      # 0xd1ea
callq 0x2150
movq %rax, %rdi
movq 0xe99a(%rip), %rsi      # 0x11fb8
callq 0x2190
movq 0xe99e(%rip), %rdi      # 0x11fc8
leaq 0x9a5c(%rip), %rsi      # 0xd08d
callq 0x2150
movq 0xe99b(%rip), %rdi      # 0x11fd8
leaq -0x10(%rbp), %rsi
callq 0x20a0
cmpl $0x1, -0x10(%rbp)
jne 0x37bf
jmp 0x3652
movq 0xe96f(%rip), %rdi      # 0x11fc8
movq 0xe958(%rip), %rsi      # 0x11fb8
callq 0x2190
movq %rax, %rdi
leaq 0x9ba4(%rip), %rsi      # 0xd213
callq 0x2150
movq %rax, %rdi
movq 0xe93a(%rip), %rsi      # 0x11fb8
callq 0x2190
movl $0x0, -0x38(%rbp)
cmpl $0x5, -0x38(%rbp)
jge 0x3702
movl $0x0, -0x3c(%rbp)
cmpl $0x5, -0x3c(%rbp)
jge 0x36f5
movq 0xe934(%rip), %rdi      # 0x11fd8
leaq -0x31(%rbp), %rsi
callq 0x21b0
movsbl -0x31(%rbp), %eax
cmpl $0x30, %eax
jne 0x36cf
movslq -0x38(%rbp), %rcx
leaq -0x30(%rbp), %rax
imulq $0x5, %rcx, %rcx
addq %rcx, %rax
movslq -0x3c(%rbp), %rcx
movb $0x0, (%rax,%rcx)
jmp 0x36e8
movb -0x31(%rbp), %dl
movslq -0x38(%rbp), %rcx
leaq -0x30(%rbp), %rax
imulq $0x5, %rcx, %rcx
addq %rcx, %rax
movslq -0x3c(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0x36ea
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x3697
jmp 0x36f7
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x368a
movq 0xe8bf(%rip), %rdi      # 0x11fc8
leaq 0x9b28(%rip), %rsi      # 0xd238
callq 0x2150
movq %rax, %rdi
movq 0xe899(%rip), %rsi      # 0x11fb8
callq 0x2190
movq 0xe89d(%rip), %rdi      # 0x11fc8
leaq 0x995b(%rip), %rsi      # 0xd08d
callq 0x2150
movq 0xe89a(%rip), %rdi      # 0x11fd8
leaq -0x10(%rbp), %rsi
callq 0x20a0
cmpl $0x0, -0x10(%rbp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x3652
movq 0xe869(%rip), %rdi      # 0x11fc8
movq 0xe852(%rip), %rsi      # 0x11fb8
callq 0x2190
movq %rax, %rdi
leaq 0x9aee(%rip), %rsi      # 0xd263
callq 0x2150
movq %rax, %rdi
movq 0xe834(%rip), %rsi      # 0x11fb8
callq 0x2190
movq 0xe838(%rip), %rdi      # 0x11fc8
leaq 0x98f6(%rip), %rsi      # 0xd08d
callq 0x2150
movq 0xe835(%rip), %rdi      # 0x11fd8
leaq -0x14(%rbp), %rsi
callq 0x20a0
movq -0x420(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0xa8f0
movq 0xe802(%rip), %rdi      # 0x11fc8
movq 0xe7eb(%rip), %rsi      # 0x11fb8
callq 0x2190
movq -0x420(%rbp), %rdi
callq 0xab80
leaq -0x2e0(%rbp), %rdi
callq 0x51e0
jmp 0x37ec
cmpl $0x0, -0xc(%rbp)
je 0x39ef
movq -0x420(%rbp), %rdi
callq 0xb910
movb %al, -0x421(%rbp)
jmp 0x380a
movb -0x421(%rbp), %al
testb $0x1, %al
jne 0x39ef
jmp 0x381a
movq 0xe7a7(%rip), %rdi      # 0x11fc8
movq 0xe790(%rip), %rsi      # 0x11fb8
callq 0x2190
movq %rax, -0x430(%rbp)
jmp 0x3836
movq -0x430(%rbp), %rdi
leaq 0x9a3d(%rip), %rsi      # 0xd281
callq 0x2150
jmp 0x384b
movq 0xe786(%rip), %rdi      # 0x11fd8
leaq -0x2f5(%rbp), %rsi
callq 0x21b0
jmp 0x3860
movsbl -0x2f5(%rbp), %eax
cmpl $0x31, %eax
jl 0x3878
movsbl -0x2f5(%rbp), %eax
cmpl $0x36, %eax
jle 0x38a0
jmp 0x37ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2f0(%rbp)
movl %eax, -0x2f4(%rbp)
leaq -0x2e0(%rbp), %rdi
callq 0x4c80
jmp 0x3dd6
movq 0xe721(%rip), %rdi      # 0x11fc8
leaq 0x982f(%rip), %rsi      # 0xd0dd
callq 0x2150
movq %rax, -0x438(%rbp)
jmp 0x38bc
movq -0x438(%rbp), %rdi
movq 0xe6ee(%rip), %rsi      # 0x11fb8
callq 0x2190
jmp 0x38d1
movq 0xe6f0(%rip), %rdi      # 0x11fc8
leaq 0x97ae(%rip), %rsi      # 0xd08d
callq 0x2150
jmp 0x38e6
movq 0xe6eb(%rip), %rdi      # 0x11fd8
leaq -0x2fc(%rbp), %rsi
callq 0x20a0
jmp 0x38fb
cmpl $0x0, -0x2fc(%rbp)
jl 0x390d
cmpl $0x2, -0x2fc(%rbp)
jle 0x3912
jmp 0x37ea
movq 0xe6af(%rip), %rdi      # 0x11fc8
leaq 0x997c(%rip), %rsi      # 0xd29c
callq 0x2150
movq %rax, -0x440(%rbp)
jmp 0x392e
movq -0x440(%rbp), %rdi
movq 0xe67c(%rip), %rsi      # 0x11fb8
callq 0x2190
jmp 0x3943
movq 0xe67e(%rip), %rdi      # 0x11fc8
leaq 0x973c(%rip), %rsi      # 0xd08d
callq 0x2150
jmp 0x3958
movq 0xe679(%rip), %rdi      # 0x11fd8
leaq -0x300(%rbp), %rsi
callq 0x20a0
jmp 0x396d
cmpl $0x0, -0x300(%rbp)
je 0x397b
jmp 0x37ea
movq -0x420(%rbp), %rax
movq %rax, -0x450(%rbp)
movsbl -0x2f5(%rbp), %eax
addl $-0x31, %eax
movl %eax, -0x30c(%rbp)
leaq -0x30c(%rbp), %rdi
leaq -0x2fc(%rbp), %rsi
callq 0x4d10
movq %rax, -0x448(%rbp)
jmp 0x39b5
movq -0x450(%rbp), %rdi
movq -0x448(%rbp), %rax
movq %rax, -0x308(%rbp)
leaq -0x308(%rbp), %rsi
callq 0xb120
movl %eax, -0x454(%rbp)
jmp 0x39de
movl -0x454(%rbp), %eax
movl %eax, -0x2e4(%rbp)
jmp 0x3cad
cmpl $0x0, -0xc(%rbp)
jne 0x3bce
movq -0x420(%rbp), %rdi
callq 0xb910
movb %al, -0x455(%rbp)
jmp 0x3a0d
movb -0x455(%rbp), %al
testb $0x1, %al
jne 0x3a1c
jmp 0x3bce
movq 0xe5a5(%rip), %rdi      # 0x11fc8
movq 0xe58e(%rip), %rsi      # 0x11fb8
callq 0x2190
movq %rax, -0x460(%rbp)
jmp 0x3a38
movq -0x460(%rbp), %rdi
leaq 0x9879(%rip), %rsi      # 0xd2bf
callq 0x2150
jmp 0x3a4d
movq 0xe584(%rip), %rdi      # 0x11fd8
leaq -0x30d(%rbp), %rsi
callq 0x21b0
jmp 0x3a62
movsbl -0x30d(%rbp), %eax
cmpl $0x41, %eax
jl 0x3a7a
movsbl -0x30d(%rbp), %eax
cmpl $0x46, %eax
jle 0x3a7f
jmp 0x37ea
movq 0xe542(%rip), %rdi      # 0x11fc8
leaq 0x9677(%rip), %rsi      # 0xd104
callq 0x2150
movq %rax, -0x468(%rbp)
jmp 0x3a9b
movq -0x468(%rbp), %rdi
movq 0xe50f(%rip), %rsi      # 0x11fb8
callq 0x2190
jmp 0x3ab0
movq 0xe511(%rip), %rdi      # 0x11fc8
leaq 0x95cf(%rip), %rsi      # 0xd08d
callq 0x2150
jmp 0x3ac5
movq 0xe50c(%rip), %rdi      # 0x11fd8
leaq -0x314(%rbp), %rsi
callq 0x20a0
jmp 0x3ada
cmpl $0x0, -0x314(%rbp)
jl 0x3aec
cmpl $0x2, -0x314(%rbp)
jle 0x3af1
jmp 0x37ea
movq 0xe4d0(%rip), %rdi      # 0x11fc8
leaq 0x979d(%rip), %rsi      # 0xd29c
callq 0x2150
movq %rax, -0x470(%rbp)
jmp 0x3b0d
movq -0x470(%rbp), %rdi
movq 0xe49d(%rip), %rsi      # 0x11fb8
callq 0x2190
jmp 0x3b22
movq 0xe49f(%rip), %rdi      # 0x11fc8
leaq 0x955d(%rip), %rsi      # 0xd08d
callq 0x2150
jmp 0x3b37
movq 0xe49a(%rip), %rdi      # 0x11fd8
leaq -0x318(%rbp), %rsi
callq 0x20a0
jmp 0x3b4c
cmpl $0x0, -0x318(%rbp)
je 0x3b5a
jmp 0x37ea
movq -0x420(%rbp), %rax
movq %rax, -0x480(%rbp)
movsbl -0x30d(%rbp), %eax
addl $-0x41, %eax
movl %eax, -0x324(%rbp)
leaq -0x324(%rbp), %rdi
leaq -0x314(%rbp), %rsi
callq 0x4d10
movq %rax, -0x478(%rbp)
jmp 0x3b94
movq -0x480(%rbp), %rdi
movq -0x478(%rbp), %rax
movq %rax, -0x320(%rbp)
leaq -0x320(%rbp), %rsi
callq 0xb120
movl %eax, -0x484(%rbp)
jmp 0x3bbd
movl -0x484(%rbp), %eax
movl %eax, -0x2e4(%rbp)
jmp 0x3cab
movq 0xe3f3(%rip), %rdi      # 0x11fc8
movq 0xe3dc(%rip), %rsi      # 0x11fb8
callq 0x2190
movq %rax, -0x490(%rbp)
jmp 0x3bea
movq -0x490(%rbp), %rdi
leaq 0x96e2(%rip), %rsi      # 0xd2da
callq 0x2150
jmp 0x3bff
movq 0xe3d2(%rip), %rdi      # 0x11fd8
leaq -0x325(%rbp), %rsi
callq 0x21b0
jmp 0x3c14
movsbl -0x325(%rbp), %eax
cmpl $0x31, %eax
jl 0x3c2c
movsbl -0x325(%rbp), %eax
cmpl $0x36, %eax
jle 0x3c31
jmp 0x37ea
movq -0x420(%rbp), %rsi
movq %rsi, %rax
movq %rax, -0x498(%rbp)
leaq -0x418(%rbp), %rdi
callq 0xa520
jmp 0x3c50
movsbl -0x325(%rbp), %edx
addl $-0x31, %edx
leaq -0x2e0(%rbp), %rdi
leaq -0x418(%rbp), %rsi
callq 0x5650
movq %rax, -0x4a0(%rbp)
jmp 0x3c76
movq -0x498(%rbp), %rdi
movq -0x4a0(%rbp), %rax
movq %rax, -0x330(%rbp)
leaq -0x330(%rbp), %rsi
callq 0xb120
movl %eax, -0x4a4(%rbp)
jmp 0x3c9f
movl -0x4a4(%rbp), %eax
movl %eax, -0x2e4(%rbp)
jmp 0x3cad
movq -0x420(%rbp), %rdi
callq 0xab80
jmp 0x3cbb
cmpl $0x0, -0x2e4(%rbp)
je 0x3dc3
movq 0xe2f9(%rip), %rdi      # 0x11fc8
leaq 0x9849(%rip), %rsi      # 0xd51f
callq 0x2150
movq %rax, -0x4b0(%rbp)
jmp 0x3ce4
movq -0x4b0(%rbp), %rdi
movq 0xe2c6(%rip), %rsi      # 0x11fb8
callq 0x2190
jmp 0x3cf9
cmpl $0x0, -0xc(%rbp)
je 0x3d08
cmpl $0x1, -0x2e4(%rbp)
je 0x3d17
cmpl $0x0, -0xc(%rbp)
jne 0x3d4a
cmpl $0x2, -0x2e4(%rbp)
jne 0x3d4a
movq 0xe2aa(%rip), %rdi      # 0x11fc8
leaq 0x95c9(%rip), %rsi      # 0xd2ee
callq 0x2150
movq %rax, -0x4b8(%rbp)
jmp 0x3d33
movq -0x4b8(%rbp), %rdi
movq 0xe277(%rip), %rsi      # 0x11fb8
callq 0x2190
jmp 0x3d48
jmp 0x3d7d
movq 0xe277(%rip), %rdi      # 0x11fc8
leaq 0x95b4(%rip), %rsi      # 0xd30c
callq 0x2150
movq %rax, -0x4c0(%rbp)
jmp 0x3d66
movq -0x4c0(%rbp), %rdi
movq 0xe244(%rip), %rsi      # 0x11fb8
callq 0x2190
jmp 0x3d7b
jmp 0x3d7d
movq 0xe244(%rip), %rdi      # 0x11fc8
leaq 0x9794(%rip), %rsi      # 0xd51f
callq 0x2150
movq %rax, -0x4c8(%rbp)
jmp 0x3d99
movq -0x4c8(%rbp), %rdi
movq 0xe211(%rip), %rsi      # 0x11fb8
callq 0x2190
jmp 0x3dae
leaq -0x2e0(%rbp), %rdi
callq 0x4c80
addq $0x4d0, %rsp            # imm = 0x4D0
popq %rbp
retq
movq -0x420(%rbp), %rdi
callq 0xb440
jmp 0x3dd1
jmp 0x37ea
movq -0x2f0(%rbp), %rdi
callq 0x2210
nopw %cs:(%rax,%rax)