I am trying to store attack moves for chess pieces in a 64 square bitboard. Basically I am using any array of hash-tables to do this:
(defvar attacks (make-array '(64) :initial-element (make-hash-table))
However, I have noticed that when I fill up each hashtable in the array (with about 1000 elements each) it intersects with another hashtable. That is one hashtable has values from another hashtable, even though I didn’t put it there.
Am I imagining things? Is this a bug?
You create a single hash table (with make-hash-table) that you then set in all elements of an array. To do what you want, you’d want to do one of:
That way, the hash tables would be separate instead of the same hash table stored 64 times.