Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: 0x88 findings

Author: Roman Hartmann

Date: 03:23:53 02/22/06

Go up one level in this thread


On February 21, 2006 at 20:16:33, Sean Mintz wrote:

Hi,
>I have been working on the basic underpinnings of an 0x88 program.  By today it
>had gotten to the point where it was working well enough that I could tinker and
>make some comparisons.
>
>The initial version's move generator is, in terms of its code, very long.
>
>1. Generate castling moves
>2. Generate en passant moves
>3. Big switch statement, seperated by each type of piece. Pawn is seperated
>further into white and black and each of those is split into normal or promotion
>moves.

My move generator looks about the same but I need two different routines for the
black and white pieces because of the 10x12 sheme I'm using.

>The attack function in this program ( used to determine whether the king is in
>check ) is very similar to the move generator. It sort of generates the moves
>backwards to determine whether the square is being attacked.

I just x-ray from the position of the king and see if I hit any other colored
pieces. Simply put, I put a white bishop on the square of the white king and see
if I can take a black bishop or a black queen. If so, the king is in check. The
same I do with the queen/rook/knights.

But I only call the attack function if the square where a piece is going to move
and the square of the king is connected. For that I create a direction table at
startup. The table has 2 dimensions and tells you the distance between two
squares. direction[A1][A8] will give you the value 7 while direction[A1][B8]
will have value 0. With a direction table you can avoid a lot of attack calls.

>The code for this version is fairly lengthy, but runs quite fast.
>
>Today I tried rewriting the move generator and the attack function to be shorter
>and to take advantage of some of the talked about "tricks" of 0x88 (
>specifically in the attack function ).
>
>The move generator now looks like this:
>
>1. Generate castling moves
>2. Generate en passant moves
>3. Smaller switch statement. Do pawn moves, but then do all other moves together
>( has an array to determine whether a piece is a slider or not, and a
>multidimensional array that says which directions a piece can go )
>
>The attack function is similar to that of Gerbil, but I do pawns seperately ( as
>opposed to having another multidimensional array to handle the pawns ).
>
>On to the tests:
>
>First I perft to a depth of 6.  This takes reasonably long.
>
>After that I do 3 repetitive tests.
>
>First I generate all 20 moves for the initial position 2.5 million times.
>Then I make and unmake each of those 20 moves 2.5 million times.
>Then I run the attack function on the white AND black king 2.5 million times (
>so the attack function runs 5 million times ).
>
>On to the results:
>
>Version One
>
>Calculating Perft to depth 6 ... 119060324
>Took 19.44 seconds
>Performing Move Generator Test ... Took 0.922000 seconds
>Performing Move Make Test ... Took 2.243000 seconds
>Performing Attack Test ... Took 0.320000 seconds
>
>Version Two
>
>Calculating Perft to depth 6 ... 119060324
>Took 24.48 seconds
>Performing Move Generator Test ... Took 1.932000 seconds
>Performing Move Make Test ... Took 2.214000 seconds
>Performing Attack Test ... Took 0.410000 seconds
>
>I was personally surprised to see the second version running so much slower.

>Sean Mintz



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.