looking for feedback on the gameplay of my chess engine

Programming Topics (Computer Chess) and technical aspects as test techniques, book building, program tuning etc

Moderator: Andres Valverde

Re: thanks

Postby H.G.Muller » 28 May 2007, 20:04

OK, there definitely is something wrong with my random mover. I am now playing it against POS in random mode, and it seems to score 60%! From watching the games, I can see that it tends to move the same piece a number of times in a row. In KBK it moved the Bishop 50 times, without a single King move...

Apparently my random is not random at all. I used
(rand() & 0xFFFF)*NrOfMoves >> 16

Apparently this is not an uncorrelated random at all. I will now try
rand() % NrOfMoves
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Re: thanks

Postby H.G.Muller » 28 May 2007, 20:38

OK, I give up. I tried 20 different ways, but there is no way I can get a sequence of numbers out of rand() that look anything like random. Even if I interspace it with ~about a million other calls to rand().

So forget about my results with the random mover, I cannot make one.

Nevertheless, it seems strange that with me POS seemed to have so much difficulty in winning against a bare King. For no matter how non-random Ram 0.0 played, it almost always ended up against POS with a bare King, and POS with lots of material.

But it might be of course, that against truly random play, POS ends up wit, say, on the average 50% more material as it did in my case, and that this makes all the difference between mating within 50 moves with 95% probability or with only 50% probability.

Or it might be that the tendency to do consecutive moves with the same piece enhanced the 3-fold repetition probability.

Are you sure that POS claims adequately on 50-move and rep-draw?

Anyway, I would worry about the fact that PS moves predominantly its King, and towards the center. That is of more practical interest then how random you have to move to let POS win.
User avatar
H.G.Muller
 
Posts: 3453
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Re: thanks

Postby Uri Blass » 03 Jun 2007, 13:27

H.G.Muller wrote:OK, I give up. I tried 20 different ways, but there is no way I can get a sequence of numbers out of rand() that look anything like random. Even if I interspace it with ~about a million other calls to rand().

So forget about my results with the random mover, I cannot make one.

Nevertheless, it seems strange that with me POS seemed to have so much difficulty in winning against a bare King. For no matter how non-random Ram 0.0 played, it almost always ended up against POS with a bare King, and POS with lots of material.

But it might be of course, that against truly random play, POS ends up wit, say, on the average 50% more material as it did in my case, and that this makes all the difference between mating within 50 moves with 95% probability or with only 50% probability.

Or it might be that the tendency to do consecutive moves with the same piece enhanced the 3-fold repetition probability.

Are you sure that POS claims adequately on 50-move and rep-draw?

Anyway, I would worry about the fact that PS moves predominantly its King, and towards the center. That is of more practical interest then how random you have to move to let POS win.


Why do you use rand when there are known ways to generate random numbers?

See the following code:

Code: Select all
/*
   A C-program for MT19937, with initialization improved 2002/2/10.
   Coded by Takuji Nishimura and Makoto Matsumoto.
   This is a faster version by taking Shawn Cokus's optimization,
   Matthe Bellew's simplification, Isaku Wada's real version.

   Before using, initialize the state by using init_genrand(seed)
   or init_by_array(init_key, key_length).

   Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
   All rights reserved.

   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions
   are met:

   1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

   2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.

   3. The names of its contributors may not be used to endorse or promote
   products derived from this software without specific prior written
   permission.

   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


   Any feedback is very welcome.
   http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
   email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
 */
 
#include <string.h>
 
class MersenneTwister {
#define ARRAY_DIM 624
 private:
    unsigned long   state[ARRAY_DIM];
    int             left;
    int             initf;
    unsigned long  *next;

    void            next_state(void) {
        unsigned long  *p = state;
        int             j;
        if (initf == 0)
            init_genrand(5489UL);
        left = ARRAY_DIM;
        next = state;
        for (j = ARRAY_DIM - 397 + 1; --j; p++)
            *p = p[397] ^ (((((p[0]) & 0x80000000UL) | ((p[1]) & 0x7fffffffUL)) >> 1) ^ ((p[1]) & 1UL ? 0x9908b0dfUL : 0UL));
        for (j = 397; --j; p++)
            *p = p[397 - ARRAY_DIM] ^ (((((p[0]) & 0x80000000UL) | ((p[1]) & 0x7fffffffUL)) >> 1) ^ ((p[1]) & 1UL ? 0x9908b0dfUL : 0UL));
        *p = p[397 - ARRAY_DIM] ^ (((((p[0]) & 0x80000000UL) | ((state[0]) & 0x7fffffffUL)) >> 1) ^ ((state[0]) & 1UL ? 0x9908b0dfUL : 0UL));
    }

 public:
    MersenneTwister() {
         memset(state, 0, sizeof state);
        left = 1;
        initf = 0;
        next = 0;
        unsigned long   init[4] = {0x123, 0x234, 0x345, 0x456};
        init_by_array(init, 4);
    }
/* initializes state[N] with a seed */
    void            init_genrand(unsigned long s) {
        int             j;
        state[0] = s & 0xffffffffUL;
        for (j = 1; j < ARRAY_DIM; j++) {
            state[j] = (1812433253UL * (state[j - 1] ^ (state[j - 1] >> 30)) + j);
            state[j] &= 0xffffffffUL;
        }
        left = 1;
        initf = 1;
    }

/* initialize by an array with array-length */
/* init_key is the array for initializing keys */
/* key_length is its length */
/* slight change for C++, 2004/2/26 */
    void            init_by_array(unsigned long init_key[], int key_length) {
        int             i,
                        j,
                        k;
        init_genrand(19650218UL);
        i = 1;
        j = 0;
        k = (ARRAY_DIM > key_length ? ARRAY_DIM : key_length);
        for (; k; k--) {
            state[i] = (state[i] ^ ((state[i - 1] ^ (state[i - 1] >> 30)) * 1664525UL)) + init_key[j] + j;
            state[i] &= 0xffffffffUL;
            i++;
            j++;
            if (i >= ARRAY_DIM) {
                state[0] = state[ARRAY_DIM - 1];
                i = 1;
            }
            if (j >= key_length)
                j = 0;
        }
        for (k = ARRAY_DIM - 1; k; k--) {
            state[i] = (state[i] ^ ((state[i - 1] ^ (state[i - 1] >> 30)) * 1566083941UL)) - i;
            state[i] &= 0xffffffffUL;
            i++;
            if (i >= ARRAY_DIM) {
                state[0] = state[ARRAY_DIM - 1];
                i = 1;
            }
        }
        state[0] = 0x80000000UL;
        left = 1;
        initf = 1;
    }

/* generates a random number on [0,0xffffffff]-interval */
    unsigned long   genrand_int32(void) {
        unsigned long   y;
        if (--left == 0)
            next_state();
        y = *next++;
        y ^= (y >> 11);
        y ^= (y << 7) & 0x9d2c5680UL;
        y ^= (y << 15) & 0xefc60000UL;
        y ^= (y >> 18);
        return y;
    }

 

 
 };


extern class MersenneTwister MT;
User avatar
Uri Blass
 
Posts: 727
Joined: 09 Oct 2004, 05:59
Location: Tel-Aviv

Re: thanks

Postby Onno Garms » 07 Jun 2007, 15:38

The delfi engine claims to be a random mover when restricted to 600 elo. I have not testet that.
User avatar
Onno Garms
 
Posts: 128
Joined: 17 Feb 2007, 11:17
Location: Bonn, Germany

Previous

Return to Programming and Technical Discussions

Who is online

Users browsing this forum: No registered users and 38 guests

cron