Hi all,
The following line gives me a "Debug Assertion Failed!" error with "Expression: Vector subscript out of range". This means that I must be using my vector incorrectly. However I cannot use breakpoints and step through my code to find out the problem due to the way the project has been set, but I have managed to narrow it down to a certain method and a couple of lines.
The second line of the method is the line that's throwing the error.
I cant find out why, I've tried initializing the children vector before passing "GetChildren()" but it still doesn't like it.
The method GetChildren() returns a "vector<Node*>" so that is also not the problem.
Any Ideas ?
The following line gives me a "Debug Assertion Failed!" error with "Expression: Vector subscript out of range". This means that I must be using my vector incorrectly. However I cannot use breakpoints and step through my code to find out the problem due to the way the project has been set, but I have managed to narrow it down to a certain method and a couple of lines.
int Minimax::SearchMethod(Node* node, int depth)
{
node->GenerateChildren();
vector<Node*> children = node->GetChildren();
if(depth == 0 || !node->HasChildren())
{
return node->GetBoard()->getBoardValue();
}
int value = 0;
if(node->IsPlayerOneTurn())
{
value = -100000;
for (int i = 0; i < children.size(); i++)
{
value = max(value, SearchMethod(children[i], depth - 1));
}
}
else
{
value = 100000;
for (int i = 0; i < children.size(); i++)
{
value = min(value, SearchMethod(children[i], depth - 1));
}
}
return value;
}
The second line of the method is the line that's throwing the error.
I cant find out why, I've tried initializing the children vector before passing "GetChildren()" but it still doesn't like it.
The method GetChildren() returns a "vector<Node*>" so that is also not the problem.
Any Ideas ?