Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Three questions

Author: Gerd Isenberg

Date: 04:36:08 11/09/02

Go up one level in this thread


On November 09, 2002 at 07:15:18, Sune Fischer wrote:

>On November 09, 2002 at 06:03:13, Gerd Isenberg wrote:
>>Hi Sune,
>>
>>you declared a function pointer but no pointer to member functions.
>>Pointer to member function need an pointer to an object and they act like an
>>offset. There are explicitely two new atomic operators in C++, ".*" and "->*",
>>to call member fuctions via pointer.
>>
>>class BOARD {
>>public:
>>  void (BOARD::*pGenCastleMoves)();
>>  void GenNormalCastleMoves();
>>  void GenFischerCastleMoves();
>>...
>>}
>
>Thanks, so I gather:)
>
>>I use arrays of function pointers a lot in this way:
>>
>>	typedef	void (CSearchTree::*PTR_DOMOVE)(CNode &node);
>>	static PTR_DOMOVE m_scDoMove[SMOVE::MK_NUMBER_OF_KINDS];
>>	__forceinline void DoMove(const CNode &fromnode, CNode &tonode)	{
>>          ....
>>          (this->*m_scDoMove[tonode.m_Move2ThisNode.kind])(tonode);}
>>
>>For your purpose i would prefere an abstract base class with two concrete
>>derivates, where you must overload the pure virtual GenCastleMoves routine:
>>
>>class BOARDBASE {
>>public:
>>  virtual void GenCastleMoves() = 0;
>>...
>>}
>
>Well, the trick is to support different games without losing performance in the
>primary game (chess!). I think only fischer-random requires special castling
>rules, even shuffle chess can use ordinary rules just by removing castle rights.
>So I think don't I will really be needing more than two such castle functions:)
>
>-S.

Yes, but calling virtual functions has about the same overhead, than calling a
member function via pointer.
For design reasons i would prefere seperate board or game objects rather than
the possibility of switching the rules during search, even if the intention is
it to do it only once for initalization.

Gerd



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.