Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Promotion frequency

Author: Bo Persson

Date: 01:45:23 07/23/02

Go up one level in this thread


On July 23, 2002 at 00:14:49, Russell Reagan wrote:

>I am attempting to use an object-oriented approach in developing my engine, and
>I have a problem and question about handling promotions.
>
>My problem is that my object-oriented design prevents me from handling promotion
>as efficiently as I'd like. I would like to handle it by storing the piece to
>promote to in my move structure, then to promote it's simply a copy of the piece
>type over the existing pawn type. Something like this:
>
>squares[move.to] = move.promotePiece;
>

Why don't you do it like

squares[move.to()] = move.promotedPiece();

That looks pretty OOP to me :-)

It won't cost you anything extra at run time, if all the functions are inlined.


If you want to be really fancy, you can even override operator[] for your
position structure, so you don't have to access the squares directly either.
Then you get

CurrentPosition[move.to()] = move.promotedPiece();

Someone here will surely call this overworked, but I think it is sort of OK if
you do it in just a few good places.


Bo Persson
bop2@telia.com



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.