mailbox & CPW

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
hgm
Posts: 28451
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

mailbox & CPW

Post by hgm »

When googling something I happened to end up in the Chess-Programming Wiki, and I noticed it spreads a completely wrong definition of mailbox board representation.

In Chess programming a 'mailbox' board is a representation where the contents-description of every square resides in a separately addressable memory variable. Just as in a post-office mailbox every addressee has its own compartment with a separately openable door.

8x8 boards, 0x88, 10x12 boards are all mailbox. Whether there are unused elements in the array that can act as a guard band has nothing to do with it.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: mailbox & CPW

Post by sje »

That's true. What are the all the known ways of storing a board representation?

1. Mailbox
2. Bitboard
3. Piece vector
4. List
5. String (FEN or other)
Gerd Isenberg
Posts: 2251
Joined: Wed Mar 08, 2006 8:47 pm
Location: Hattingen, Germany

Re: mailbox & CPW

Post by Gerd Isenberg »

hgm wrote:When googling something I happened to end up in the Chess-Programming Wiki, and I noticed it spreads a completely wrong definition of mailbox board representation.

In Chess programming a 'mailbox' board is a representation where the contents-description of every square resides in a separately addressable memory variable. Just as in a post-office mailbox every addressee has its own compartment with a separately openable door.
Thank you for your critique. I am not an expert in board array representations, and what you call completely wrong definition comes from a comment in TSCP as cited in the article:

Code: Select all

/* Now we have the mailbox array, so called because it looks like a
   mailbox, at least according to Bob Hyatt.  ... */

int mailbox[120] = {
     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
     -1,  0,  1,  2,  3,  4,  5,  6,  7, -1,
     -1,  8,  9, 10, 11, 12, 13, 14, 15, -1,
     -1, 16, 17, 18, 19, 20, 21, 22, 23, -1,
     -1, 24, 25, 26, 27, 28, 29, 30, 31, -1,
     -1, 32, 33, 34, 35, 36, 37, 38, 39, -1,
     -1, 40, 41, 42, 43, 44, 45, 46, 47, -1,
     -1, 48, 49, 50, 51, 52, 53, 54, 55, -1,
     -1, 56, 57, 58, 59, 60, 61, 62, 63, -1,
     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
};
hgm wrote:8x8 boards, 0x88, 10x12 boards are all mailbox. Whether there are unused elements in the array that can act as a guard band has nothing to do with it.
Really? Is it your opinion or can you cite some other sources? I mean an 8x8 or 0x88 array containing {occupied by piece, empty, and invalid square} codes is therefor according to your definition not a mailbox approach due to the missing indirection.

Gerd
User avatar
hgm
Posts: 28451
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: mailbox & CPW

Post by hgm »

I don't understand that last question. What do you mean by 'missing indirection'? It seems to me if the array element encodes what is in there (piece / empty / invalid) it gives a pretty unambiguous representation of the board, and nothing is missing.

As to TSCP:

Note that just below the code you quoted, TSCP defines an 8x8 array without guard band called 'mailbox64'. So I am not sure why you forward this as evidence that the 10x12 representation would be any more mailbox than the 8x8.

The "at least according to Bob Hyatt" disclaimer in the accompanying comment strongly suggest that the author himself did not think at all it looked anything like a mailbox, but that he purely goes on Bob's authority by this. Apparently we are dealing here with a purely 'hearsay' source that is reflecting nothing else that Tom Kerrigan's interpretation of Bob's opinion.

We can ask Bob directly. In fact this was done here in this forum, but quite some time ago. So I am not sure if we will still be able to find it. But Bob is around every day.

Steven Edwards seems to agree with me...
Gerd Isenberg
Posts: 2251
Joined: Wed Mar 08, 2006 8:47 pm
Location: Hattingen, Germany

Re: mailbox & CPW

Post by Gerd Isenberg »

hgm wrote:I don't understand that last question. What do you mean by 'missing indirection'? It seems to me if the array element encodes what is in there (piece / empty / invalid) it gives a pretty unambiguous representation of the board, and nothing is missing.
But is a simple 8x8 array with (piece / empty / invalid) a mailbox? With indirection, I mean what you called
hgm wrote: the contents-description of every square resides in a separately addressable memory variable
that is keeping addresses or indices into another 0..63 board array or piecelist, instead of directly maintaining the empty square and piece codes inside the array.
hgm wrote:As to TSCP:

Note that just below the code you quoted, TSCP defines an 8x8 array without guard band called 'mailbox64'. So I am not sure why you forward this as evidence that the 10x12 representation would be any more mailbox than the 8x8.

The "at least according to Bob Hyatt" disclaimer in the accompanying comment strongly suggest that the author himself did not think at all it looked anything like a mailbox, but that he purely goes on Bob's authority by this. Apparently we are dealing here with a purely 'hearsay' source that is reflecting nothing else that Tom Kerrigan's interpretation of Bob's opinion.

We can ask Bob directly. In fact this was done here in this forum, but quite some time ago. So I am not sure if we will still be able to find it. But Bob is around every day.

Steven Edwards seems to agree with me...
I don't disagree, I don't know. What is the definition of a mailbox board array now? ;-)
User avatar
hgm
Posts: 28451
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: mailbox & CPW

Post by hgm »

Gerd Isenberg wrote:
hgm wrote: the contents-description of every square resides in a separately addressable memory variable
that is keeping addresses or indices into another 0..63 board array or piecelist, instead of directly maintaining the empty square and piece codes inside the array.
No, that is not what I meant at all. With 'contents description' I just meant a value that would unambiguously tell you what is on the square. Could be an encoding of the piece type, could be a piece number, could be a pointer. As long as it describes what is on the square, directly or indirectly.

I am not sure how we should describe the method used by Fruit, which uses two independently addressable variables per board square (one for the piece type, another for the piece number). I would be inclined to say it keeps two mailbox boards. (Especially so since they are organized as two separate arrays. If the two infos on a square would have been stored in consecutive memory, e.g. an array of structs, I would lean more to a single mailbox with big elements. After all, an int can also be seen as a struct containing 4 char.)
hgm wrote:I don't disagree, I don't know. What is the definition of a mailbox board array now? ;-)
The one I gave: the encoding of every square resides in a separately addressable memory element.

A post (from 2006) that also seems to support my view, even if it can hardly be called an authoritive source:

http://www.chesscircle.net/forums/showt ... ox&p=18171

Or here:

http://www.open-aurec.com/wbforum/viewt ... f=4&t=2514
Gerd Isenberg
Posts: 2251
Joined: Wed Mar 08, 2006 8:47 pm
Location: Hattingen, Germany

Re: mailbox & CPW

Post by Gerd Isenberg »

Ok, I understand. Thanks for the clarification.

Requires some re-structure and correction of several cpw pages, what I called "Square Centric" is all mailbox, so 8*8 Board, 0x88 and Vector Attacks (coined by Fabien Letouzey) need to be child pages of mailbox rather than siblings.