Open respel opened 3 years ago
Hi,
With the hashtable I meant the transposition table. I can think of 2 possible improvements: 1) In Java the maximum length of an array is the maximum value of an integer, which is 2147483647. I use 2 long arrays for the transposition table which results in a maximum memory usage of 8 GB. Normally this is more than enough but under TCEC conditions (64 threads, long timecontrol) this is probably a bottleneck. It is hard to say how much but I guess 25 elo. 2) The transposition table consists of 2 long arrays, one containing the zobrist keys, the other the values (score, bestmove, depth, etc...). I think its much cleaner to store a struct of 128 bit containing all this data. I think there are also some minor performance improvements: no bit shifting necessary to create the value, no xorring necessary to validate that the key and value belong to each other and finally better cache usage because the key and value are adjacent to each other in memory.
Does this help? :)
@sandermvdb Thanks for the reply, it did help a lot.
You are already using only one array for the transpositions table, so that's a non-issue 😄
Regarding the struct itself, I have implemented it, however, it's clocking in at 136 bits instead of 128.
namespace Chess22kDotNet.Search
{
public struct TtEntry
{
private short _depth;
public long Key { get; set; }
public int Move { get; set; }
public short Score { get; set; }
public byte Flag { get; set; }
public short Depth
{
set => _depth = (short)(value + TtUtil.HalfMoveCounter);
get => (short)(_depth - TtUtil.HalfMoveCounter);
}
}
}
You are indeed correct that the transposition table is already one array, I changed that some time ago :)
Regarding the 136 bits, you could use 16 bits for the Move and then reconstruct the missing bits (6 I believe). Or combine _depth or Move with Flag, since Flag only needs 2 bits.
@sandermvdb Thanks for the tip. Merged move with flag.
Hey, it's me again. So, the C# port is live at https://github.com/respel/Chess22kDotNet. In one of our previous discussions, you mentioned some stuff that you would like to implement in the C# port. I'm quoting you here
I'm interested in implementing them. Can you expand a bit more on exactly what hash tables were you talking about here?
Another thing I was thinking about was to make a library out of the common code and then make the engine use that. However, I guess that would render the engine much weaker, so wasn't totally sure whether to go forward with it.