// File: /workspace/github_cpp_makefile_star2_O2/ttencate[P]pickomino/pickomino.cc
// Function: main
int main(int argc, char const *const *argv) {
  // for (Roll roll : Roll::allWithDice(2)) {
  //   cout << roll.dice() << ' ' << roll.probability() << '\n';
  // }
  // for (int i = 1; i <= 8; i++) {
  //   cout << i << ' ' << Roll::allWithDice(i).size() << '\n';
  // }
  // return 0;

  int games = 1;
  if (argc > 1) {
    games = atoi(argv[1]);
  }
  if (argc > 2) {
    seedRandom(atoi(argv[2]));
  }

  int optimalWins = 0;
  int simpleWins = 0;
  int ties = 0;
  while (games--) {
    vector<shared_ptr<Strategy>> strategies;
    strategies.push_back(shared_ptr<Strategy>(new OptimalBot("Alice")));
    strategies.push_back(shared_ptr<Strategy>(new SimpleBot("Bob")));
    Game game(strategies, games % 2);
    game.playToEnd();
    switch (game.winner()) {
      case 0:
        optimalWins++;
        break;
      case 1:
        simpleWins++;
        break;
      default:
        ties++;
        break;
    }
  }
  cout << '\n';
  cout << "Alice wins " << optimalWins << " times\n";
  cout << "Bob wins " << simpleWins << " times\n";
  if (ties) {
    cout << "There were " << ties << " ties\n";
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
cmpl $0x2, %edi
jl 0x498f
movq %rsi, %rbx
movl %edi, %r14d
movq 0x8(%rsi), %rdi
callq 0x2200
movl %eax, %ebp
cmpl $0x2, %r14d
je 0x4992
movq 0x10(%rbx), %rdi
callq 0x2200
movl %eax, %edi
callq 0x59b8
jmp 0x4992
pushq $0x1
popq %rbp
decl %ebp
movl $0x0, 0x4(%rsp)
leaq 0xb8(%rsp), %r15
leaq 0x68(%rsp), %rbx
leaq 0x50(%rsp), %r14
movl $0x0, 0x8(%rsp)
movl $0x0, 0xc(%rsp)
cmpl $-0x1, %ebp
je 0x4b03
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movl $0xa0, %edi
callq 0x2170
movq %rax, %r13
movq %r15, %rdi
leaq 0x2aa4(%rip), %rsi      # 0x7490
leaq 0x3(%rsp), %rdx
callq 0x2080
movq %r15, %rsi
movb $0x1, %r15b
movq %r13, %rdi
movq %rsi, %r12
callq 0x4c3c
xorl %r15d, %r15d
movq %rbx, %rdi
movq %r13, %rsi
callq 0x53f0
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x548c
leaq 0x70(%rsp), %rdi
callq 0x4ee4
movq %r12, %rdi
callq 0x20a0
pushq $0x28
popq %rdi
callq 0x2170
leaq 0x30(%rsp), %r15
movq %rax, %r13
movq %r15, %rdi
leaq 0x2a48(%rip), %rsi      # 0x7496
leaq 0x3(%rsp), %rdx
callq 0x2080
movq %r15, %rsi
movb $0x1, %r15b
movq %r13, %rdi
callq 0x4cd6
xorl %r15d, %r15d
movq %rbx, %rdi
movq %r13, %rsi
callq 0x5654
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x548c
leaq 0x70(%rsp), %rdi
callq 0x4ee4
leaq 0x30(%rsp), %rdi
callq 0x20a0
movq %r14, %rdi
movq %r15, %rsi
callq 0x4d2e
movq %r12, %r15
movl %ebp, %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4d82
movq %r14, %rdi
callq 0x4e98
movq %rbx, %rdi
callq 0x3018
movq %rbx, %rdi
callq 0x3118
testl %eax, %eax
je 0x4ae0
cmpl $0x1, %eax
jne 0x4ae6
incl 0x8(%rsp)
jmp 0x4aea
incl 0x4(%rsp)
jmp 0x4aea
incl 0xc(%rsp)
movq %rbx, %rdi
callq 0x4eba
leaq 0x10(%rsp), %rdi
callq 0x4e98
decl %ebp
jmp 0x49be
movq 0x74c6(%rip), %rbx      # 0xbfd0
pushq $0xa
popq %rsi
movq %rbx, %rdi
callq 0x21a0
leaq 0x297e(%rip), %rsi      # 0x749a
movq %rbx, %rdi
callq 0x2160
movq %rax, %rdi
movl 0x4(%rsp), %esi
callq 0x2240
leaq 0x296f(%rip), %r14      # 0x74a6
movq %rax, %rdi
movq %r14, %rsi
callq 0x2160
leaq 0x2965(%rip), %rsi      # 0x74ae
movq %rbx, %rdi
callq 0x2160
movq %rax, %rdi
movl 0x8(%rsp), %esi
callq 0x2240
movq %rax, %rdi
movq %r14, %rsi
callq 0x2160
movl 0xc(%rsp), %ebx
testl %ebx, %ebx
je 0x4b9c
movq 0x7459(%rip), %rdi      # 0xbfd0
leaq 0x293a(%rip), %rsi      # 0x74b8
callq 0x2160
movq %rax, %rdi
movl %ebx, %esi
callq 0x2240
leaq 0x2930(%rip), %rsi      # 0x74c4
movq %rax, %rdi
callq 0x2160
xorl %eax, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4bd7
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x4e98
jmp 0x4c29
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x4ee4
xorl %r15d, %r15d
jmp 0x4c05
jmp 0x4bd7
jmp 0x4bee
movq %rax, %rbx
jmp 0x4c29
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x4ee4
xorl %r15d, %r15d
jmp 0x4c12
movq %rax, %rbx
jmp 0x4c21
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x4eba
jmp 0x4c29
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
jmp 0x4c17
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x20a0
testb %r15b, %r15b
je 0x4c29
movq %r13, %rdi
callq 0x2150
leaq 0x10(%rsp), %rdi
callq 0x4e98
movq %rbx, %rdi
callq 0x2250
nop