// File: /workspace/github_cpp_makefile_star2_O1/tewalds[P]morat/havannah/agentmctsthread.cpp
// Function: Morat::Havannah::AgentMCTS::AgentThread::add_knowledge(Morat::Havannah::Board const&, Morat::Havannah::AgentMCTS::Node*, Morat::Havannah::AgentMCTS::Node*)
void AgentMCTS::AgentThread::add_knowledge(const Board & board, Node * node, Node * child){
	if(agent->localreply){ //boost for moves near the previous move
		int dist = board.dist(node->move, child->move);
		if(dist < 4)
			child->know += agent->localreply * (4 - dist);
	}

	if(agent->locality) //boost for moves near previous stones
		child->know += agent->locality * board.local(child->move, board.to_play());

	Board::Cell cell;
	if(agent->connect || agent->size)
		cell = board.test_cell(child->move);

	if(agent->connect) //boost for moves that connect to edges/corners
		child->know += agent->connect * (cell.numcorners() + cell.numedges());

	if(agent->size) //boost for size of the group
		child->know += agent->size * cell.size;

	if(agent->bridge && test_bridge_probe(board, node->move, child->move)) //boost for maintaining a virtual connection
		child->know += agent->bridge;

	if(agent->dists)
		child->know += abs(agent->dists) * std::max(0, board.lines() - dists.get(child->move, board.to_play()));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r14
movq 0x40(%rdi), %rax
movl 0x110(%rax), %ecx
testl %ecx, %ecx
je 0x17a8c
movsbl 0x25(%r12), %edx
movsbl 0x25(%rbx), %esi
movl %edx, %edi
subl %esi, %edi
movl %edi, %r8d
negl %r8d
cmovsl %edi, %r8d
movl $0xff, %edi
andl %edi, %r8d
movsbl 0x24(%r12), %r9d
movsbl 0x24(%rbx), %r10d
addl %r9d, %esi
subl %r10d, %r9d
movl %r9d, %r11d
negl %r11d
cmovsl %r9d, %r11d
andl %edi, %r11d
addl %r8d, %r11d
subl %esi, %edx
addl %r10d, %edx
movl %edx, %esi
negl %esi
cmovsl %edx, %esi
addl %r11d, %esi
cmpl $0x7, %esi
ja 0x17a8c
shrl %esi
movl $0x4, %edx
subl %esi, %edx
imull %ecx, %edx
addw %dx, 0x20(%rbx)
movl 0x114(%rax), %ebp
testl %ebp, %ebp
je 0x17abb
movsbl 0x24(%rbx), %eax
movsbl (%r15), %ecx
imull %eax, %ecx
movsbl 0x25(%rbx), %esi
addl %ecx, %esi
movzbl 0xa(%r15), %edx
movq %r15, %rdi
callq 0x18ea4
imull %ebp, %eax
addw %ax, 0x20(%rbx)
movq 0x40(%r14), %rax
cmpl $0x0, 0x118(%rax)
jne 0x17ad5
cmpl $0x0, 0x11c(%rax)
je 0x17bc1
leaq 0x24(%rbx), %rsi
movq %r15, %rdi
callq 0x18534
movl $0x820, %ecx            # imm = 0x820
bextrq %rcx, %rax, %rcx
movl $0x828, %edx            # imm = 0x828
bextrq %rdx, %rax, %rdx
movzbl %ah, %eax
movq 0x40(%r14), %r13
movl 0x118(%r13), %esi
testl %esi, %esi
je 0x17b1f
leaq 0x1df62(%rip), %rdi     # 0x35a70
movzbl (%rcx,%rdi), %ecx
movzbl (%rdx,%rdi), %edx
addl %ecx, %edx
imull %esi, %edx
addw %dx, 0x20(%rbx)
movl 0x11c(%r13), %ecx
testl %ecx, %ecx
je 0x17b31
imull %eax, %ecx
addw %cx, 0x20(%rbx)
movl 0x120(%r13), %ebp
testl %ebp, %ebp
je 0x17b57
addq $0x24, %r12
leaq 0x24(%rbx), %rcx
movq %r15, %rsi
movq %r12, %rdx
callq 0x17bcc
testb %al, %al
je 0x17b57
addw %bp, 0x20(%rbx)
movl 0x124(%r13), %eax
testl %eax, %eax
je 0x17bb2
movl %eax, %ebp
negl %ebp
cmovsl %eax, %ebp
movsbl (%r15), %r12d
movzwl 0x24(%rbx), %eax
movsbl %al, %ecx
shrl $0x8, %eax
movq 0xf410(%r14), %rdx
addq $0x28e8, %r14           # imm = 0x28E8
movsbl (%rdx), %edx
imull %ecx, %edx
movsbl %al, %esi
addl %edx, %esi
movzbl 0xa(%r15), %edx
movq %r14, %rdi
callq 0x18d3c
subl %eax, %r12d
movl %r12d, %eax
sarl $0x1f, %eax
andnl %r12d, %eax, %eax
imull %ebp, %eax
addw %ax, 0x20(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ecx, %ecx
xorl %edx, %edx
xorl %eax, %eax
jmp 0x17af8