Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Hey I did this alone!

Author: Bas Hamstra

Date: 16:21:49 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?

Well, you tell me! :) I have a few comments:

- Why the examine? The search() is enough, examine() is almost a copy
- You don't want to do gen() in a loop unless you gen() 1 move at a time, which
it doesn't look like in your code.
- Score should be actual (or vice versa)
- For the rest it looks ok

Have fun!

Bas Hamstra.







>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();
>		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 (score>best)
>			mejor = score;
>		}
>return mejor;
>}
>
>/////////////////////////////////////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.