当前位置: 首页>>代码示例>>C#>>正文


C# Evaluator类代码示例

本文整理汇总了C#中Evaluator的典型用法代码示例。如果您正苦于以下问题:C# Evaluator类的具体用法?C# Evaluator怎么用?C# Evaluator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Evaluator类属于命名空间,在下文中一共展示了Evaluator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SolverController

        /// <summary>
        /// Strong Contruction
        /// </summary>
        /// <param name="map">Map to solve</param>
        public SolverController(SokobanMap map)
        {
            if (map == null) throw new ArgumentNullException("map");
            this.settings = new Settings();

            this.state = States.NotStarted;
            this.map = map;
            debugReport = new SolverReport();

            debugReport.AppendHeading(1, "SokoSolve | Solver Debug Report v{0}", ProgramVersion.VersionString);

            debugReport.Append("Creating Statistics");
            stats = new SolverStats(this);
            debugReport.Append("Creating Exit Conditions");
            exitConditions = new ItteratorExitConditions();

            // TODO: This should be configured, perhaps via a factory pattern
            debugReport.Append("Creating Forward Strategy");
            strategy = new SolverStrategy(this);
            debugReport.Append("Creating Forward Evaluator");
            evaluator = new Evaluator<SolverNode>(true);

            debugReport.Append("Creating Reverse Strategy");
            reverseStrategy = new ReverseStrategy(this);
            debugReport.Append("Creating Reverse Evaluator");
            reverseEvaluator = new Evaluator<SolverNode>(true);
        }
开发者ID:rfrfrf,项目名称:SokoSolve-Sokoban,代码行数:31,代码来源:SolverController.cs

示例2: Main

        static void Main(string[] args)
        {
            string command = "";
            do
            {
                Console.Write(Prompt);
                command = Console.ReadLine();
                if (string.IsNullOrWhiteSpace(command))
                {
                    continue;
                }
                command = command.Trim();
                if (command.StartsWith("/"))
                {
                    if (processSpecialCommand(command)) break;
                    continue;
                }
                try
                {
                    sb.Append(command).Append("\n");

                    string text = sb.ToString();
                    _evaluator = new Evaluator(text);
                    Console.Write("->\n" + _evaluator.Interpret() + "\n");
                }
                catch (Exception e)
                {
                    Console.Write("!> " + e.Message + "\n");
                    sb.Clear();
                }

            } while (command != ExitCommand);
        }
开发者ID:soltys,项目名称:W8MC,代码行数:33,代码来源:Program.cs

示例3: OnFirstRun

        /// <summary>Called when [first run].</summary>
        ///
        /// <exception cref="InvalidDataException">Thrown when an Invalid Data error condition occurs.</exception>
        protected override void OnFirstRun()
        {
            if (varName != null)
                return;

            var declaration = Condition.TrimEnd().TrimEnd(';');

            var parts = declaration.Split('=');
            if (parts.Length != 2)
                throw new InvalidDataException(
                    "Invalid var declaration, should be '@var varName = {MemberExpression} [, {VarDeclaration}]' was: " + declaration);

            varName = parts[0].Trim();
            memberExpr = parts[1].Trim();

            this.Condition = memberExpr;

            const string methodName = "resolveVarType";
            var exprParams = GetExprParams();
            var evaluator = new Evaluator(ReturnType, Condition, methodName, exprParams);
            var result = evaluator.Evaluate(methodName, GetParamValues(ScopeArgs).ToArray());
            ScopeArgs[varName] = result;
            if (result != null)
                this.ReturnType = result.GetType();

            base.OnFirstRun();
        }
开发者ID:Qasemt,项目名称:NServiceKit,代码行数:30,代码来源:VarStatementExprBlock.cs

示例4: MiniMaxNode

 public MiniMaxNode(GameState g, Evaluator e, int player, MiniMaxNode parent)
 {
     this.State = g;
     this.e = e;
     this.player = player;
     this.Parent = parent;
 }
开发者ID:SvenPetroll,项目名称:TronBot,代码行数:7,代码来源:MiniMaxNode.cs

示例5: Call

        /// <summary>
        /// Call let* evaluator.
        /// </summary>
        /// <param name="expr">The expression to evaluate.</param>
        /// <param name="env">The environment to make the expression in.</param>
        /// <param name="caller">The caller.  Return to this when done.</param>
        /// <returns>The let evaluator.</returns>
        internal static Evaluator Call(SchemeObject expr, Environment env, Evaluator caller)
        {
            if (expr is EmptyList)
            {
                ErrorHandlers.SemanticError("No arguments arguments for let*", null);
            }

            if (!(expr is Pair))
            {
                ErrorHandlers.SemanticError("Bad arg list for let*: " + expr, null);
            }

            SchemeObject bindings = First(expr);
            SchemeObject body = Rest(expr);

            if (body is EmptyList)
            {
                caller.ReturnedExpr = Undefined.Instance;
                return caller;
            }

            SchemeObject vars = MapFun(First, bindings);
            SchemeObject inits = MapFun(Second, bindings);
            SchemeObject formals = EmptyList.Instance;
            SchemeObject vals = EmptyList.Instance;
            return new EvaluateLetStar(expr, env, caller, body, vars, inits, formals, vals);
        }
开发者ID:cchayden,项目名称:SimpleScheme,代码行数:34,代码来源:EvaluateLetStar.cs

示例6: Eval

		internal override Result Eval(Evaluator evaluater, Result[] argArray) {
			if ((bool)argArray[0].Value) {
				return argArray[1];
			} else {
				return argArray[2];
			}
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:7,代码来源:ConditionalOp.cs

示例7: Minify

 public override Token Minify(Evaluator evaluator)
 {
     Arguments = Arguments.Select(arg => arg.Minify(evaluator)).ToArray();
     if (!Arguments.All(arg => arg is ConstantToken))
         return this;
     return new ConstantToken(Evaluate(evaluator));
 }
开发者ID:Gilnaa,项目名称:SilverSurfer,代码行数:7,代码来源:FunctionToken.cs

示例8: Call

        /// <summary>
        /// Create a list evaluator.
        /// </summary>
        /// <param name="expr">The expression to evaluate.</param>
        /// <param name="env">The environment to make the expression in.</param>
        /// <param name="caller">The caller.  Return to this when done.</param>
        /// <returns>A list evaluator.</returns>
        internal static Evaluator Call(SchemeObject expr, Environment env, Evaluator caller)
        {
            // first check for degenerate cases
            if (expr is EmptyList)
            {
                caller.ReturnedExpr = EmptyList.Instance;
                return caller;
            }

            if (!(expr is Pair))
            {
                ErrorHandlers.SemanticError("Bad args for list: " + expr, null);
            }

            if (AllEvaluated(expr))
            {
                // Skip creating an evaluator or a list if all elements are constants.
                caller.ReturnedExpr = expr;
                return caller;
            }

            if (AllSimple(expr))
            {
                // Skip creating an evaluator if all elements are constants or symbols.
                caller.ReturnedExpr = EvaluateSymbolsInList(expr, env);
                return caller;
            }

            // Something actually needs to be evaluated.
            return new EvaluateList(expr, env, caller);
        }
开发者ID:cchayden,项目名称:SimpleScheme,代码行数:38,代码来源:EvaluateList.cs

示例9: Call

        /// <summary>
        /// Call letrec evaluator.
        /// </summary>
        /// <param name="expr">The expression to evaluate.</param>
        /// <param name="env">The environment to make the expression in.</param>
        /// <param name="caller">The caller.  Return to this when done.</param>
        /// <returns>The let evaluator.</returns>
        internal static Evaluator Call(SchemeObject expr, Environment env, Evaluator caller)
        {
            if (expr is EmptyList)
            {
                ErrorHandlers.SemanticError("No arguments for letrec", null);
            }

            if (!(expr is Pair))
            {
                ErrorHandlers.SemanticError("Bad arg list for letrec: " + expr, null);
            }

            SchemeObject body = Rest(expr);
            if (body is EmptyList)
            {
                caller.ReturnedExpr = Undefined.Instance;
                return caller;
            }

            SchemeObject bindings = First(expr);
            //// In the bindings, the variables are first, the values are second, and anything left over is discarded.
            //// If either is missing, an empty list is used instead.
            //// To start with, bindings are undefined.
            SchemeObject formals = MapFun(First, bindings);
            SchemeObject inits = MapFun(Second, bindings);
            SchemeObject initVals = Fill(ListLength(formals), Undefined.Instance);

            return new EvaluateLetRec(expr, new Environment(formals, initVals, env), caller, body, formals, inits);
        }
开发者ID:cchayden,项目名称:SimpleScheme,代码行数:36,代码来源:EvaluateLetRec.cs

示例10: Form1

		public Form1() 
		{
			mInitializing = true;
			ev = new Evaluator(Eval3.eParserSyntax.cSharp,false);
			ev.AddEnvironmentFunctions(this);
			ev.AddEnvironmentFunctions(new EvalFunctions());
			// This call is required by the Windows Form Designer.


			A = new Eval3.EvalVariable(0.0, typeof(double));
			B = new Eval3.EvalVariable(0.0, typeof(double));
			C = new Eval3.EvalVariable(0.0, typeof(double));

			// This call is required by the Windows Form Designer.
			InitializeComponent();

			A.Value = (double)updownA.Value;
			B.Value = (double)updownB.Value;
			C.Value = (double)updownC.Value;

			// Add any initialization after the InitializeComponent() call
			mInitializing = false;
			btnEvaluate_Click(null, null);
			btnEvaluate2_Click(null, null);
			btnEvaluate3_Click(null, null);
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:26,代码来源:Form1.cs

示例11: Execute

        public ScriptResult Execute(string code, string[] scriptArgs, AssemblyReferences references, IEnumerable<string> namespaces,
            ScriptPackSession scriptPackSession)
        {
            Guard.AgainstNullArgument("references", references);
            Guard.AgainstNullArgument("scriptPackSession", scriptPackSession);

            references.PathReferences.UnionWith(scriptPackSession.References);

            SessionState<Evaluator> sessionState;
            if (!scriptPackSession.State.ContainsKey(SessionKey))
            {
                Logger.Debug("Creating session");
                var context = new CompilerContext(new CompilerSettings
                {
                    AssemblyReferences = references.PathReferences.ToList()
                }, new ConsoleReportPrinter());

                var evaluator = new Evaluator(context);
                var allNamespaces = namespaces.Union(scriptPackSession.Namespaces).Distinct();

                var host = _scriptHostFactory.CreateScriptHost(new ScriptPackManager(scriptPackSession.Contexts), scriptArgs);
                MonoHost.SetHost((ScriptHost)host);

                evaluator.ReferenceAssembly(typeof(MonoHost).Assembly);
                evaluator.InteractiveBaseClass = typeof(MonoHost);

                sessionState = new SessionState<Evaluator>
                {
                    References = new AssemblyReferences(references.PathReferences, references.Assemblies),
                    Namespaces = new HashSet<string>(),
                    Session = evaluator
                };

                ImportNamespaces(allNamespaces, sessionState);

                scriptPackSession.State[SessionKey] = sessionState;
            }
            else
            {
                Logger.Debug("Reusing existing session");
                sessionState = (SessionState<Evaluator>)scriptPackSession.State[SessionKey];

                var newReferences = sessionState.References == null ? references : references.Except(sessionState.References);
                foreach (var reference in newReferences.PathReferences)
                {
                    Logger.DebugFormat("Adding reference to {0}", reference);
                    sessionState.Session.LoadAssembly(reference);
                }

                sessionState.References = new AssemblyReferences(references.PathReferences, references.Assemblies);

                var newNamespaces = sessionState.Namespaces == null ? namespaces : namespaces.Except(sessionState.Namespaces);
                ImportNamespaces(newNamespaces, sessionState);
            }

            Logger.Debug("Starting execution");
            var result = Execute(code, sessionState.Session);
            Logger.Debug("Finished execution");
            return result;
        }
开发者ID:selony,项目名称:scriptcs,代码行数:60,代码来源:MonoScriptEngine.cs

示例12: FloodFill

        public void FloodFill()
        {
            Bitmap map = new Bitmap(new string[]
                                        {
                                            "111111111111111111",
                                            "100000000000001001",
                                            "100000000000001001",
                                            "100001111111001001",
                                            "100001010001001001",
                                            "100001000101001001",
                                            "100001111111000001",
                                            "111011000000001111",
                                            "100000001000010001",
                                            "100000001000010001",
                                            "111111111111111111"
                                        });

            Debug.WriteLine(map.ToString());

            Evaluator<LocationNode> eval = new Evaluator<LocationNode>();
            FloodFillStrategy strategy = new FloodFillStrategy(map, new VectorInt(2, 2));
            eval.Evaluate(strategy);

            Debug.WriteLine(strategy.Result.ToString());

            List<LocationNode> path = strategy.GetShortestPath(new VectorInt(9, 9));
            Assert.IsNotNull(path);

            Debug.WriteLine(StringHelper.Join(path, delegate(LocationNode node) { return node.Location.ToString(); }, ", "));

            Debug.WriteLine(map.ToString());

            // Expected value
            Assert.AreEqual(new VectorInt(9, 9), path[path.Count - 1].Location);
        }
开发者ID:rfrfrf,项目名称:SokoSolve-Sokoban,代码行数:35,代码来源:BitmapTest.cs

示例13: Operator

        private int prec = System.Int32.MaxValue; // the precedence this operator has

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Creates an Operator
        /// </summary>
        /// <param name="_operator">string operator symbol</param>
        /// <param name="arguments">number of arguments</param>
        /// <param name="precedence">precedence relative to other operators</param>
        /// <param name="eval">delegate to use for evaluating operator</param>
        public Operator(String _operator, int arguments, int precedence, Evaluator eval)
        {
            this.op = _operator;
            this.args = arguments;
            this.prec = precedence;
            this.evaluator = eval;
        }
开发者ID:TienLg,项目名称:BetS,代码行数:20,代码来源:Operator.cs

示例14: TestBools

        public void TestBools()
        {
            Evaluator e = new Evaluator();

            Assert.IsTrue(e.Evaluate("true") ? true : false);
            Assert.IsFalse(e.Evaluate("false") ? true : false);

            Assert.IsFalse(e.Evaluate("!true") ? true : false);
            Assert.IsTrue(e.Evaluate("!false") ? true : false);

            if (e.Evaluate("!!!true")) {
                Assert.Fail();
            }

            if (!e.Evaluate("10")) {
                Assert.Fail();
            }

            Assert.IsTrue(e.Evaluate("1 != 2").As<bool>());
            Assert.IsTrue(e.Evaluate("(true || false)").As<bool>());

            Assert.IsFalse(e.Evaluate("(true && false) || (false)").As<bool>());

            Assert.IsFalse(e.Evaluate("(true && false) && (false)").As<bool>());
            Assert.IsFalse(e.Evaluate("(true && !false) && (false)").As<bool>());
        }
开发者ID:svermeulen,项目名称:iris,代码行数:26,代码来源:TestExpressionEvaluator.cs

示例15: doSearch

        public GameState doSearch(GameState g, Evaluator e, int depth, double time)
        {
            HiPerfTimer timer = new HiPerfTimer();

            List<MiniMaxNode> trees = new List<MiniMaxNode>();
            foreach (GameState gs in g.getSuccessorStates(0))
            {
                timer.Start();
                trees.Add(MiniMaxNode.getGameTree(gs, e, depth, time));
                timer.Stop();
                time += timer.Duration * 1000;
            }

            int eval = 0;
            MiniMaxNode bestNode = new MiniMaxNode(g,e,0);
            foreach (MiniMaxNode tree in trees)
            {
                tree.score = tree.evaluate(int.MinValue, int.MaxValue);
                if (tree.score > eval)
                {
                    eval = tree.score;
                    bestNode = tree;
                }
            }

            return bestNode.State;
        }
开发者ID:SvenPetroll,项目名称:TronBot,代码行数:27,代码来源:MiniMaxSearch.cs


注:本文中的Evaluator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。