Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Found another small bug in TSCP

Author: Michel Langeveld

Date: 13:38:13 01/15/04

Go up one level in this thread


On January 15, 2004 at 15:24:24, Michel Langeveld wrote:

>Just for sharing
>
>Fixing the bug saves a bit in quiet positions where history heuristic is more
>important. I take the original TSCP 1.81 search again to explain the bug. The
>bug is caused that the wrong number of plies is added to the history heurstic if
>we talk about a check.
>
>I will publish my heavily modified TSCP when it is totally done :-)
>
>/* search() does just that, in negamax fashion */
>
>int search(int alpha, int beta, int depth)
>{
>	int i, j, x;
>	BOOL c, f;
>
>	/* we're as deep as we want to be; call quiesce() to get
>	   a reasonable score and return it. */
>	if (!depth)
>		return quiesce(alpha,beta);
>	++nodes;
>
>	/* do some housekeeping every 1024 nodes */
>	if ((nodes & 1023) == 0)
>		checkup();
>
>	pv_length[ply] = ply;
>
>	/* if this isn't the root of the search tree (where we have
>	   to pick a move and can't simply return 0) then check to
>	   see if the position is a repeat. if so, we can assume that
>	   this line is a draw and return 0. */
>	if (ply && reps())
>		return 0;
>
>	/* are we too deep? */
>	if (ply >= MAX_PLY - 1)
>		return eval();
>	if (hply >= HIST_STACK - 1)
>		return eval();
>
>	/* are we in check? if so, we want to search deeper */
>	c = in_check(side);
>	if (c)
>		++depth;
>	gen();
>	if (follow_pv)  /* are we following the PV? */
>		sort_pv();
>	f = FALSE;
>
>	/* loop through the moves */
>	for (i = first_move[ply]; i < first_move[ply + 1]; ++i) {
>		sort(i);
>		if (!makemove(gen_dat[i].m.b))
>			continue;
>		f = TRUE;
>		x = -search(-beta, -alpha, depth - 1);
>		takeback();
>		if (x > alpha) {
>
>			/* this move caused a cutoff, so increase the history
>			   value so it gets ordered high next time we can
>			   search it */
>			//history[(int)gen_dat[i].m.b.from][(int)gen_dat[i].m.b.to] += depth;
>
>                        ************************************************
>                        //we have to subtract depth
>
>history[(int)gen_dat[i].m.b.from][(int)gen_dat[i].m.b.to] += (depth - c);
>                        ************************************************
>
>			if (x >= beta)
>				return beta;
>			alpha = x;
>
>			/* update the PV */
>			pv[ply][ply] = gen_dat[i].m;
>			for (j = ply + 1; j < pv_length[ply + 1]; ++j)
>				pv[ply][j] = pv[ply + 1][j];
>			pv_length[ply] = pv_length[ply + 1];
>		}
>	}
>
>	/* no legal moves? then we're in checkmate or stalemate */
>	if (!f) {
>		if (c)
>			return -10000 + ply;
>		else
>			return 0;
>	}
>
>	/* fifty move draw rule */
>	if (fifty >= 100)
>		return 0;
>	return alpha;
>}


I think also the check for draw is done too late:

if (fifty >= 100)
   return 0;

should be after declarations.... else a beta cutoff that leads to a draw is
calculated as a draw.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.