cleanup
This commit is contained in:
@@ -40,7 +40,6 @@
|
||||
*/
|
||||
bool sq_is_attacked(const pos_t *pos, const bitboard_t occ, const square_t sq, const color_t c)
|
||||
{
|
||||
bitboard_t sqbb = mask(sq);
|
||||
color_t opp = OPPONENT(c);
|
||||
|
||||
/* bishop / queen */
|
||||
|
@@ -160,10 +160,10 @@ void bitboard_init(void)
|
||||
/* 3) pawn, knight and king attacks
|
||||
*/
|
||||
for (square_t sq = A1; sq <= H8; ++sq) {
|
||||
if (sq >= A2 && sq <= H7) {
|
||||
bb_pawn_attacks[WHITE][sq] = pawn_attacks_bb(mask(sq), WHITE);
|
||||
if (sq >= A2)
|
||||
bb_pawn_attacks[BLACK][sq] = pawn_attacks_bb(mask(sq), BLACK);
|
||||
}
|
||||
if (sq <= H7)
|
||||
bb_pawn_attacks[WHITE][sq] = pawn_attacks_bb(mask(sq), WHITE);
|
||||
|
||||
for (int vec = 0; vec < 8; ++vec) {
|
||||
int dst = sq + knight_vector[vec];
|
||||
|
@@ -314,6 +314,7 @@ static __always_inline bitboard_t shift_nw(const bitboard_t bb)
|
||||
#define pawn_shift_up(bb, c) ((c) == WHITE ? shift_n(bb): shift_s(bb))
|
||||
#define pawn_shift_upleft(bb, c) ((c) == WHITE ? shift_nw(bb): shift_se(bb))
|
||||
#define pawn_shift_upright(bb, c) ((c) == WHITE ? shift_ne(bb): shift_sw(bb))
|
||||
|
||||
#define pawn_attacks_bb(bb, c) (pawn_shift_upleft(bb, c) | \
|
||||
pawn_shift_upright(bb, c))
|
||||
|
||||
@@ -321,8 +322,8 @@ static __always_inline bitboard_t shift_nw(const bitboard_t bb)
|
||||
* Need to make functions with control instead.
|
||||
*/
|
||||
#define pawn_push_up(sq, c) ((sq) + ((c) == WHITE ? NORTH: SOUTH))
|
||||
#define pawn_push_upleft(sq, c) ((sq) + ((c) == WHITE ? NORTH_WEST: SOUTH_EAST))
|
||||
#define pawn_push_upright(sq, c) ((sq) + ((c) == WHITE ? NORTH_EAST: SOUTH_WEST))
|
||||
//#define pawn_push_upleft(sq, c) ((sq) + ((c) == WHITE ? NORTH_WEST: SOUTH_EAST))
|
||||
//#define pawn_push_upright(sq, c) ((sq) + ((c) == WHITE ? NORTH_EAST: SOUTH_WEST))
|
||||
|
||||
bitboard_t bitboard_between_excl(square_t sq1, square_t sq2);
|
||||
void bitboard_init(void);
|
||||
|
@@ -35,10 +35,9 @@ struct fentest {
|
||||
""
|
||||
},
|
||||
*/
|
||||
/* tests rank movegen bug - FIXED
|
||||
*/
|
||||
//"4k3/pppppppp/8/8/8/8/PPPPPPPP/2BRK3 w - - 0 1",
|
||||
//"4k3/pppppppp/8/8/8/8/PPPPPPPP/1B1R1K2 w - - 0 1",
|
||||
|
||||
/* ***************** TEMP TESTS ABOVE ************************** */
|
||||
|
||||
{ __LINE__, MOVEGEN | MOVEDO | PERFT,
|
||||
"illegal white e.p.",
|
||||
"3k4/8/5K2/3pP3/8/2b5/8/8 w - d6 0 1",
|
||||
@@ -92,43 +91,43 @@ struct fentest {
|
||||
* },
|
||||
*/
|
||||
{ __LINE__, ATTACK,
|
||||
"checkers: a1 h1",
|
||||
"1k6/8/8/8/8/8/8/r2K3r w - - 1 1"
|
||||
"only 3 K moves (but impossible situation)",
|
||||
"1k6/8/8/8/8/8/8/r2K3r w - - 0 1"
|
||||
},
|
||||
{ __LINE__, ATTACK,
|
||||
"checkers: a8 h8",
|
||||
"R2k3R/8/8/8/8/8/8/1K6 b - - 1 1"
|
||||
"R2k3R/8/8/8/8/8/8/1K6 b - - 0 1"
|
||||
},
|
||||
{ __LINE__, ATTACK,
|
||||
"checkers: b3 g3",
|
||||
"1k6/8/8/8/8/1r1K2r1/8/8 w - - 1 1"
|
||||
"1k6/8/8/8/8/1r1K2r1/8/8 w - - 0 1"
|
||||
},
|
||||
|
||||
{ __LINE__, ATTACK,
|
||||
"checkers: b6 g6",
|
||||
"8/8/1R1k2R1/8/8/8/8/1K6 b - - 1 1"
|
||||
"8/8/1R1k2R1/8/8/8/8/1K6 b - - 0 1"
|
||||
},
|
||||
|
||||
{ __LINE__, ATTACK,
|
||||
"checkers: g2 g7",
|
||||
"8/k5r1/8/8/6K1/8/6r1/8 w - - 1 1"
|
||||
"8/k5r1/8/8/6K1/8/6r1/8 w - - 0 1"
|
||||
},
|
||||
{ __LINE__, ATTACK,
|
||||
"checkers: g2 g7",
|
||||
"8/6R1/8/6k1/8/8/K5R1/8 b - - 1 1"
|
||||
"8/6R1/8/6k1/8/8/K5R1/8 b - - 0 1"
|
||||
},
|
||||
{ __LINE__, ATTACK,
|
||||
"checkers: d5 e3, pinners: none (2 pieces between attacker & K)",
|
||||
"3k4/8/8/3r3b/b7/1N2nn2/2n1B3/rNBK1Rbr w - - 1 1"
|
||||
"3k4/8/8/3r3b/b7/1N2nn2/2n1B3/rNBK1Rbr w - - 0 1"
|
||||
},
|
||||
|
||||
{ __LINE__, ATTACK,
|
||||
"checkers: d4 e6 pinners: h4 a5 a8 h8",
|
||||
"Rn1k1r1R/4b3/1n2N3/B7/3R3B/8/8/3K4 b - - 1 1"
|
||||
"Rn1k1r1R/4b3/1n2N3/B7/3R3B/8/8/3K4 b - - 0 1"
|
||||
},
|
||||
{ __LINE__, ATTACK,
|
||||
"checkers: d5 e3, pinners: a1 h1 a4 h5",
|
||||
"3k4/8/8/3r3b/b7/1N2n3/4B3/rN1K1R1r w - - 1 0"
|
||||
"3k4/8/8/3r3b/b7/1N2n3/4B3/rN1K1R1r w - - 0 1"
|
||||
},
|
||||
|
||||
{ __LINE__, MOVEGEN | MOVEDO | PERFT,
|
||||
|
@@ -232,16 +232,15 @@ int main(int __unused ac, __unused char**av)
|
||||
movelist_t fishmoves;
|
||||
//move_t move;
|
||||
FILE *outfd;
|
||||
int depth = 6;
|
||||
s64 ms1 = 0, ms1_total = 0;
|
||||
s64 ms2 = 0, ms2_total = 0;
|
||||
s64 ms3 = 0, ms3_total = 0;
|
||||
int run = 7;
|
||||
|
||||
int depth = 6, run = 3;
|
||||
|
||||
if (ac > 1)
|
||||
depth = atoi(av[1]);
|
||||
if (ac > 2)
|
||||
run = atoi(av[2]);
|
||||
run = atoi(av[2]) & 3;
|
||||
printf("depth = %d run=%d\n", depth, run);
|
||||
|
||||
if (!run)
|
||||
@@ -253,7 +252,6 @@ int main(int __unused ac, __unused char**av)
|
||||
bitboard_init();
|
||||
hyperbola_init();
|
||||
|
||||
|
||||
CLOCK_DEFINE(clock, CLOCK_PROCESS);
|
||||
while ((fen = next_fen(PERFT | MOVEDO))) {
|
||||
test_line = cur_line();
|
||||
@@ -271,46 +269,29 @@ int main(int __unused ac, __unused char**av)
|
||||
ms1_total += ms1;
|
||||
|
||||
if (sf_count == my_count) {
|
||||
printf("pt1 OK : line=%3d perft=%lu %'ldms lps=%'lu \"%s\"\n",
|
||||
printf("pt1 OK : line=%3d perft=%'lu %'ldms lps=%'lu \"%s\"\n",
|
||||
test_line, my_count, ms1,
|
||||
ms1? my_count*1000l/ms1: 0,
|
||||
fen);
|
||||
} else {
|
||||
printf("pt1 ERR: line=%3d sf=%lu me=%lu \"%s\"\n",
|
||||
printf("pt1 ERR: line=%3d sf=%'lu me=%'lu \"%s\"\n",
|
||||
test_line, sf_count, my_count, fen);
|
||||
}
|
||||
}
|
||||
|
||||
if (run & 2) {
|
||||
clock_start(&clock);
|
||||
my_count = perft2(pos, depth, 1);
|
||||
my_count = perft_new_pinners(pos, depth, 1);
|
||||
ms2 = clock_elapsed_ms(&clock);
|
||||
ms2_total += ms2;
|
||||
|
||||
if (sf_count == my_count) {
|
||||
printf("pt2 OK : line=%3d perft=%lu %'ldms lps=%'lu \"%s\"\n",
|
||||
printf("pt2 OK : line=%3d perft=%'lu %'ldms lps=%'lu \"%s\"\n",
|
||||
test_line, my_count, ms2,
|
||||
ms2? my_count*1000l/ms2: 0,
|
||||
fen);
|
||||
} else {
|
||||
printf("pt2 ERR: line=%3d sf=%lu me=%lu \"%s\"\n",
|
||||
test_line, sf_count, my_count, fen);
|
||||
}
|
||||
}
|
||||
|
||||
if (run & 4) {
|
||||
clock_start(&clock);
|
||||
my_count = perft_new_pinners(pos, depth, 1);
|
||||
ms3 = clock_elapsed_ms(&clock);
|
||||
ms3_total += ms3;
|
||||
|
||||
if (sf_count == my_count) {
|
||||
printf("pt3 OK : line=%3d perft=%lu %'ldms lps=%'lu \"%s\"\n",
|
||||
test_line, my_count, ms3,
|
||||
ms3? my_count*1000l/ms3: 0,
|
||||
fen);
|
||||
} else {
|
||||
printf("pt3 ERR: line=%3d sf=%lu me=%lu \"%s\"\n",
|
||||
printf("pt2 ERR: line=%3d sf=%'lu me=%'lu \"%s\"\n",
|
||||
test_line, sf_count, my_count, fen);
|
||||
}
|
||||
}
|
||||
@@ -323,7 +304,5 @@ int main(int __unused ac, __unused char**av)
|
||||
printf("total perft %'ldms\n", ms1_total);
|
||||
if (run & 2)
|
||||
printf("total perft2 %'ldms\n", ms2_total);
|
||||
if (run & 4)
|
||||
printf("total perft3 %'ldms\n", ms3_total);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user