Author: Gerd Isenberg
Date: 22:03:09 07/29/03
Go up one level in this thread
On July 29, 2003 at 20:02:03, Russell Reagan wrote: >On July 29, 2003 at 16:34:36, Gerd Isenberg wrote: > >>Move is a class already, no virtuals, only inlined functions. > >Hi Gerd, > >Would you mind posting your move class declaration? I am always interested to >see how people implement "simple" classes like this, because sometimes it ends >up being not so simple :) Hi Russell, Don't like posting "real" source code... Ok, the "outdated" current one, simply a union with some bitfields and inlines. The next one becomes rather different. Cheers, Gerd struct SMove { union { UINT32 u; struct { unsigned from : 6; unsigned to : 6; unsigned kind : 5; unsigned check : 1; unsigned scored : 1; unsigned score : 13; }; }; __forceinline BOOL isMove() { return (u & 0x0fff) != 0;} __forceinline UINT getPiece() const { return scPieceByKind[kind];} __forceinline BOOL isReversable() const { return scIsReverableByKind[kind];} __forceinline BOOL isKingMove() const { return scIsKingMoveByKind[kind];} __forceinline BOOL equalCoordinates(SMOVE move) const { return ((move.u & 0x0fff) == (u & 0x0fff)); } __forceinline BOOL equalMoves(SMOVE move) const { return ((move.u & 0x03ffff) == (u & 0x03ffff)); } __forceinline BOOL unequalMoves(SMOVE move) const { return ((move.u & 0x03ffff) != (u & 0x03ffff)); } __forceinline BOOL equalMoves(UINT f, UINT t, UINT k, UINT c) { return from == f && to == t && kind == k && check == c; } __forceinline void operator=(int umove) {u = umove;} protected: static const UINT scPieceByKind[MK_NUMBER_OF_KINDS]; .... };
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.