[Exceptional C++ Style] Item 26 -- Data Formats and Efficiency

Adrian Fagg adrianf at evaluategroup.com
Mon Jan 31 10:41:32 EST 2005


> -----Original Message-----
> From: effective-cpp-bounces at accu.org
> [mailto:effective-cpp-bounces at accu.org]On Behalf Of Ric Parkin

> For example, by retricting it to legal chess games, a large
> number of impossible positions and moves can be ignored,
> which means you have a much smaller set to consider.

Yes, when you think about it, all you need is to find a consistent numbering
system for each set of moves and both ends can work out how many bits are
needed. Also, you can decide on a numbering system for the pieces that can
move, thus reducing the bits needed to identify the piece. Take an extreme
(and slightly impossible) example, it's black's move and there's only the
knight left to move and only one square to move into that isn't threatened -
total number of bits needed = 0 for the piece and 0 for the move = o.;-)
Why bother with separate bits for piece and move? there is only a finite
number of possible moves at any one point in the game, so just number them
all and use that number.
But then, there is only a finite number of games possible (provided that you
can recognise all possible stalemates), so assign each a number and just
send that number.;-)

Regards,

Adrian

Work: mailto:adrianf at evaluategroup.com
Home: mailto:adrian.fagg at ntlworld.com

Pretty pictures: http://homepage.ntlworld.com/rbyadf/




More information about the Effective-cpp mailing list