src/players/UCTPlayer.js
/** `evaluatedMoves(game, player)` return a sequence with the evaluated moves.
	*/
`evaluatedMoves(game, player)` return a sequence with the evaluated moves.
` evaluatedMoves ( game player ) ` return a sequence with the evaluated moves .
function evaluatedMoves(game, player) {
		var root = new GameTree({ state: game }),
			startTime = Date.now(),
			node, simulationResult;
		root.uct = { visits: 0, wins: 0, rewards: 0 };
		for (var i = 0;  !this.__finishMoveEvaluation__(i, startTime, root); i++) {
			node = root;
			while (node.__children__ && node.__children__.length > 0) { 
				node = this.selectNode(node, i+1, this.explorationConstant);
			}
			if (!node.state) {
				node.expand();
			}
			simulationResult = this.simulation(node.state, player); 
			for (; node; node = node.parent) { 
				node.uct.visits++;
				if (simulationResult.result > 0) {
					node.uct.wins++;
				}
				node.uct.rewards += game.normalizedResult(simulationResult.result);
			}
		}
		var result = iterable(root.children()).map(function (n) {
				if (!n.uct) console.log(n);
				var visits = n.uct.visits;
				return n.uct ?
					[n.transition, n.uct.rewards / (visits + 1e-10), visits] :
					[n.transition, 0, 0]; 
			}).toArray();
		//console.log(result);
		return result;
	}
function evaluatedMoves ( game , player ) { var root = new GameTree ( { state : game } ) , startTime = Date . now ( ) , node , simulationResult ; root . uct = { visits : 0 , wins : 0 , rewards : 0 } ; for ( var i = 0 ; ! this . __finishMoveEvaluation__ ( i , startTime , root ) ; i ++ ) { node = root ; while ( node . __children__ && node . __children__ . length > 0 ) { node = this . selectNode ( node , i + 1 , this . explorationConstant ) ; } if ( ! node . state ) { node . expand ( ) ; } simulationResult = this . simulation ( node . state , player ) ; for ( ; node ; node = node . parent ) { node . uct . visits ++ ; if ( simulationResult . result > 0 ) { node . uct . wins ++ ; } node . uct . rewards += game . normalizedResult ( simulationResult . result ) ; } } var result = iterable ( root . children ( ) ) . map ( function ( n ) { if ( ! n . uct ) console . log ( n ) ; var visits = n . uct . visits ; return n . uct ? [ n . transition , n . uct . rewards / ( visits + 1e-10 ) , visits ] : [ n . transition , 0 , 0 ] ; } ) . toArray ( ) ; return result ; }
`evaluatedMoves(game, player)` return a sequence with the evaluated moves.
` evaluatedMoves ( game player ) ` return a sequence with the evaluated moves .
// Selection // Simulation // Backpropagation //FIXME //console.log(result);//FIXME