#Static Member Array of Unknown Size?

4 messages · Page 1 of 1 (latest)

lost rain
#

Ok so a few things to get out of the way:

  • The class TranspositionTable should only have one object, thus the constructor is private.
  • The table itself should be a user-defined length if possible, default size is 1024 currently.
  • The table holds pointers to hash key objects.
    Is there a good way of doing this?
    My code:
//HEADER FILE
class ZobristKey {
public:
    uint64_t key;

    static uint64_t ZobristHashTable[66][2];
    static bool hashTableInitialized;

    bool compareKeys(ZobristKey& otherKey);
    void copyData(ZobristKey& otherKey);
    void updateHash(Move move);
    void initializeRandomHash();

    ZobristKey();
    ZobristKey(ZobristKey& otherKey, Move move);
};

//Only one object of type TranspositionTable should exist at one time
class TranspositionTable {
public:
    static ZobristKey* table[];

    bool posExists(ZobristKey* key);
    bool isFull();
    void clearTable();

private:
    TranspositionTable() = delete;
};
//MAIN FILE
#include "boardrep.h"
#include <iostream>

int main() {
    TranspositionTable::table[DEFAULT_HASH_SIZE];

    ZobristKey key;
    ZobristKey* keyPtr = &key;

    TranspositionTable::table[0] = keyPtr;

    return 0;
}
lapis currentBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

lost rain
#

Kind of fixed my problem, made the class nonstatic (as it'll be wrapped by a static class anyways)

#

!solved