Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Node* Selection()
- {
- Node* temp = root;
- selectedCount = 0;
- while (true)
- {
- selectedNodes[selectedCount++] = temp;
- int status = temp->status;
- if (status < 2)
- return temp;
- int childIndex = temp->childIndex;
- if (childIndex == 0)
- return temp;
- Node* children = nodes + childIndex;
- if (temp->childMax == 1)
- {
- temp = children;
- continue;
- }
- float visits = temp->visits;
- float sqrtLogVisits = EXPLORATION * fastlogf(fastsqrtf(visits));
- int bestIndex = -1;
- float bestScore = MINUS_INFINITY;
- for (int i = 0; i < temp->childMax; i++)
- {
- Node& child = children[i];
- if (child.status != 2)
- continue;
- float score = child.UCT(sqrtLogVisits);
- if (score > bestScore)
- {
- bestIndex = i;
- bestScore = score;
- }
- }
- temp = children + bestIndex;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement