Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: What kind of sort to use?

Author: Dan Newman

Date: 17:38:16 07/31/00

Go up one level in this thread


On July 31, 2000 at 13:17:20, Larry Griffiths wrote:

>I am currently using a bubble sort to sort my captures list.
>
>I plan to change it to a selection sort.
>
>Do any of you use another type of sort like quicksort to sort your lists or do
>you have any preferences?
>
>Larry :)

The capture list is almost always very short (0-6 items) so doing this with
a bubble sort isn't bad at all.  Crafty used a bubble sort for this until
recently.  (Bob switched over to straight insertion after a long debate
here on the best way to sort captures.  But, according to Bob, the straight
insertion is no faster.)  I haven't tried selection on the captures though,
and I guess it could be faster.  But I suspect it would only make a very
small (nearly unmeasureable) difference in node rate...

Here's what straight insertion (which I got from Numerical Recipes) looks
like:


    for( j = 1; j < N; j++ ) {
        temp = arr[j];
        i = j-1;
        while( i >= 0 && arr[i] < temp ) {
            arr[i+1] = arr[i];
            i--;
        }
        arr[i+1] = temp;
    }

You can look in Crafty's quiesce.c for what it looks like in a chess
program with both move and score vectors.

-Dan.



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.