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


C# Action.CopyTo方法代码示例

本文整理汇总了C#中Action.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# Action.CopyTo方法的具体用法?C# Action.CopyTo怎么用?C# Action.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Action的用法示例。


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

示例1: ChooseAction

        public Action ChooseAction()
        {
            var processedActions = 0;
            int currentDepth = 0;
            var startTime = Time.realtimeSinceStartup;
            Action[] actions = new Action[MAX_DEPTH];

            while(currentDepth >= 0){
                if (processedActions > MAX_PROCESSED_ACTIONS)
                {
                    InProgress = true;
                    return null;
                }
                float currentValue = Models[currentDepth].CalculateDiscontentment(Goals);
                if(currentDepth >= MAX_DEPTH){
                    if(currentValue < BestDiscontentmentValue){
                        BestDiscontentmentValue = currentValue;
                        BestAction = actions[0];
                        BestDiscontentmentValue = BestDiscontentmentValue;
                        actions.CopyTo(BestActionSequence,0);
                        TotalProcessingTime = Time.realtimeSinceStartup - startTime;

                    }
                    processedActions++;
                    TotalActionCombinationsProcessed++;
                    currentDepth -= 1;
                    continue;
                }
                Action nextAction = Models[currentDepth].GetNextAction();

                if (nextAction != null){
                    Models[currentDepth+1] = Models[currentDepth].GenerateChildWorldModel();
                    nextAction.ApplyActionEffects(Models[currentDepth+1]);
                    actions[currentDepth] = nextAction;
                    currentDepth += 1;
                }
                else
                    currentDepth -= 1;
            }
            InProgress = false;
            return BestAction;
        }
开发者ID:hugosednax,项目名称:IAJProj3,代码行数:42,代码来源:DepthLimitedGOAPDecisionMaking.cs

示例2: ChooseAction

        public Action ChooseAction()
        {
            var processedActions = 0;

            var startTime = Time.realtimeSinceStartup;

            Action[] actions = new Action[MAX_DEPTH];

            while (this.CurrentDepth >= 0)
            {
                if(processedActions > this.ActionCombinationsProcessedPerFrame)
                {
                    this.InProgress = true;
                    return null;
                }

                float currentValue = this.Models[this.CurrentDepth].CalculateDiscontentment(this.Goals);

                if (this.CurrentDepth >= MAX_DEPTH)
                {
                    if (currentValue < this.BestDiscontentmentValue)
                    {
                        this.BestDiscontentmentValue = currentValue;
                        this.BestAction = actions[0];
                        actions.CopyTo(this.BestActionSequence,0);

                        this.TotalActionCombinationsProcessed += processedActions;
                        this.TotalProcessingTime += Time.realtimeSinceStartup - startTime;
                    }
                    this.CurrentDepth -= 1;
                    continue;
                }

                Action nextAction = this.Models[this.CurrentDepth].GetNextAction();
                processedActions++;

                if (nextAction != null)
                {
                    this.Models[this.CurrentDepth + 1] = this.Models[this.CurrentDepth].GenerateChildWorldModel();
                    nextAction.ApplyActionEffects(this.Models[this.CurrentDepth + 1]);
                    actions[CurrentDepth] = nextAction;
                    this.CurrentDepth += 1;
                }
                else
                    this.CurrentDepth -= 1;
            }

            this.InProgress = false;
            return this.BestAction;
        }
开发者ID:IAJ-g04,项目名称:Lab9,代码行数:50,代码来源:DepthLimitedGOAPDecisionMaking.cs


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