In the asteroids tutorial it makes use of cPickle to store data and it looks like it effectively attaches data to a node. The idea of attaching data to a node seems pretty good to me, you could attach qualities, velocity, hit points, etc.
I’m building a program that uses physics to move animals through a fluid. The animals have fins attached to them that move back an forth and it propels the animals through the fluid. So I have many “fin” nodes attached to different animals. I’m still building things and troubleshooting so I have one fin per animal. The fins are placed on random places on the animals and so they rotate certain ways if they are on one side as opposed to on the other side of the animal. I want to store this fin specific information and attach it to the fin itself. So I used cPickle following the example from the asteroids tutorial. The problem is that I get this wierd “end of file” error when I run it. So I scaled it back instead of producing many animals, I set the generator loop to 1 animal and it worked fine, the fin moved fine and the animal moved fine. I set the generator loop to 2 animals and it crashes. So I changed the processing loop so that it would only process animal #1. That worked fine too.
Here’s the weird and wacky part: I manually told it to process the 2nd animal instead of using a loop just like I did for animal #1. I got the same EOF error then I commented out the line to process the second animal and re-ran the program only to have it crash again. From that point on it just crashed. So I loaded a different .py script, closed it, then reopened the original animal .py an it worked fine with the line commented out. I repeated this process several times to make sure it wasn’t a fluke.
I have no idea what’s happening. If anyone can help I’d appreciate it, or if you know of another way to attach data to a node.