I wrote it a couple of years ago when I was just starting to program so it isn't in top shape , I Know that premature optimization isn't a good thing and that the speed gain from optimizing this won't affect the engine's elo much if at all , but the problem I'm facing is that when I wrapped my code inside a "position" class those parts slowed down considerably "~10%:20%", C++ isn't my "native" language and I understand that abstraction comes with a cost -"but not a huge one"- but I believe that the cause is something I'm doing wrong here , the reset of the functions don't suffer from the same performance degradation , even the move generator is the same speed .
looks *very* suspicious, since TypeBoard is an array of bitboards ...
Do you swear that there will "never ever" be an array bounds overflow?
Edit: ok, I see that I misinterpreted the meaning of "BB", in fact it seems to be a piece type, not a bitboard, despite the name ... But nevertheless, I get the feeling that the whole "TypeBoard" stuff is unintuitive (array index "64 + ply"?). And I would not be surprised if your actual problem were related to some unintuitive code.
They always told me that object oriented programming is not for free. Calling a virtual method is like dereferencing a pointer to a function. So if you want to code more efficiently use C instead of C++. No nonsense with virtual tables.
Henk wrote:They always told me that object oriented programming is not for free. Calling a virtual method is like dereferencing a pointer to a function. So if you want to code more efficiently use C instead of C++. No nonsense with virtual tables.
This doesn't make any sense. Why is the cost of calling virtual functions an argument for using a different language? If you don't want to pay the cost of calling virtual functions, don't use virtual functions.
Henk wrote:They always told me that object oriented programming is not for free. Calling a virtual method is like dereferencing a pointer to a function. So if you want to code more efficiently use C instead of C++. No nonsense with virtual tables.
Henk, please ... how can we prevent you from writing nonsense in a serious thread where someone is looking for help?
Henk wrote:They always told me that object oriented programming is not for free. Calling a virtual method is like dereferencing a pointer to a function. So if you want to code more efficiently use C instead of C++. No nonsense with virtual tables.
This doesn't make any sense. Why is the cost of calling virtual functions an argument for using a different language? If you don't want to pay the cost of calling virtual functions, don't use virtual functions.
Then it is more object based programming. Yes that's possible too.
I don't know if it isn't always using virtual tables whether there are virtual methods defined or not. I would be surprised if inheritance is for free.
Henk wrote:I don't know if it isn't always using virtual tables whether there are virtual methods defined or not. Don't even know how inheritance is implemented. I think you need at least an extra pointer from an object to it's parent.
It's OK to be ignorant about something. But then you shouldn't go around giving advice about it.
No, C++ doesn't use vtables if there aren't virtual methods. Inheritance is implemented in several different ways, which you can look up on the web. You generally don't need a pointer to the parent, unless you are using virtual inheritance.
Personal opinion: If you want to live a happy life, don't use virtual inheritance, multiple inheritance or non-public inheritance. Use simple, non-virtual, public inheritance, and only to get polymorphic behavior, and only when inheritance expresses an "IS-A" relationship.
By the way, I have never used virtual functions or inheritance in a chess engine.
looks *very* suspicious, since TypeBoard is an array of bitboards ...
Do you swear that there will "never ever" be an array bounds overflow?
Edit: ok, I see that I misinterpreted the meaning of "BB", in fact it seems to be a piece type, not a bitboard, despite the name ... But nevertheless, I get the feeling that the whole "TypeBoard" stuff is unintuitive (array index "64 + ply"?). And I would not be surprised if your actual problem were related to some unintuitive code.
U64 GameRecord[512];
U64 SBackup[MaxDepth][16];
U64 CRBackup[MaxDepth][2];
//use the Game record instead
U64 PositionKeyBackUp[MaxDepth];
U64 HalfMoveClockBackUp[MaxDepth];
U64 BitBoards[16];
U64 HalfMoveClock = 0ULL;
U64 GameRecordCounter = 0ULL;
U64 Positionkey = 0ULL;
U64 CastleRights[2];
unsigned int LastMoveDPushSQBackup[MaxDepth];
Score PSQTScoreBackUp[MaxDepth];
unsigned int DoublePushSQ[2] = { 0U,0U };
Score PSQTScore;
int ply = 0;
BB TypeBoard[64 + MaxDepth];
Color STM = White;
Henk wrote:10-20% is nothing. You are just wasting your time. (Like I do all day)
they are something , and as I've already pointed in the post this is not my main concern.
Henk wrote:They always told me that object oriented programming is not for free. Calling a virtual method is like dereferencing a pointer to a function. So if you want to code more efficiently use C instead of C++. No nonsense with virtual tables.
to achieve the same functionality they provide you'll have to pay a similar price regardless of the language you are using.