// File: /workspace/github_cpp_makefile_star2_O1/antoniogarro[P]Hara/priors.cpp
// Function: Goban::init_priors(Prior*) const
void Goban::init_priors(Prior priors[]) const
{
  const double EQUIV = size;// /2;
  priors[PASS].prior = 0.1*EQUIV, priors[PASS].equiv = EQUIV;

  for(int i = 0; i < empty_points.length(); ++i){    
    int p = empty_points[i];
       priors[p].prior = 0.5*EQUIV, priors[p].equiv = EQUIV;
    }
    for(int i = 0; i < empty_points.length(); ++i){    
    int p = empty_points[i];
    if(is_self_atari(p, side)){
      priors[p].prior = 0.2*EQUIV, priors[p].equiv = 2*EQUIV;
      continue;
    }  
    if(is_surrounded(p, side)){
      priors[p].prior = 0.3*EQUIV, priors[p].equiv = EQUIV;
      continue;
    }
    priors[p].prior = 0.5*EQUIV, priors[p].equiv = EQUIV;
    if(size > 11){
      if(distance_to_edge[p] == 0 && !stones_around(p, 4)){
        priors[p].prior = 0.1*EQUIV, priors[p].equiv = EQUIV;
      }
      else if(distance_to_edge[p] == 3 && !stones_around(p, 4)){
        priors[p].prior = 0.9*EQUIV, priors[p].equiv = EQUIV;
      }
    }
    
    GroupSet<4> neigh;
    int nneigh = neighbour_groups(p, neigh);
    for(int j = 0; j < nneigh; j++){
      if(neigh[j]->has_one_liberty()){
        if(neigh[j]->get_color() != side){
          priors[p].prior = 1.4*EQUIV, priors[p].equiv = 2*EQUIV;
          goto endloop;
        }
        else{
          priors[p].prior = 0.6*EQUIV, priors[p].equiv = EQUIV;
          goto endloop;
        }
      }
    }
    if(match_mogo_pattern(p, side)){
      priors[p].prior = 0.9*EQUIV, priors[p].equiv = EQUIV;
      continue;
    }
  endloop:;
  }
  
  if(last_point == 0) return;
  
  PointSet<MAXSIZE2> list;
  capture_heuristic(last_point, list);
  for(int i = 0; i < list.length(); i++){
    priors[list[i]].prior += 3*EQUIV, priors[list[i]].equiv += 3*EQUIV;
  }
  list.clear();

  save_heuristic(last_point, list);
  for(int i = 0; i < list.length(); i++){
    priors[list[i]].prior += 2*EQUIV, priors[list[i]].equiv += 2*EQUIV;
  }
  list.clear();

  pattern_heuristic(last_point, list);
  for(int i = 0; i < list.length(); i++){
    priors[list[i]].prior += 2*EQUIV, priors[list[i]].equiv += 2*EQUIV;
  }
  list.clear();

  
  for(int i = 0; last_point && i < 4; i++){
    for(int j = 0; j < 4*(i+1); j++){
      int v =  within_manhattan[last_point][i][j];
      if(v) {
        priors[v].prior += (1.0-0.1*i)*EQUIV, priors[v].equiv += EQUIV;
      }
    }
  }
  
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5e8, %rsp            # imm = 0x5E8
movq %rsi, %rbx
movq %rdi, %r14
cvtsi2sdl 0x8(%rdi), %xmm1
movsd 0x175c(%rip), %xmm0     # 0xb028
mulsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd %xmm0, (%rsi)
movsd %xmm1, 0x8(%rsi)
movslq 0xfc6d0(%rdi), %rax
testq %rax, %rax
jle 0x9918
movsd 0x1e9d(%rip), %xmm0     # 0xb790
mulsd %xmm1, %xmm0
xorl %ecx, %ecx
movslq 0xfc128(%r14,%rcx,4), %rdx
shlq $0x4, %rdx
movsd %xmm0, (%rbx,%rdx)
movsd %xmm1, 0x8(%rbx,%rdx)
incq %rcx
cmpq %rcx, %rax
jne 0x98f9
cmpl $0x0, 0xfc6d0(%r14)
movapd %xmm1, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd %xmm1, (%rsp)
jle 0x9b40
movsd 0x1e4f(%rip), %xmm0     # 0xb790
mulsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x16b5(%rip), %xmm0     # 0xb008
mulsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x1e33(%rip), %xmm0     # 0xb798
mulsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x1e29(%rip), %xmm0     # 0xb7a0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
xorl %r13d, %r13d
movl 0xfc128(%r14,%r13,4), %ebp
movslq %ebp, %r12
movzbl (%r14), %edx
movq %r14, %rdi
movl %r12d, %esi
callq 0x82e4
testb %al, %al
je 0x99c4
shlq $0x4, %r12
movsd 0x30(%rsp), %xmm0
movsd %xmm0, (%rbx,%r12)
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rbx,%r12)
jmp 0x9b2d
movzbl (%r14), %edx
movq %r14, %rdi
movl %r12d, %esi
xorl %ecx, %ecx
callq 0x543c
movq %r12, %r15
shlq $0x4, %r15
addq %rbx, %r15
testb %al, %al
je 0x99f8
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%r15)
movsd (%rsp), %xmm0
jmp 0x9b27
movsd 0x28(%rsp), %xmm0
movsd %xmm0, (%r15)
movsd (%rsp), %xmm0
movsd %xmm0, 0x8(%r15)
cmpl $0xc, 0x8(%r14)
jl 0x9a6e
cmpl $0x0, 0xdf6f8(%r14,%r12,4)
jne 0x9a39
movq %r14, %rdi
movl %ebp, %esi
movl $0x4, %edx
callq 0x902a
movsd 0x18(%rsp), %xmm0
testb %al, %al
je 0x9a5e
cmpl $0x3, 0xdf6f8(%r14,%r12,4)
jne 0x9a6e
movq %r14, %rdi
movl %r12d, %esi
movl $0x4, %edx
callq 0x902a
movsd 0x10(%rsp), %xmm0
testb %al, %al
jne 0x9a6e
movsd %xmm0, (%r15)
movsd (%rsp), %xmm0
movsd %xmm0, 0x8(%r15)
movl $0x0, 0x68(%rsp)
movq $0x0, 0x38(%rsp)
movq %r14, %rdi
movl %r12d, %esi
leaq 0x38(%rsp), %rdx
callq 0x5210
testl %eax, %eax
setg %cl
movsd (%rsp), %xmm2
jle 0x9b05
movq 0x38(%rsp), %rdx
cmpl $0x1, 0x96c(%rdx)
je 0x9acd
movl %eax, %eax
leaq -0x1(%rax), %rcx
xorl %esi, %esi
cmpq %rsi, %rcx
je 0x9b05
movq 0x40(%rsp,%rsi,8), %rdx
incq %rsi
cmpl $0x1, 0x96c(%rdx)
jne 0x9ab1
cmpq %rax, %rsi
setb %cl
movb (%r14), %sil
xorl %eax, %eax
movapd %xmm2, %xmm0
cmpb (%rdx), %sil
sete %dl
je 0x9ae4
movsd 0x8(%rsp), %xmm0
movb %dl, %al
leaq 0x1ccb(%rip), %rdx      # 0xb7b8
movsd (%rdx,%rax,8), %xmm1
mulsd %xmm2, %xmm1
movsd %xmm1, (%r15)
movsd %xmm0, 0x8(%r15)
testb %cl, %cl
jne 0x9b2d
movzbl (%r14), %edx
movq %r14, %rdi
movl %ebp, %esi
callq 0x8b30
movsd (%rsp), %xmm0
testb %al, %al
je 0x9b2d
movsd 0x10(%rsp), %xmm1
movsd %xmm1, (%r15)
movsd %xmm0, 0x8(%r15)
incq %r13
movslq 0xfc6d0(%r14), %rax
cmpq %rax, %r13
jl 0x9984
movl 0xd63e0(%r14), %esi
testl %esi, %esi
je 0x9d36
xorl %ebp, %ebp
leaq 0x38(%rsp), %r15
movl %ebp, 0x5ac(%r15)
movl %ebp, 0x8(%r15)
leaq 0x61b8(%rip), %rax      # 0xfd20
movq %rax, (%r15)
movq %r14, %rdi
movq %r15, %rdx
callq 0x8880
movslq 0x5ac(%r15), %rax
testq %rax, %rax
jle 0x9bc0
xorl %ecx, %ecx
movsd 0x1c1c(%rip), %xmm0     # 0xb7a8
mulsd (%rsp), %xmm0
movslq 0x40(%rsp,%rcx,4), %rdx
shlq $0x4, %rdx
movsd (%rbx,%rdx), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rbx,%rdx)
movsd 0x8(%rbx,%rdx), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rbx,%rdx)
incq %rcx
cmpq %rcx, %rax
jne 0x9b91
leaq 0x38(%rsp), %r15
movl %ebp, 0x5ac(%r15)
movl %ebp, 0x8(%r15)
movl 0xd63e0(%r14), %esi
movq %r14, %rdi
movq %r15, %rdx
callq 0x873c
movslq 0x5ac(%r15), %rax
testq %rax, %rax
movsd 0x8(%rsp), %xmm1
jle 0x9c25
xorl %ecx, %ecx
movslq 0x40(%rsp,%rcx,4), %rdx
shlq $0x4, %rdx
movsd (%rbx,%rdx), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rbx,%rdx)
movsd 0x8(%rbx,%rdx), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rbx,%rdx)
incq %rcx
cmpq %rcx, %rax
jne 0x9bf6
xorl %ebp, %ebp
leaq 0x38(%rsp), %r15
movl %ebp, 0x5ac(%r15)
movl %ebp, 0x8(%r15)
movl 0xd63e0(%r14), %esi
movq %r14, %rdi
movq %r15, %rdx
callq 0x881a
movsd 0x8(%rsp), %xmm1
movslq 0x5ac(%r15), %rax
testq %rax, %rax
jle 0x9c8c
xorl %ecx, %ecx
movslq 0x40(%rsp,%rcx,4), %rdx
shlq $0x4, %rdx
movsd (%rbx,%rdx), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rbx,%rdx)
movsd 0x8(%rbx,%rdx), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rbx,%rdx)
incq %rcx
cmpq %rcx, %rax
jne 0x9c5d
movl %ebp, 0x5e4(%rsp)
movl %ebp, 0x40(%rsp)
movslq 0xd63e0(%r14), %rax
testq %rax, %rax
movsd (%rsp), %xmm4
je 0x9d36
leaq (%rax,%rax,4), %rcx
shlq $0x6, %rcx
addq %r14, %rcx
addq $0xdfca0, %rcx          # imm = 0xDFCA0
movl $0x4, %edx
xorl %esi, %esi
movsd 0x1ae3(%rip), %xmm0     # 0xb7b0
movsd 0x134b(%rip), %xmm1     # 0xb020
xorps %xmm2, %xmm2
cvtsi2sd %esi, %xmm2
mulsd %xmm0, %xmm2
addsd %xmm1, %xmm2
mulsd %xmm4, %xmm2
xorl %edi, %edi
movslq (%rcx,%rdi,4), %r8
testq %r8, %r8
je 0x9d19
shlq $0x4, %r8
movsd (%rbx,%r8), %xmm3
addsd %xmm2, %xmm3
movsd %xmm3, (%rbx,%r8)
movsd 0x8(%rbx,%r8), %xmm3
addsd %xmm4, %xmm3
movsd %xmm3, 0x8(%rbx,%r8)
incq %rdi
cmpq %rdi, %rdx
jne 0x9cea
cmpq $0x2, %rsi
ja 0x9d36
incq %rsi
addq $0x4, %rdx
addq $0x50, %rcx
testl %eax, %eax
jne 0x9cd5
addq $0x5e8, %rsp            # imm = 0x5E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq