Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: [OT] pseudo-code for O(n log(n)) solution

Author: blass uri

Date: 05:07:02 06/26/00

Go up one level in this thread


On June 26, 2000 at 05:47:28, Simon Finn wrote:

>>static int compare(solution* a, solution* b)
>>{
>>    int i;
>>    for (i = 0; i < SOLUTION_SIZE; i++)
>>    {
>>        if (a[i] < b[i]) return -1;
>>        if (a[i] > b[i]) return 1;
>
>Sorry - that should be:
>         if ((*a)[i] < (*b)[i]) return -1;
>
>etc.
>
>>    }
>>    return 0;


This compare is slow because it can take SOLUTION_SIZE steps and it often takes
more than 1 step.

I am not interested in the question if solution a is bigger or smaller than
solution b but only in the question if it is different and in order to do it
usually quickly I need to find hash number for every solution.

xor could help me and xor of all the numbers (a[i]<<i) helped me even more but I
believe that using some random numbers for hash can help even more.

Thanks for posting this code but
I think that something similiar to hash tables in chess programs can help me and
not this code.

I need in every case that I get a new solution to check only if the new solution
is not the same as previous solutions

Uri



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.