Author: Gerd Isenberg
Date: 05:47:55 11/09/02
Go up one level in this thread
On November 09, 2002 at 08:21:21, Sune Fischer wrote: >On November 09, 2002 at 07:36:08, Gerd Isenberg wrote: > >>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 > >Oh I see, I thought the other way around, that given the games are so much >alike, they should have as much in common as possible, in the spirit of OOP. >I really didn't intend to write a whole new program, only to make full use of >what is already there. > >Actually I also like to have the option to change pointers during the game, eg. >if castling is impossible, set the pointer to NULL and never bother to check for >castling flags during search :) > >So I guess I disagree ;) > >-S. OK, that's fine, for pragmatic reasons... I don't want to be a wisenheimer :-) Cheers, 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.