Computer Chess Club Archives


Search

Terms

Messages

Subject: Search function

Author: Maurizio Di Vitto

Date: 06:22:59 02/21/04


Hi,
now I am writing a very simple search engine in according with your crbmg.cpp
code, I simply mean that I would like to improve a search function that work
with your basic engine, just to understand better how a search function should
work, but before I begin i need to understand something about your code. You use
the Perft function member to explore the tree but in the main function you
wrote:
for (int depth=1;depth<=max_depth;depth++)

so you execute the Perft(depth) max_depth time, so what would happen if you just
execute Perft(5), so does it explore correctly the tree to find a best move. So
after I tried many times, the main question is how could I modify the Perf to
find a move as result? I think the first think could be to declare that function
as int and not void, then I'll sobstitute ++movesfound with
score=-Perft(depth-1) then at the begin I cold write something like if(depth<1)
then return evaluation():

int Board::Perft(uint depth) {
	Board *pboard = &tree.boards[ply];
	int i=-1,movesfound=0;
	Move *pmove;
	uint nmoves;
        int score=0;
        int bestscore=-1000;

       if(depth<1)
       return evaluate();

	*pboard=*this;
	GenMoves();

	pmove = tree.first_move[ply];
	nmoves = tree.first_move[ply+1]-tree.first_move[ply];

	while (++i<nmoves) {
		if(!MakeMove(pmove+i))
			continue;
		score=-Perft(depth-1);
		*this=*pboard;
                if (score>bestscore)
                 {
                    bestscore=score;
                    //this is the best move
                 }
	}
	NodeCount[ply+1] += movesfound;

	return bestscore;
}
This code doesn't work, but why? Why do you use:
for (int depth=1;depth<=max_depth;depth++)?
Thanks for your time.
Maurizio Di Vitto



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.