Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
 public IObservable<object> Evaluate(IContext context, object[] arguments)
 {
     return Commands
         .Select(command => context.Evaluate(command.Evaluate(context, arguments)))
         .Concat()
         ;
 }