Small improvement

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

tomitank
Posts: 276
Joined: Sat Mar 04, 2017 12:24 pm
Location: Hungary

Small improvement

Post by tomitank »

Hi all!

Very small improvement:
don't try verify the "checks" after null move pruning (first ply).
It is unnecessary, because the opponent had to leave the check.

-Tamás
Ras
Posts: 2488
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Small improvement

Post by Ras »

Not sure whether I understand correctly... but when one side leaves check, this can generate check for the other side, isn't that an issue?
tomitank
Posts: 276
Joined: Sat Mar 04, 2017 12:24 pm
Location: Hungary

Re: Small improvement

Post by tomitank »

After null move, the check verify is unnecessary.

Code: Select all

			if (nullOK)
			{
				TakeNullMove(); // eg: replace side

				Score = -AlphaBeta(-beta, -beta+1, depth-4, false, true);

				// This call: AlphaBeta -> next node for opponent
				// No need to verify again the check at next node

				TakeBackNull(); // eg: replace side

				if (Score >= beta) {
					return Score;
				}
			}

Code: Select all

	function AlphaBeta(alpha, beta, depth, nullMove, afterNullMove) {
		......
		if (afterNullMove == false) { // Unnecessary after null move (at first node)
			inCheck = isCheck();
		}
		......
	}
If you predefine the outcome of a move, the code is even simpler.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Small improvement

Post by Evert »

You can do even better if you test for alignment of the origin (Queen-alignment) and destination (Superpiece or Amazon alignment). If neither matches, the move cannot be a checking move.
tomitank
Posts: 276
Joined: Sat Mar 04, 2017 12:24 pm
Location: Hungary

Re: Small improvement

Post by tomitank »

I'm already using it. :)