swig.
MModular
•Created by swig. on 4/11/2024 in #questions
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?
19 replies
MModular
•Created by swig. on 3/29/2024 in #questions
Tensor Open Source
Hi in the documentation tensors are listed under the standard library category but I can’t find it’s contents in the mojo GitHub repo. Is this not something that is going to be open sourced in the near future?
2 replies
MModular
•Created by swig. on 3/9/2024 in #questions
Defining A DynamicVector containing References
I am trying to create a vector that holds a list of object references so that I can manipulate the object's properties from the container but I don't understand how to define the "lifetime" of the Reference type. According to the Mojo docs, it requires three parameters (Reference[?, ?, ?]). I want the lifetime to last for the duration of the parent object's lifetime. Can I get some examples for proper lifetime values when specifying the Reference type parameters?
5 replies