#include <uct.h>
Public Member Functions | |
| Node (TWstep *, float heur=0) | |
| Constructor with step and heuristic. | |
| Node * | findUctChild (Node *realFather) |
| Finds child with highest UCB1 value. | |
| Node * | findRandomChild () const |
| Finds random child. | |
| Node * | findMostExploredChild () const |
| Finds child with most visits. | |
| float | exploreFormula (float) const |
| Core of UCT algorithm. | |
| void | cCacheInit () |
| Children Cache init. | |
| void | cCacheUpdate (float exploreCoeff) |
| Updating children Cache. | |
| void | uctOneChild (Node *act, Node *&best, float &bestUrgency, float exploreCoeff) const |
| DRY-purpose method. | |
| float | ucb (float exploreCoeff) const |
| The UCB1 formula. | |
| float | ucbTuned (float exploreCoeff) const |
| The UCB-tuned formula. | |
| void | addChild (Node *child) |
| Children addition during node expansion. | |
| void | reverseChildren () |
| Reverse order of children. | |
| void | delChildrenRec () |
| Deletes children recursively. | |
| void | connectToMaster (const bool lock=true) |
| Connect the node to its master (in parallel search). | |
| void | connectChildrenToMaster () |
| Atomic children connecting to their masters (in parallel search). | |
| void | syncMaster () |
| One node commit. | |
| void | recSyncMaster () |
| Recursive commit to master. | |
| void | updateTTbrothers (float sample=0, int size=0) |
| Value update of tt connected nodes. | |
| void | update (float) |
| Update after playout. | |
| void | updateTWstep (float) |
| Update after playout. | |
| bool | isMature () const |
| Maturity test. | |
| bool | hasChildren () const |
| Node * | getFather () const |
| void | setFather (Node *) |
| Node * | getFirstChild () const |
| void | setFirstChild (Node *) |
| Node * | getSibling () const |
| void | setSibling (Node *) |
| TTitem * | getTTitem () const |
| void | setTTitem (TTitem *node) |
| Step | getStep () const |
| TWstep * | getTWstep () const |
| player_t | getPlayer () const |
| int | getVisits () const |
| void | setVisits (int visits) |
| float | getValue () const |
| void | setValue (float value) |
| void | setMaster (Node *master) |
| Node * | getMaster () |
| void | lock () |
| void | unlock () |
| nodeType_e | getNodeType () const |
| int | getDepth () const |
| Gets ply in which node lies. | |
| int | getLocalDepth () const |
| Depth from last opponent's move. | |
| int | getLevel () const |
| Gets level (level ~ +- 4 plys). | |
| int | getDepthIdentifier () const |
| Combination of getLocalDepth and getLevel. | |
| string | toString () const |
| Representation. | |
| string | recToString (int) const |
| Recursively (children as well) to string. | |
Private Attributes | |
| float | value_ |
| Uct value of the node in [-1, 1]. | |
| float | heur_ |
| Heuristic value - purely position dependent. | |
| float | squareSum_ |
| For calculationg variance. | |
| int | visits_ |
| Number of simulations throught the node. | |
| TWstep * | twStep_ |
| Pointer to corresponding twStep (carrying the actual step to make). | |
| float | masterValue_ |
| Master value from last sync. | |
| int | masterVisits_ |
| Master visits from last sync. | |
| TTitem * | ttItem_ |
| Transposition tables item. | |
| Node * | sibling_ |
| Node * | firstChild_ |
| Node * | father_ |
| int | cCacheLastUpdate_ |
| Holds the number of visit when the ccache was last updated. | |
| Node ** | cCache_ |
| Node's ccache. | |
| Node * | master_ |
| Mirror of the node in the master tree. | |
| pthread_mutex_t | mutex |
| void Node::cCacheInit | ( | ) |
Children Cache init.
Cache array is created and filled with nulls.
| void Node::cCacheUpdate | ( | float | exploreCoeff | ) |
Updating children Cache.
Selects appropriate nodes and places them into cache.
| void Node::connectChildrenToMaster | ( | ) |
Atomic children connecting to their masters (in parallel search).
from the father). Sets the master_ pointer to the master node.
| void Node::connectToMaster | ( | const bool | lock = true |
) |
Connect the node to its master (in parallel search).
Finds the master node in the master tree (using information from the father). Sets the master_ pointer to the master node.
| lock | Use lock on the father tree. Lockless connection might be used from within the connectChildrenToMaster. |
| Node * Node::findRandomChild | ( | ) | const |
Finds random child.
Mostly for testing.
| bool Node::isMature | ( | ) | const |
Maturity test.
Checks whether number of descends through node passed some constant threshold (around number of legal steps from average position). Being mature is prerequisite for expansion.
| void Node::recSyncMaster | ( | ) |
Recursive commit to master.
Commits itself and the whole subtree.
| void Node::syncMaster | ( | ) |
One node commit.
Commits it's statistics to master.
| void Node::update | ( | float | sample | ) |
Update after playout.
Updates value/visits.
| void Node::updateTTbrothers | ( | float | sample = 0, |
|
| int | size = 0 | |||
| ) |
Value update of tt connected nodes.
Performed after node update.
| void Node::updateTWstep | ( | float | sample | ) |
Update after playout.
Updates value/visits of twStep.
Node** Node::cCache_ [private] |
Node's ccache.
Actual allocation is performed when ccache is first used.
int Node::cCacheLastUpdate_ [private] |
Holds the number of visit when the ccache was last updated.
float Node::heur_ [private] |
Heuristic value - purely position dependent.
Node* Node::master_ [private] |
Mirror of the node in the master tree.
float Node::masterValue_ [private] |
Master value from last sync.
int Node::masterVisits_ [private] |
Master visits from last sync.
float Node::squareSum_ [private] |
For calculationg variance.
TTitem* Node::ttItem_ [private] |
Transposition tables item.
TWstep* Node::twStep_ [private] |
Pointer to corresponding twStep (carrying the actual step to make).
float Node::value_ [private] |
Uct value of the node in [-1, 1].
int Node::visits_ [private] |
Number of simulations throught the node.
1.5.7.1