// File: /workspace/github_cpp_makefile_star2_O2/tewalds[P]morat/hex/agentmctsthread.cpp
// Function: Morat::Hex::AgentMCTS::AgentThread::rollout(Morat::Hex::Board&, Morat::Move, int)
Outcome AgentMCTS::AgentThread::rollout(Board & board, Move move, int depth){
	Outcome won;

	if(agent->instantwin)
		instant_wins.rollout_start(board, agent->instantwin);

	random_policy.rollout_start(board);

	while((won = board.outcome()) < Outcome::DRAW){
		Side turn = board.to_play();

		move = rollout_choose_move(board, move);

		movelist.addrollout(move, turn);

		assert2(board.move(move, true, false), "\n" + board.to_s(true) + "\n" + move.to_s());
		depth++;
	}

	gamelen.add(depth);

	if(won > Outcome::DRAW)
		win_types[won.to_i() - 1][(int)board.win_type()].add(depth);

	//update the last good reply table
	if(agent->lastgoodreply)
		last_good_reply.rollout_end(board, movelist, won);

	movelist.finishrollout(won);
	return won;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movw %dx, 0x6(%rsp)
movl %ecx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x40(%rdi), %rax
movl 0xd8(%rax), %eax
testl %eax, %eax
je 0x11fbc
movsbl (%rbx), %ecx
imull %eax, %ecx
negl %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
movl %ecx, 0x2f08(%r14)
andl $0x0, 0x2f0c(%r14)
movw $0x78fc, 0x2f10(%r14)   # imm = 0x78FC
movl 0xefc(%r14), %eax
leaq 0x119b8(%r14), %r13
leaq 0x6(%rsp), %r12
movl %eax, 0xf00(%r14)
movsbq 0x9(%rbx), %r15
leaq 0x14ecf(%rip), %rax     # 0x26eb1
cmpb (%rax), %r15b
jge 0x12040
movb 0x8(%rbx), %r15b
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x124aa
movw %ax, 0x6(%rsp)
movq %rbx, %rdi
movslq 0x12110(%r14), %rdx
movslq 0x1210c(%r14), %rcx
addq %rdx, %rcx
leal 0x1(%rdx), %esi
leaq (%rcx,%rcx,2), %rcx
movl %esi, 0x12110(%r14)
movq %r12, %rsi
movw %ax, (%r13,%rcx)
movb %r15b, 0x2(%r13,%rcx)
pushq $0x1
popq %rdx
xorl %ecx, %ecx
callq 0xe1ea
testb %al, %al
je 0x120ba
incl %ebp
jmp 0x11fd6
leaq 0x12148(%r14), %rdi
movl %ebp, %esi
callq 0x126b2
leaq 0x14e5c(%rip), %rax     # 0x26eb1
cmpb (%rax), %r15b
jle 0x12070
movq %r15, %rax
shlq $0x5, %rax
movl %ebp, %esi
leaq 0x12148(%rax,%r14), %rdi
callq 0x126b2
movq 0x40(%r14), %rax
cmpl $0x0, 0xd4(%rax)
je 0x12093
leaq 0x4c(%r14), %rdi
leaq 0xcb78(%r14), %rdx
movq %rbx, %rsi
movl %r15d, %ecx
callq 0x12a10
addq $0xcb78, %r14           # imm = 0xCB78
movl %r15d, %esi
movq %r14, %rdi
callq 0x12606
movl %r15d, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x29f2f(%rip), %rdi     # 0x3bff0
leaq 0x125d9(%rip), %rsi     # 0x246a1
callq 0x5320
leaq 0x12465(%rip), %rsi     # 0x24539
movq %rax, %rdi
callq 0x5320
leaq 0x125f3(%rip), %rsi     # 0x246d6
movq %rax, %rdi
callq 0x5320
movl $0x1ad, %esi            # imm = 0x1AD
movq %rax, %rdi
callq 0x5610
leaq 0x11273(%rip), %rsi     # 0x23372
movq %rax, %rdi
callq 0x5320
movq %rax, %r14
leaq 0x88(%rsp), %r15
pushq $0x1
popq %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x17dc6
leaq 0x107b5(%rip), %rsi     # 0x228dc
leaq 0x28(%rsp), %rdi
movq %r15, %rdx
callq 0xcf8b
leaq 0x107a1(%rip), %rdx     # 0x228dc
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x8051
leaq 0x8(%rsp), %rdi
leaq 0x6(%rsp), %rsi
callq 0xcfb0
leaq 0x68(%rsp), %rdi
leaq 0x48(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0xcf24
leaq 0x68(%rsp), %rsi
movq %r14, %rdi
callq 0x52c0
movq %rax, %rdi
callq 0x5170
leaq 0x68(%rsp), %rdi
callq 0x5150
leaq 0x8(%rsp), %rdi
callq 0x5150
leaq 0x48(%rsp), %rdi
callq 0x5150
leaq 0x28(%rsp), %rdi
callq 0x5150
leaq 0x88(%rsp), %rdi
callq 0x5150
pushq $0x1
popq %rdi
callq 0x5430
leaq 0x68(%rsp), %rdi
movq %rax, %rbx
callq 0x5150
jmp 0x121d1
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x5150
jmp 0x121e0
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x5150
jmp 0x121ef
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x5150
jmp 0x121fe
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x5150
movq %rbx, %rdi
callq 0x5650