Small improvement

Discussion of chess software programming and technical issues.

Moderators: hgm, Dann Corbit, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
tomitank
Posts: 258
Joined: Sat Mar 04, 2017 11:24 am
Location: Hungary

Small improvement

Post by tomitank » Sat Mar 24, 2018 9:43 am

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: 1745
Joined: Tue Aug 30, 2016 6:19 pm
Full name: Rasmus Althoff
Contact:

Re: Small improvement

Post by Ras » Sat Mar 24, 2018 11:52 am

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: 258
Joined: Sat Mar 04, 2017 11:24 am
Location: Hungary

Re: Small improvement

Post by tomitank » Sat Mar 24, 2018 12:21 pm

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: Fri Jan 21, 2011 11:42 pm
Location: NL
Contact:

Re: Small improvement

Post by Evert » Sat Mar 24, 2018 12:33 pm

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: 258
Joined: Sat Mar 04, 2017 11:24 am
Location: Hungary

Re: Small improvement

Post by tomitank » Sat Mar 24, 2018 12:38 pm

I'm already using it. :)

Post Reply