Computer Chess Club Archives


Search

Terms

Messages

Subject: PV History question

Author: Nicolas Carrasco

Date: 16:52:29 10/14/99


Dear Guys,

I have been working in order to make a search results description as for example
to see like:

I moved e2-e4 because of: 1.e2-e4 1..e7-e6 2.g1-f3 2..b8-c6 ..............

But I have tried how to put "PV[0].b[ply]= move[ply].b[i];" on the correct place
but falied.

Note: "0" is a constant. I made an array of PV[50] for Iterative deepening.

I use the search functions like this:

void main(void)
{
Search(5,-11000,11000); // And this function uses AlphaBeta function and makes
}                       //the best move

Thanks,

Nicolás Carrasco


////////Search functions//////////
int AlphaBeta (int depth, int alpha, int beta)
{
	int i;
	int value;
	int moves_done = nodes;

	if (depth == 0)
		return eval();
	++ply;
    gen();
    for (i=0; i<move[ply].number;i++) {
        if (make_move(move[ply].b[i])) {
			++nodes;
			value = -AlphaBeta(depth - 1, -beta, -alpha);
			unmake_move();
			if (value > alpha) {
				if (value >= beta) {
						--ply;
						return beta;
				}
				alpha = value;
			}
		}
    }

	if(moves_done == nodes) {
		if(in_check(side)) {
			--ply;
			return(-11000+ply);
		}
		else {
			--ply;
			return(0);
		}
	}

	if(fifty>=100) {
		--ply;
		return(0);
	}

	--ply;
    return alpha;
}

int Search (int depth, int alpha, int beta)
{
	int i;
	int value;
	int move_to_make;
	int moves_done = nodes;

	ply = 0;
    gen();
    for (i=0; i<move[ply].number;i++) {
		if (make_move(move[ply].b[i])) {
			++nodes;
			value = -AlphaBeta(depth - 1, -beta, -alpha);
			unmake_move();
			if (value > alpha) {
				if (value >= beta) {
						make_move(move[ply].b[i]);
						return beta;
				}
				move_to_make = i;
				alpha = value;
			}
		}
    }

	if(moves_done == nodes) {
		if(in_check(side))
			return(beta);
		else
			return(0);
	}

	if(fifty>=100)
		return(0);

	make_move(move[ply].b[move_to_make]);
	return alpha;
}



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.