src/games/TicTacToe.js
/** `heuristicFromWeights(weights)` builds an heuristic evaluation function from weights for
		each square in the board. The result of the function is the weighted sum, empty squares 
		being ignored, opponent squares considered negative.
		*/
`heuristicFromWeights(weights)` builds an heuristic evaluation function from weights for
each square in the board. The result of the function is the weighted sum, empty squares
being ignored, opponent squares considered negative.
` heuristicFromWeights ( weights ) ` builds an heuristic evaluation function from weights for each square in the board . The result of the function is the weighted sum empty squares being ignored opponent squares considered negative .
function heuristicFromWeights(weights) {
			var weightSum = iterable(weights).map(Math.abs).sum();
			function __heuristic__(game, player) {
				var playerChar = player.charAt(0);
				return iterable(game.board).map(function (square, i) {
					return (square === '_' ? 0 : weights[i] * (square === playerChar ? 1 : -1));
				}).sum() / weightSum;
			}
			__heuristic__.weights = weights;
			return __heuristic__;
		}
function heuristicFromWeights ( weights ) { var weightSum = iterable ( weights ) . map ( Math . abs ) . sum ( ) ; function __heuristic__ ( game , player ) { var playerChar = player . charAt ( 0 ) ; return iterable ( game . board ) . map ( function ( square , i ) { return ( square === '_' ? 0 : weights [ i ] * ( square === playerChar ? 1 : - 1 ) ) ; } ) . sum ( ) / weightSum ; } __heuristic__ . weights = weights ; return __heuristic__ ; }
`heuristicFromWeights(weights)` builds an heuristic evaluation function from weights for
each square in the board.
` heuristicFromWeights ( weights ) ` builds an heuristic evaluation function from weights for each square in the board .