Author: Alessandro Damiani
Date: 11:07:30 09/19/99
Go up one level in this thread
On September 19, 1999 at 13:49:42, Nicolas Carrasco wrote:
>I think these two functions will simulate MIN-MAX (I know I don“t detect ilegal
>moves). I implemented this algorim myself. I also know I can reduce the use of
>gen() funtion.
>
>Is it working ok?
>
>I use:
>///////////////////////////////////////////////////////SOURCE///////
>void main(void)
>{
>search(3);
>print_board();
>}
>
>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();
why here another gen()? your move list is already there.
> 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;
>}
>
>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 gen() generate your moves then this here is not needed.
> if (score>best)
> mejor = score;
> }
>return mejor;
I think, you wanted to write:
if (actual>best) {
best= actual;
}
but then your variable "score" should be "actual". I think the compiler does not
translate "mejor" into "best". :-)
Alessandro
>}
>
>/////////////////////////////////////STRUCTURES:
>struct move_data {
> unsigned char from;
> unsigned char to;
> unsigned char promote;
> unsigned char bits;
>};
>struct move_list {
> move_data b[250];
> unsigned char number;
>};
>
>move_list move;
>
>///////////////PROTOTYPES OF FUNCTIONS MENTIONED//////////////////////
>int eval(void);
>void print_board(void);
>BOOL make_move (move_data this_move);
>void unmake_move (void);
>void gen(void);
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.