// File: 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
movq %rsp, %rbp
subq $0x6c0, %rsp            # imm = 0x6C0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x638(%rbp)
cvtsi2sdl 0x8(%rax), %xmm0
movsd %xmm0, -0x18(%rbp)
movsd 0x2bd8(%rip), %xmm0     # 0x14018
mulsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movl $0x0, -0x1c(%rbp)
movq -0x638(%rbp), %rdi
movl -0x1c(%rbp), %eax
movl %eax, -0x63c(%rbp)
addq $0xfc120, %rdi          # imm = 0xFC120
callq 0x77a0
movl %eax, %ecx
movl -0x63c(%rbp), %eax
cmpl %ecx, %eax
jge 0x114ea
movq -0x638(%rbp), %rdi
addq $0xfc120, %rdi          # imm = 0xFC120
movl -0x1c(%rbp), %esi
callq 0x7780
movl %eax, -0x20(%rbp)
movsd 0x32f5(%rip), %xmm0     # 0x147a0
mulsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x11462
movl $0x0, -0x24(%rbp)
movq -0x638(%rbp), %rdi
movl -0x24(%rbp), %eax
movl %eax, -0x640(%rbp)
addq $0xfc120, %rdi          # imm = 0xFC120
callq 0x77a0
movl %eax, %ecx
movl -0x640(%rbp), %eax
cmpl %ecx, %eax
jge 0x11885
movq -0x638(%rbp), %rdi
addq $0xfc120, %rdi          # imm = 0xFC120
movl -0x24(%rbp), %esi
callq 0x7780
movq -0x638(%rbp), %rdi
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %esi
movb (%rdi), %al
andb $0x1, %al
movzbl %al, %edx
callq 0xe560
testb $0x1, %al
jne 0x11552
jmp 0x11598
movsd 0x326e(%rip), %xmm0     # 0x147c8
mulsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movsd 0x3236(%rip), %xmm0     # 0x147b0
mulsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
jmp 0x11877
movq -0x638(%rbp), %rdi
movl -0x28(%rbp), %esi
movb (%rdi), %al
xorl %ecx, %ecx
andb $0x1, %al
movzbl %al, %edx
callq 0x7e60
testb $0x1, %al
jne 0x115b6
jmp 0x115f4
movsd 0x3202(%rip), %xmm0     # 0x147c0
mulsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
jmp 0x11877
movq -0x638(%rbp), %rax
movsd 0x319d(%rip), %xmm0     # 0x147a0
mulsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movslq -0x28(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movsd %xmm0, (%rcx)
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rcx
movslq -0x28(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movsd %xmm0, 0x8(%rcx)
cmpl $0xb, 0x8(%rax)
jle 0x11710
movq -0x638(%rbp), %rax
movslq -0x28(%rbp), %rcx
cmpl $0x0, 0xdf6f8(%rax,%rcx,4)
jne 0x116a6
movq -0x638(%rbp), %rdi
movl -0x28(%rbp), %esi
movl $0x4, %edx
callq 0x10500
testb $0x1, %al
jne 0x116a6
movsd 0x29a5(%rip), %xmm0     # 0x14018
mulsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
jmp 0x1170e
movq -0x638(%rbp), %rax
movslq -0x28(%rbp), %rcx
cmpl $0x3, 0xdf6f8(%rax,%rcx,4)
jne 0x1170c
movq -0x638(%rbp), %rdi
movl -0x28(%rbp), %esi
movl $0x4, %edx
callq 0x10500
testb $0x1, %al
jne 0x1170c
movsd 0x2935(%rip), %xmm0     # 0x14010
mulsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
jmp 0x1170e
jmp 0x11710
leaq -0x60(%rbp), %rdi
callq 0x73c0
movq -0x638(%rbp), %rdi
movl -0x28(%rbp), %esi
leaq -0x60(%rbp), %rdx
callq 0x7a10
movl %eax, -0x64(%rbp)
movl $0x0, -0x68(%rbp)
movl -0x68(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0x1181c
movl -0x68(%rbp), %esi
leaq -0x60(%rbp), %rdi
callq 0x73e0
movq %rax, %rdi
callq 0x73a0
testb $0x1, %al
jne 0x1175f
jmp 0x1180c
movl -0x68(%rbp), %esi
leaq -0x60(%rbp), %rdi
callq 0x73e0
movq %rax, %rdi
callq 0x7400
movq -0x638(%rbp), %rcx
andb $0x1, %al
movzbl %al, %eax
movb (%rcx), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
je 0x117d1
movsd 0x3025(%rip), %xmm0     # 0x147b8
mulsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movsd 0x2ffd(%rip), %xmm0     # 0x147b0
mulsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
jmp 0x11875
movsd 0x2fcf(%rip), %xmm0     # 0x147a8
mulsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
jmp 0x11875
jmp 0x1180e
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x11736
movq -0x638(%rbp), %rdi
movl -0x28(%rbp), %esi
movb (%rdi), %al
andb $0x1, %al
movzbl %al, %edx
callq 0xf2b0
testb $0x1, %al
jne 0x11838
jmp 0x11873
movsd 0x27d0(%rip), %xmm0     # 0x14010
mulsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
jmp 0x11877
jmp 0x11875
jmp 0x11877
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x114f1
movq -0x638(%rbp), %rax
cmpl $0x0, 0xd63e0(%rax)
jne 0x1189a
jmp 0x11d3c
leaq -0x618(%rbp), %rdi
callq 0x10ee0
movq -0x638(%rbp), %rdi
movl 0xd63e0(%rdi), %esi
leaq -0x618(%rbp), %rdx
callq 0xee40
movl $0x0, -0x61c(%rbp)
movl -0x61c(%rbp), %eax
movl %eax, -0x644(%rbp)
leaq -0x618(%rbp), %rdi
callq 0x10fb0
movl %eax, %ecx
movl -0x644(%rbp), %eax
cmpl %ecx, %eax
jge 0x119c1
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x668(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x660(%rbp)
movl -0x61c(%rbp), %esi
leaq -0x618(%rbp), %rdi
callq 0x110a0
movsd -0x668(%rbp), %xmm0
movl %eax, %ecx
movq -0x660(%rbp), %rax
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm1
movsd 0x2e56(%rip), %xmm2     # 0x14798
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x658(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x650(%rbp)
movl -0x61c(%rbp), %esi
leaq -0x618(%rbp), %rdi
callq 0x110a0
movsd -0x658(%rbp), %xmm0
movl %eax, %ecx
movq -0x650(%rbp), %rax
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm1
movsd 0x2df8(%rip), %xmm2     # 0x14798
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rax)
movl -0x61c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x61c(%rbp)
jmp 0x118c9
leaq -0x618(%rbp), %rdi
callq 0x10f20
movq -0x638(%rbp), %rdi
movl 0xd63e0(%rdi), %esi
leaq -0x618(%rbp), %rdx
callq 0xec60
movl $0x0, -0x620(%rbp)
movl -0x620(%rbp), %eax
movl %eax, -0x66c(%rbp)
leaq -0x618(%rbp), %rdi
callq 0x10fb0
movl %eax, %ecx
movl -0x66c(%rbp), %eax
cmpl %ecx, %eax
jge 0x11ad8
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x690(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x688(%rbp)
movl -0x620(%rbp), %esi
leaq -0x618(%rbp), %rdi
callq 0x110a0
movsd -0x690(%rbp), %xmm0
movl %eax, %ecx
movq -0x688(%rbp), %rax
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm1
addsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x680(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x678(%rbp)
movl -0x620(%rbp), %esi
leaq -0x618(%rbp), %rdi
callq 0x110a0
movsd -0x680(%rbp), %xmm0
movl %eax, %ecx
movq -0x678(%rbp), %rax
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm1
addsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rax)
movl -0x620(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x620(%rbp)
jmp 0x119f0
leaq -0x618(%rbp), %rdi
callq 0x10f20
movq -0x638(%rbp), %rdi
movl 0xd63e0(%rdi), %esi
leaq -0x618(%rbp), %rdx
callq 0xeda0
movl $0x0, -0x624(%rbp)
movl -0x624(%rbp), %eax
movl %eax, -0x694(%rbp)
leaq -0x618(%rbp), %rdi
callq 0x10fb0
movl %eax, %ecx
movl -0x694(%rbp), %eax
cmpl %ecx, %eax
jge 0x11bef
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x6b8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x6b0(%rbp)
movl -0x624(%rbp), %esi
leaq -0x618(%rbp), %rdi
callq 0x110a0
movsd -0x6b8(%rbp), %xmm0
movl %eax, %ecx
movq -0x6b0(%rbp), %rax
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm1
addsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x6a8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x6a0(%rbp)
movl -0x624(%rbp), %esi
leaq -0x618(%rbp), %rdi
callq 0x110a0
movsd -0x6a8(%rbp), %xmm0
movl %eax, %ecx
movq -0x6a0(%rbp), %rax
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm1
addsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rax)
movl -0x624(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x624(%rbp)
jmp 0x11b07
leaq -0x618(%rbp), %rdi
callq 0x10f20
movl $0x0, -0x628(%rbp)
movq -0x638(%rbp), %rcx
xorl %eax, %eax
cmpl $0x0, 0xd63e0(%rcx)
movb %al, -0x6b9(%rbp)
je 0x11c2d
cmpl $0x4, -0x628(%rbp)
setl %al
movb %al, -0x6b9(%rbp)
movb -0x6b9(%rbp), %al
testb $0x1, %al
jne 0x11c3c
jmp 0x11d3c
movl $0x0, -0x62c(%rbp)
movl -0x62c(%rbp), %eax
movl -0x628(%rbp), %ecx
addl $0x1, %ecx
shll $0x2, %ecx
cmpl %ecx, %eax
jge 0x11d26
movq -0x638(%rbp), %rcx
movq %rcx, %rax
addq $0xdfca0, %rax          # imm = 0xDFCA0
movslq 0xd63e0(%rcx), %rcx
imulq $0x140, %rcx, %rcx      # imm = 0x140
addq %rcx, %rax
movslq -0x628(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movslq -0x62c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x630(%rbp)
cmpl $0x0, -0x630(%rbp)
je 0x11d10
cvtsi2sdl -0x628(%rbp), %xmm0
movsd 0x2ad8(%rip), %xmm1     # 0x14790
mulsd %xmm1, %xmm0
movsd 0x235c(%rip), %xmm1     # 0x14020
addsd %xmm1, %xmm0
movsd -0x18(%rbp), %xmm2
movq -0x10(%rbp), %rax
movslq -0x630(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rax
movslq -0x630(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
addsd 0x8(%rax), %xmm0
movsd %xmm0, 0x8(%rax)
jmp 0x11d12
movl -0x62c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x62c(%rbp)
jmp 0x11c46
jmp 0x11d28
movl -0x628(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x628(%rbp)
jmp 0x11c05
addq $0x6c0, %rsp            # imm = 0x6C0
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop