// File: 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:
subq $0x148, %rsp            # imm = 0x148
movl $0x0, 0x144(%rsp)
movl %edi, 0x140(%rsp)
movq %rsi, 0x138(%rsp)
movl $0x1, 0x134(%rsp)
cmpl $0x1, 0x140(%rsp)
jle 0xb92e
movq 0x138(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x2240
movl %eax, 0x134(%rsp)
cmpl $0x2, 0x140(%rsp)
jle 0xb950
movq 0x138(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x2240
movl %eax, %edi
callq 0xf670
movl $0x0, 0x130(%rsp)
movl $0x0, 0x12c(%rsp)
movl $0x0, 0x128(%rsp)
movl 0x134(%rsp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, 0x134(%rsp)
cmpl $0x0, %eax
je 0xbd44
leaq 0x110(%rsp), %rdi
callq 0xbe10
movl $0xa0, %edi
callq 0x2180
movq %rax, 0x20(%rsp)
jmp 0xb9ab
movb $0x1, 0xce(%rsp)
leaq 0xcf(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x2290
movq 0x18(%rsp), %rdx
leaq 0x6a2b(%rip), %rsi      # 0x123fc
leaq 0xd0(%rsp), %rdi
callq 0x2200
jmp 0xb9e0
movq 0x20(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0xbe50
jmp 0xb9f4
movq 0x20(%rsp), %rsi
movb $0x0, 0xce(%rsp)
leaq 0x100(%rsp), %rdi
callq 0xbef0
jmp 0xba10
leaq 0x110(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0xbe20
jmp 0xba27
leaq 0x100(%rsp), %rdi
callq 0xbf20
leaq 0xd0(%rsp), %rdi
callq 0x20e0
leaq 0xcf(%rsp), %rdi
callq 0x21a0
movl $0x28, %edi
callq 0x2180
movq %rax, 0x10(%rsp)
jmp 0xba5f
movb $0x1, 0x96(%rsp)
leaq 0x97(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x2290
movq 0x8(%rsp), %rdx
leaq 0x697d(%rip), %rsi      # 0x12402
leaq 0x98(%rsp), %rdi
callq 0x2200
jmp 0xba94
movq 0x10(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0xbf30
jmp 0xbaa8
movq 0x10(%rsp), %rsi
movb $0x0, 0x96(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0xbfb0
jmp 0xbac4
leaq 0x110(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0xbe20
jmp 0xbadb
leaq 0xb8(%rsp), %rdi
callq 0xbf20
leaq 0x98(%rsp), %rdi
callq 0x20e0
leaq 0x97(%rsp), %rdi
callq 0x21a0
leaq 0x28(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0xbfe0
jmp 0xbb16
movl 0x134(%rsp), %edx
movl %edx, %ecx
shrl $0x1f, %ecx
movl %edx, %eax
addl %ecx, %eax
andl $-0x2, %eax
subl %eax, %edx
leaq 0x40(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0xc0e0
jmp 0xbb3c
leaq 0x28(%rsp), %rdi
callq 0xc2f0
leaq 0x40(%rsp), %rdi
callq 0x4700
jmp 0xbb52
leaq 0x40(%rsp), %rdi
callq 0x48c0
movl %eax, 0x4(%rsp)
jmp 0xbb62
movl 0x4(%rsp), %eax
testl %eax, %eax
je 0xbcdf
jmp 0xbb70
movl 0x4(%rsp), %eax
subl $0x1, %eax
je 0xbcf2
jmp 0xbd05
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf8(%rsp)
movl %eax, 0xf4(%rsp)
jmp 0xbd32
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf8(%rsp)
movl %eax, 0xf4(%rsp)
jmp 0xbbf5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf8(%rsp)
movl %eax, 0xf4(%rsp)
jmp 0xbbe8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf8(%rsp)
movl %eax, 0xf4(%rsp)
leaq 0x100(%rsp), %rdi
callq 0xbf20
leaq 0xd0(%rsp), %rdi
callq 0x20e0
leaq 0xcf(%rsp), %rdi
callq 0x21a0
testb $0x1, 0xce(%rsp)
jne 0xbc0e
jmp 0xbc18
movq 0x20(%rsp), %rdi
callq 0x2160
jmp 0xbd32
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf8(%rsp)
movl %eax, 0xf4(%rsp)
jmp 0xbc77
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf8(%rsp)
movl %eax, 0xf4(%rsp)
jmp 0xbc6a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf8(%rsp)
movl %eax, 0xf4(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0xbf20
leaq 0x98(%rsp), %rdi
callq 0x20e0
leaq 0x97(%rsp), %rdi
callq 0x21a0
testb $0x1, 0x96(%rsp)
jne 0xbc90
jmp 0xbc9a
movq 0x10(%rsp), %rdi
callq 0x2160
jmp 0xbd32
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf8(%rsp)
movl %eax, 0xf4(%rsp)
leaq 0x28(%rsp), %rdi
callq 0xc2f0
jmp 0xbd32
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf8(%rsp)
movl %eax, 0xf4(%rsp)
leaq 0x40(%rsp), %rdi
callq 0xc350
jmp 0xbd32
movl 0x130(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x130(%rsp)
jmp 0xbd16
movl 0x12c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x12c(%rsp)
jmp 0xbd16
movl 0x128(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x128(%rsp)
leaq 0x40(%rsp), %rdi
callq 0xc350
leaq 0x110(%rsp), %rdi
callq 0xc2f0
jmp 0xb971
leaq 0x110(%rsp), %rdi
callq 0xc2f0
jmp 0xbe01
movq 0xf285(%rip), %rdi      # 0x1afd0
movl $0xa, %esi
callq 0x21c0
movq 0xf274(%rip), %rdi      # 0x1afd0
leaq 0x66a3(%rip), %rsi      # 0x12406
callq 0x2170
movq %rax, %rdi
movl 0x130(%rsp), %esi
callq 0x2270
movq %rax, %rdi
leaq 0x6691(%rip), %rsi      # 0x12412
callq 0x2170
movq 0xf243(%rip), %rdi      # 0x1afd0
leaq 0x6686(%rip), %rsi      # 0x1241a
callq 0x2170
movq %rax, %rdi
movl 0x12c(%rsp), %esi
callq 0x2270
movq %rax, %rdi
leaq 0x6660(%rip), %rsi      # 0x12412
callq 0x2170
cmpl $0x0, 0x128(%rsp)
je 0xbdf2
movq 0xf208(%rip), %rdi      # 0x1afd0
leaq 0x6655(%rip), %rsi      # 0x12424
callq 0x2170
movq %rax, %rdi
movl 0x128(%rsp), %esi
callq 0x2270
movq %rax, %rdi
leaq 0x6643(%rip), %rsi      # 0x12430
callq 0x2170
movl 0x144(%rsp), %eax
addq $0x148, %rsp            # imm = 0x148
retq
movq 0xf8(%rsp), %rdi
callq 0x2280
nop