I’m working on genetic algorithm project, which I need to finish today to afternoon. Everything is working, expect one thing: when all my cars which learn to be better on track finish their run (after 100 seconds), I make the genetic algorithm things, then save them to an backup array (with append), then kill all actors on the map, spawn new, and assign them variables from backup, so they get the genes. But it doesn’t matter if I copy the contents by using just “set” or “append”, after each destroyed actor, it also gets removed from the backup.
Arrays simply reference the actors using what’s called a pointer. They don’t actually hold them.
If you point to an ice-cream parlor, then it gets blown up a second later, you won’t be able to get any ice-cream from it anymore. It’s destroyed.
It doesn’t matter if you want ice-cream and still have a reference in your head, the actual parlor is destroyed.
Your options here are to either not destroy the actor or save all the data you want to a struct- placing that in the array instead.
right, I think that would be the problem. Need to finish it today, so I temporarily used another 4 more arrays to store those values, so they don’t get destroyed. But if I will have enough time, I will convert this to structs. Thanks!