public Simulate Think(int depth, int alpha, int beta, IContext context) { //UnityEngine.Debug.LogError(depth + " [alpha = " + alpha + "][beta = " + beta + "]"); if (depth == DEPTH || context.End()) { return new Simulate(context.Evaluate(), null); } else { object bestMove = null; while (context.HaveChoices()) { object move = null; IContext newContext = context.NextChoice(ref move); Simulate value = Think(depth + 1, -beta, -alpha, newContext); if (-value.mEvaluate > alpha) { alpha = -value.mEvaluate; bestMove = move; } } return new Simulate(alpha, bestMove); } }
public IObservable<object> Evaluate(IContext context, object[] arguments) { var results = Expressions .Select(e => context.Evaluate(e.Evaluate(context, arguments)).Wait()) // TODO: Wait() is blocking! .ToArray() ; try { ICallable callable = context.Bot.Command.CallParsed(context.ConversionContext, results); return context.Evaluate(callable); } catch(Exception e) { return Observable.Throw<String>(e); } }
public IObservable<object> Evaluate(IContext context, object[] arguments) { return Commands .Select(command => context.Evaluate(command.Evaluate(context, arguments))) .Concat() ; }