Author: Michel Langeveld
Date: 00:28:24 09/19/99
Go up one level in this thread
On September 19, 1999 at 01:02:28, Daniel Karlsson wrote:
>On September 18, 1999 at 14:59:53, Nicolas Carrasco wrote:
>
>>I would be extreamly pleased to be helped on implementing a simple MIN-MAX
>>searching function to my program.
>>
>>///////////////////////////DATA/////////////////////////////
>>#define BOOL char
>>
>>struct move_list {
>> move_data b[250];
>> unsigned char number;
>>};
>>
>>struct move_data {
>> unsigned char from;
>> unsigned char to;
>> unsigned char promote;
>> unsigned char bits;
>>};
>>
>>move_list move; // GEN post moves here EXAMPLE: move.b[xxx].to
>>
>>BOOL make_move(move_data)
>>void unmake_move(void);
>>int eval (void) // ONLY MATERIAL
>>
>>///////////////////////////END OF DATA/////////////////////////////
>>
>>PLEASE POST A SEARCH FUNCTION HERE!!!!!!!!!!!!!!!!
>
>int NegaMax(int alpha, int beta, int depth)
>{
> int i, n_moves;
> struct move_data movelist[MAX_MOVES];
>
> if (depth == 0)
> return eval();
>
> n_moves = generate_moves(movelist); // returns number of moves generated
> sort_moves(movelist, n_moves);
>
> for (i = 0; i < n_moves; i++)
> if (make_move(movelist[i])) {
> val = -NegaMax(-beta, -alpha, depth - 1);
> undo_move();
> if (val > alpha) {
> alpha = val;
> if (val >= beta)
> return beta;
> }
> }
>
> return alpha;
>}
>
>You will likely need some kind of iterative deepening root search function and
>some other stuff too. Read some of the pages in the Resource Center.
>
>Note: this is not a very efficient piece of code. Can't guarantee it works
>either :-)
I think:
if (val > alpha) {
if (val >= beta)
return beta;
alpha = val;
}
will give a slightly better performance!
cheers,
Michel Langeveld
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.