Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Promotion frequency

Author: Sune Fischer

Date: 12:31:12 07/23/02

Go up one level in this thread


On July 23, 2002 at 13:59:00, Russell Reagan wrote:

>On July 23, 2002 at 06:28:43, Bo Persson wrote:
>
>>Well, in my case promotedPiece() doesn't return an int but a Piece object (which
>>encapsulates an int (or an enum; varies over time)). I don't really have your
>>Square type, but an array of Pieces in the Board structure. The question is if
>>the piece placement is a property of each square, or if it is a property of the
>>board. Or even of the piece. Who knows?
>>
>>My Board (position) class has an array of Pieces to map from Square (enum {a1,
>>a2,...) to content. It has a set of bitmaps for the reverse mapping, from piece
>>to square.
>>
>>It also has the usual set of flags for its non-positional states: castling, en
>>passant, and side to move.
>
>To me it would make more sense to have a Square object, even if it only contains
>a Piece object as private data. So I have an efficiency question about that.
>Assuming everything is properly inlined, would there be any speed hit for doing
>something like:
>
>// squares is an array of Square (the board), and you can access
>// the piece it contains via the piece() method.
>if (squares[i].piece().color() == BLACK)

from a layman: doesn't look to me like that can be inlined, the compiler needs
to know in advance what function to call to do that, but here color() depends on
piece() which it won't know until runtime.

>instead of:
>
>if (board[i].color() == BLACK)
>
>To me there is a potential confusion here. If you do board[i].color(), to me
>that says that you are asking what color the square is, not what color the piece
>is (like h1 is a light colored square).

BTW, you can do sq&1 to check the color of the square.

-S.

>So if Square is just a wrapper for a
>Piece to make things more organized and more "correct" (I guess that's the
>word), will it inline right on through the Square AND the Piece's inlined
>methods? Or is this one of those "it should, but the only way to tell is to
>check the ASM"?
>
>Thanks,
>Russell



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.