public GameAction GenerateAction(GameState gameState) { Func <double[], TicTacToeValue> predictFunction = input => new TicTacToeValue(model.Predict(input).Select(i => (double)i).ToArray()); var predictions = TicTacToeActionPrediction.Predict(gameState, TicTacToeLabeledStateLoader.InputTransforms.Bipolar, predictFunction); return(TicTacToeValueEvaluator.BestFor(gameState.CurrentPlayer, predictions.ToList())); }
public GameAction GenerateAction(GameState gameState) { var predictions = TicTacToeActionPrediction.Predict(gameState, TicTacToeLabeledStateLoader.InputTransforms.Bipolar, Predict).ToList(); int index; if (gameState.CurrentPlayer.IsCross) { index = predictions.IndexOfMin(p => p.Value[0]); } else { index = predictions.IndexOfMax(p => p.Value[0]); } return(predictions[index].Key); }