Skip to content

Commit 186afde

Browse files
author
Oliver Brausch
committed
5.9.9 Half size bitboards. Simplify PV copy and Zugzwang condition.
1 parent 5de9408 commit 186afde

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed

src/Readme.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
OliThink5 (c) Oliver Brausch 06.Jun.2021, ob112@web.de, http://brausch.org
1+
OliThink5 (c) Oliver Brausch 11.Jun.2021, ob112@web.de, http://brausch.org
22

3-
Version: 5.9.8
3+
Version: 5.9.9
44
Protocol: CECP v2 (winboard/xboard)
55
HashSize: 128MB
66
Ponder: Yes
@@ -9,10 +9,13 @@ EndgameTables: No
99
AnalyzeMode: Basic
1010
SearchMethods: Nullmove, Internal Iterative Reduction, Check Extension, LMR
1111
Evaluation: Just mobility and a very simple pawnprogressing evaluation
12-
LinesOfCode: 1450
12+
LinesOfCode: 1448
1313
Stability: 100%
1414
Special thanks to Dann Corbit for his support and contribution.
1515

16+
v5.9.9: changes since 5.9.8:
17+
Half size bitboards. Simplify PV copy and Zugzwang condition.
18+
1619
v5.9.8: changes since 5.9.7:
1720
Max history heuristics.
1821

src/olithink.c

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* OliThink5 (c) Oliver Brausch 06.Jun.2021, ob112@web.de, http://brausch.org */
2-
#define VER "5.9.8"
1+
/* OliThink5 (c) Oliver Brausch 11.Jun.2021, ob112@web.de, http://brausch.org */
2+
#define VER "5.9.9"
33
#include <stdio.h>
44
#include <string.h>
55
#ifdef _WIN64
@@ -44,14 +44,14 @@ const int fval[] = {0, 0, 2, 0, 0, 3, 5, 9};
4444
#define _CAP(x) ((x) << 19)
4545
#define PREMOVE(f, p) ((f) | _ONMV(c) | _PIECE(p))
4646

47-
#define RATT1(f) rays[((f) << 7) | key000(BOARD, f)]
48-
#define RATT2(f) rays[((f) << 7) | key090(BOARD, f) | 0x2000]
49-
#define BATT3(f) rays[((f) << 7) | key045(BOARD, f) | 0x4000]
50-
#define BATT4(f) rays[((f) << 7) | key135(BOARD, f) | 0x6000]
51-
#define RXRAY1(f) rays[((f) << 7) | key000(BOARD, f) | 0x8000]
52-
#define RXRAY2(f) rays[((f) << 7) | key090(BOARD, f) | 0xA000]
53-
#define BXRAY3(f) rays[((f) << 7) | key045(BOARD, f) | 0xC000]
54-
#define BXRAY4(f) rays[((f) << 7) | key135(BOARD, f) | 0xE000]
47+
#define RATT1(f) rays[((f) << 6) | key000(BOARD, f)]
48+
#define RATT2(f) rays[((f) << 6) | key090(BOARD, f) | 0x1000]
49+
#define BATT3(f) rays[((f) << 6) | key045(BOARD, f) | 0x2000]
50+
#define BATT4(f) rays[((f) << 6) | key135(BOARD, f) | 0x3000]
51+
#define RXRAY1(f) rays[((f) << 6) | key000(BOARD, f) | 0x4000]
52+
#define RXRAY2(f) rays[((f) << 6) | key090(BOARD, f) | 0x5000]
53+
#define BXRAY3(f) rays[((f) << 6) | key045(BOARD, f) | 0x6000]
54+
#define BXRAY4(f) rays[((f) << 6) | key135(BOARD, f) | 0x7000]
5555

5656
#define RMOVE1(f) (RATT1(f) & ~BOARD)
5757
#define RMOVE2(f) (RATT2(f) & ~BOARD)
@@ -99,7 +99,7 @@ int wstack[0x400];
9999

100100
static u64 BIT[64];
101101
static u64 hashxor[4096];
102-
static u64 rays[0x10000];
102+
static u64 rays[0x8000];
103103
static u64 pmoves[128];
104104
static u64 pcaps[384];
105105
static u64 nmoves[64];
@@ -305,8 +305,8 @@ void _init_rays(u64* ray, u64 (*rayFunc) (int, u64, int), int (*key)(u64, int))
305305
u64 occ = (*rayFunc)(f, board, 2);
306306
u64 xray = (*rayFunc)(f, board, 3);
307307
int index = (*key)(board, f);
308-
ray[(f << 7) + index] = occ | move;
309-
ray[(f << 7) + index + 0x8000] = xray;
308+
ray[(f << 6) + index] = occ | move;
309+
ray[(f << 6) + index + 0x4000] = xray;
310310
}
311311
}
312312
}
@@ -396,18 +396,18 @@ int identPiece(int f) {
396396
}
397397

398398
int key000(u64 b, int f) {
399-
return (int) ((b >> (f & 56)) & 0x7E);
399+
return (int) ((b >> ((f & 56) + 1)) & 0x3F);
400400
}
401401

402402
int key090(u64 b, int f) {
403403
u64 _b = (b >> (f&7)) & 0x0101010101010101LL;
404404
_b = _b * 0x0080402010080400LL;
405-
return (int)(_b >> 57);
405+
return (int)(_b >> 58);
406406
}
407407

408408
int keyDiag(u64 _b) {
409409
_b = _b * 0x0202020202020202LL;
410-
return (int)(_b >> 57);
410+
return (int)(_b >> 58);
411411
}
412412

413413
u64 bmask135[64], bmask45[64];
@@ -854,7 +854,7 @@ int evalc(int c) {
854854
b = pieceb[QUEEN] & cb;
855855
while (b) {
856856
f = pullLsb(&b);
857-
a = BATT3(f) | BATT4(f) | RATT1(f) | RATT2(f);
857+
a = BATT(f) | RATT(f);
858858
if (a & kn) katt += MOBILITY(a & kn, mb) << 3;
859859
mn += MOBILITY(a, mb) * egf * egf / 75 / 75;
860860
}
@@ -926,8 +926,8 @@ int quiesce(u64 ch, int c, int ply, int alpha, int beta) {
926926
if (cmat + 85 <= alpha) break;
927927
best = eval(c);
928928
if (best > alpha) {
929-
alpha = best;
930929
if (best >= beta) return beta;
930+
alpha = best;
931931
}
932932
} while(0);
933933

@@ -1047,7 +1047,7 @@ int search(u64 ch, int c, int d, int ply, int alpha, int beta, int null, Move se
10471047
hstack[COUNT] = hp;
10481048
//Null Move - pvnode => null == 0
10491049
null = null && !ch && beta > -MAXSCORE+500 && d > 1 && wstat > alpha && (ply < 2 || (mstack[COUNT-2] >> 27));
1050-
if (null && bitcnt(colorb[c] & (~pieceb[PAWN]) & (~pinnedPieces(kingpos[c], oc))) > 1) {
1050+
if (null && (colorb[c] & (~pieceb[PAWN]) & (~pieceb[KING]))) {
10511051
int R = (10 + d + nullvariance(wstat - alpha))/4;
10521052
doMove(0, c);
10531053
w = -search(0LL, oc, d-R, ply+1, -beta, 1-beta, 0, 0);
@@ -1117,8 +1117,7 @@ int search(u64 ch, int c, int d, int ply, int alpha, int beta, int null, Move se
11171117
if (w > alpha) {
11181118
alpha = w, first = GOOD_MOVE;
11191119
pv[ply][ply] = m;
1120-
for (j = ply +1; pv[ply +1][j]; j++) pv[ply][j] = pv[ply +1][j];
1121-
pv[ply][j] = 0;
1120+
for (j = ply +1; (pv[ply][j] = pv[ply +1][j]); j++);
11221121

11231122
if (w >= beta) {
11241123
if (quiet) {
@@ -1412,9 +1411,9 @@ int main(int argc, char **argv) {
14121411
crevoke[56] ^= BIT[9];
14131412

14141413
_init_rays(rays, _rook0, key000);
1415-
_init_rays(rays + 0x2000, _rook90, key090);
1416-
_init_rays(rays + 0x4000, _bishop45, key045);
1417-
_init_rays(rays + 0x6000, _bishop135, key135);
1414+
_init_rays(rays + 0x1000, _rook90, key090);
1415+
_init_rays(rays + 0x2000, _bishop45, key045);
1416+
_init_rays(rays + 0x3000, _bishop135, key135);
14181417
_init_shorts(nmoves, _knight);
14191418
_init_shorts(kmoves, _king);
14201419
_init_pawns(pmoves, pcaps, pawnfree, pawnfile, pawnhelp, 0);

0 commit comments

Comments
 (0)