Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Binary question

Author: Ricardo Gibert

Date: 02:18:34 10/20/00

Go up one level in this thread


On October 19, 2000 at 17:09:39, Severi Salminen wrote:

>Hi!
>
>Now I have my bitboard move generator online generating pawn and knight moves!
>It works, great! One question:
>
>How do I find n in a binary number 2^n? So f(1000b)=3? Now I just shift right:
>
>c=0;
>while(B>>++c) ;
>c--;
>
>Any ideas?
>
>Severi

The minimal perfect hash function y = x%67 will map without collision between
the following 2 sets:

{x: x = 2^i, 0 <= i <= 65} -> {y: 1 <= y <= 66}

You would still need to do a table lookup to unscramble the mapping, but the
table is quite small.



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.