Reputation: 8678
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?
Upvotes: 1
Views: 282
Reputation: 525
You should use :INITFORM instead of :initial-element to get different hashtables
(My answer is wrong, see Vatine's)
Upvotes: 0
Reputation: 21238
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.
Upvotes: 4