// File: jswaff[P]prophet3/test/eval__test.cpp
// Function: test_eval_rook()
void test_eval_rook() {
    position pos;

    set_pos(&pos,"6k1/3R4/8/8/8/8/8/3K4 w - - 0 1");
    int32 score = eval(&pos,false);
    assert(score==rook_val + rook_on_7th + rook_open_file);

    set_pos(&pos,"6k1/3RR3/8/8/8/8/8/3K4 w - - 0 1");
    score = eval(&pos,false);
    assert(score==rook_val*2 + rook_on_7th*2 + connected_majors_on_7th + rook_open_file*2);

    set_pos(&pos,"6k1/3RRr2/8/8/8/8/8/3K4 w - - 0 1");
    score = eval(&pos,false);
    // white has two rooks on open files and black one, so net 1 for white
    assert(score==rook_val + rook_on_7th*2 + connected_majors_on_7th + rook_open_file);

    set_pos(&pos,"6k1/3RRr2/8/8/8/8/r7/3K4 w - - 0 1");
    score = eval(&pos,false);
    assert(score==rook_on_7th + connected_majors_on_7th);

    set_pos(&pos,"6k1/3RRr2/8/8/8/r7/8/3K4 w - - 0 1");
    score = eval(&pos,false);
    // deduct for black for rook on A file
    assert(score==rook_on_7th*2 + connected_majors_on_7th - rook_pst[fliprank[A3]]);

    set_pos(&pos,"6k1/8/8/8/8/8/qr6/7K b - - 0 1");
    score = eval(&pos,false);
    assert(score==queen_val + rook_val + rook_on_7th*2 + connected_majors_on_7th
            + rook_open_file
            + queen_pst[A2]
            - eval_scale(king_safety_pawn_far_away*2+king_safety_pawn_far_away/2,queen_val+rook_val));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
leaq -0x1c8(%rbp), %rdi
leaq 0x216ab(%rip), %rsi     # 0x3b314
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
xorl %esi, %esi
callq 0x7630
movl %eax, -0x1cc(%rbp)
cmpl $0x23f, -0x1cc(%rbp)    # imm = 0x23F
jne 0x19c90
jmp 0x19caf
leaq 0x2169d(%rip), %rdi     # 0x3b334
leaq 0x213b2(%rip), %rsi     # 0x3b050
movl $0x35, %edx
leaq 0x216b9(%rip), %rcx     # 0x3b363
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
leaq 0x216bc(%rip), %rsi     # 0x3b379
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
xorl %esi, %esi
callq 0x7630
movl %eax, -0x1cc(%rbp)
cmpl $0x4ce, -0x1cc(%rbp)    # imm = 0x4CE
jne 0x19ce4
jmp 0x19d03
leaq 0x216af(%rip), %rdi     # 0x3b39a
leaq 0x2135e(%rip), %rsi     # 0x3b050
movl $0x39, %edx
leaq 0x21665(%rip), %rcx     # 0x3b363
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
leaq 0x216d8(%rip), %rsi     # 0x3b3e9
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
xorl %esi, %esi
callq 0x7630
movl %eax, -0x1cc(%rbp)
cmpl $0x2c1, -0x1cc(%rbp)    # imm = 0x2C1
jne 0x19d38
jmp 0x19d57
leaq 0x216cc(%rip), %rdi     # 0x3b40b
leaq 0x2130a(%rip), %rsi     # 0x3b050
movl $0x3e, %edx
leaq 0x21611(%rip), %rcx     # 0x3b363
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
leaq 0x216f1(%rip), %rsi     # 0x3b456
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
xorl %esi, %esi
callq 0x7630
movl %eax, -0x1cc(%rbp)
cmpl $0x82, -0x1cc(%rbp)
jne 0x19d8c
jmp 0x19dab
leaq 0x216e6(%rip), %rdi     # 0x3b479
leaq 0x212b6(%rip), %rsi     # 0x3b050
movl $0x42, %edx
leaq 0x215bd(%rip), %rcx     # 0x3b363
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
leaq 0x216ed(%rip), %rsi     # 0x3b4a6
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
xorl %esi, %esi
callq 0x7630
movl %eax, -0x1cc(%rbp)
movl -0x1cc(%rbp), %eax
movslq 0x23071(%rip), %rsi     # 0x3ce50
movl $0xb4, %ecx
leaq 0x234c5(%rip), %rdx     # 0x3d2b0
subl (%rdx,%rsi,4), %ecx
cmpl %ecx, %eax
jne 0x19df4
jmp 0x19e13
leaq 0x216ce(%rip), %rdi     # 0x3b4c9
leaq 0x2124e(%rip), %rsi     # 0x3b050
movl $0x47, %edx
leaq 0x21555(%rip), %rcx     # 0x3b363
callq 0x20c0
leaq -0x1c8(%rbp), %rdi
leaq 0x216f0(%rip), %rsi     # 0x3b511
callq 0xf3e0
leaq -0x1c8(%rbp), %rdi
xorl %esi, %esi
callq 0x7630
movl %eax, -0x1cc(%rbp)
movl -0x1cc(%rbp), %eax
movl %eax, -0x1d0(%rbp)
movl 0x23124(%rip), %eax     # 0x3cf70
addl $0x645, %eax            # imm = 0x645
movl %eax, -0x1d4(%rbp)
movl $0xffffffb5, %edi       # imm = 0xFFFFFFB5
movl $0x578, %esi            # imm = 0x578
callq 0x7170
movl -0x1d4(%rbp), %ecx
movl %eax, %edx
movl -0x1d0(%rbp), %eax
subl %edx, %ecx
cmpl %ecx, %eax
jne 0x19e7c
jmp 0x19e9b
leaq 0x216ad(%rip), %rdi     # 0x3b530
leaq 0x211c6(%rip), %rsi     # 0x3b050
movl $0x4e, %edx
leaq 0x214cd(%rip), %rcx     # 0x3b363
callq 0x20c0
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
nopw %cs:(%rax,%rax)