Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Minimum Number of Bytes - encode castling within kings coordinates

Author: KarinsDad

Date: 22:36:46 12/23/03

Go up one level in this thread


On December 23, 2003 at 23:58:19, Reinhard Scharnagl wrote:

>Hi KarinsDad,
>
>you are describing just the big translation table, I have spoken of.
>
>I will try to explain the nature of a solution I would like to have
>(which is still not complete and in devlopment).
>
>Suppose the castling rigths are the following bits: bwl, bwr, bbl, bbr.
>
>a) if both kings are at original place,
>   encode Kw = kb = (bwl, bwr, 0, bbl, bbr, 0)
>b) if only the white king is at original place,
>   1) O-O only -> place him immediately over or under the black king
>   2) O-O-O only -> place him immediately right or left to the black king
>   3) both castlings -> ... still no idea, sorry
>c) if only the black king is at original place,
>   1) O-O only -> place him immediately NW or SE the white king
>   2) O-O-O only -> place him immediately NE or SW to the white king
>   3) both castlings -> ... still no idea, sorry

This could easily work. It is similar to the idea I just mentioned (placing king
position and castling information into 12 bits), it is just a different encoding
schema.

One solution to this:

b) if only the white king is at original place
1) O-O only -> place him immediately above the black king.
2) O-O-O only -> place him immediately below the black king.
3) both castlings -> place him immediately to the right of the black king.

This leaves 21 cases (8 for O-O where bk is on rank 8, 8 for both where bk is on
file 8, and 5 for O-O-O where bk is on rank 1, but not at the illegal d1, e1, or
f1) not handled (when the direction is off the board).

When the white king is on his original location, the black king will not be on
d1(3), d2(4), e1(3), e2(4), f1(3), or f2(4), so placing the black king there
will result in 21 of the 21 cases that can be handled.

Note: Instead, you could get 7 of the 8 "off the board" O-O cases by placing the
white king to the left of the black king. Ditto for 7 of the 8 O-O-O cases.
Ditto for 6 of the 8 of the both castlings (the h1/h8 corners are spoken for in
the O-O and O-O-O cases just mentioned). However, this still leaves 4 cases that
you still have to find bit representations for (such as the bit representations
around the e1 square).

c) if only the black king is at original place
1) O-O only -> place him immediately NE of the white king.
2) O-O-O only -> place him immediately NW of the white king.
3) both castlings -> place him immediately SE of the white king.

This leaves 39 cases (3 * 15 - 6 around black king) not handled (when the
direction is off the board).

All 39 of these cases can be handled by the 48 remaining states of your unused
(bwl, bwr, 0, bbl, bbr, 0). In other words, (0/1, 0/1, 0, 0/1, 0/1, 1), (0/1,
0/1, 1, 0/1, 0/1, 0), or (0/1, 0/1, 1, 0/1, 0/1, 1) for both pieces.

I'll leave it to you to figure out a clean way to encode the 21 leftover cases
in b) (either the first way I mentioned, or the second way in the note: section,
or even a third way) and the 39 leftover cases in c). Or, to figure out a
completely different way to do this.


>That this moment is the direction I am thinking of a solution.
>
>Regards, Reinhard.
>
>P.S.: my main goal in creating a compact encoding is not to reach the
>      ultimative shortest one, but to become able to make a good estimation
>      on the number of all legal possible chess positions.

However, even the most compact encoding will not get you anywhere near count of
all legal chess positions. If I had to make a guess, that number would be
somewhere around 2^150 or 1.4e45 (or so), but I could easily be off by several
magnitudes or more.

There are just so MANY positions that will fit into any encoding schema which
are not legal. There are a boatload of illegal king (both side to not move and
side to move) positions and illegal pawn positions. For example:

RNBQKBNR
PPPPPPPP
.......p
.......p
.......p
.......p
......pp
......pp
rnbqkbnr

Dropping illegal positions out of encoding schemas is extremely difficult. At
least it is for me (I've tried about 4 ways to do that, all of which have failed
to decrease the total number of bits to represent all legal positions).



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.