Original Post
Basically, the AI of my game is made by an AI class and a possibility class. Each possibility has a map built-in, as well as an std::vector of possibilities. So, when my AI class calls the first possibility, it will build all the possibilities tree (default is 3 iterations). The problem is that, the first time I call the AI, it will work fine (I don't know if it's clever, but at least it wont crash). However, the second time I call the AI.GetBestMove(), the program will crash. Now, I believe that the problem is that the first time I call it, the entire tree of possibilities is created normally (I have an std::cout inside my possibility construction function). But the second time, the constructor isn't called, and when I try i < one_possibility.possibilities.size(), I crash. I supose that the AI class isn't being properly cleaned up, but that class is a local variable inside the function that is calling it, so that should delete the ai class at every frame. Plus, one_possibility is also a local variable inside c_ai.GetBestMovement(); - it should be deleted after every function call. There are no new or alloc()s inside these classes, only std::vectors, shouldn't they be automaticaly cleaned up? Anyone knows what's going on?? Thanks!