Author: Bruce Moreland
Date: 18:15:43 09/19/99
Go up one level in this thread
On September 19, 1999 at 13:49:42, Nicolas Carrasco wrote: >int search(unsigned char depth) >{ > int best= -120000; > int score; > unsigned char i; > > move_data move_best; > > gen(); > for (i=0; i<move.number;i++) { > make_move(move.b[i]); > actual = -examine(depth-1); > unmake_move(); > gen(); > if (score>best) { > best = score; > move_best.to = move.b.to; > move_best.promote = move.b[i].promote; > move_best.bits = move.b[i].bits; > move_best.from = move.b[i].from; > } > } > make_move(move_best); > return best; >} You will want to get rid of "actual" and use "score" instead. "actual" doesn't do anything. You have two calls to "gen", the second seems redundant, unless you are doing an incremental scheme, which seems like overkill. The above is the top level search function, which is named strangely. It confused someone else. Most people would call the function that follows "search", and call the one that you've called "search" something else. This is just something to think about. You can make this all one function if you figure out a way to record the top-level best move properly. One last thing about this function. "char" and "short" datatypes are not good to use as general-purpose ints. You are using "char" in a couple of places. You should use "int" or "unsigned" as appropriate unless you can think of some reason not to, and saving three bytes of stack space or 3/4 of a register or whatever is not a good enough reason. >int examine(unsigned char depth) >{ > int score; > int best= -120000; > unsigned char i; > > if (depth==0) { > ++nodes; > return eval(); > } > gen(); > for(i=0;i<move.number;i++) { > make_move(move.b[i]); > actual = -examine(depth-1); > unmake_move(); > gen(); > if (score>best) > mejor = score; > } >return mejor; >} You can put the "++nodes" above the "if (depth==0)". An interior node is also a node. You have the same "actual" bug in here as well. You want to replace "mejor" with "best". You could turn this into an alpha-beta implementation in about five minutes if you knew which lines to modify. There aren't very many, it is suprisingly simple. bruce
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.