Segmentation Error Occurring With Set Implementation
Hi there, I'm having a very difficult time implementing a custom datatype into the builtin set object. For somebackground I am making a an AI model from scratch to play snake and am trying to create a training environment for n number of snakes in a generation. Each update of a generation moves the snake one pixel. I have designed the snake's move operation to add a xy coordinate to a set and remove the oldest xy coordinate from the set (this is determined by a deque implementation which is unrelated). Each portion of the snakes body is stored in a
Position object which contains the x and y position and a simd vector containing the underlying data. The data structure is Hashable but when adding a position object, sometimes this works correctly but in some very small instances I get a segmentation error. Here is the code for the Position data structure I made. Let me know if there is a way to hash a tuple object or any other simpler way to hash xy positions?