Computer Chess Club Archives


Search

Terms

Messages

Subject: Hey I did this alone!

Author: Nicolas Carrasco

Date: 10:49:42 09/19/99


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();
		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.01 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.