• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Agent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: TestAccess

        public void TestAccess()
        {
            var agent = new Agent().Face<ITestAgent>();
            agent["Access"] = new Bin<bool>();

            agent.Init("stream", typeof(Stream), false);
            try
            {
                var f = agent["stream"].First;
            }
            catch (Exception e)
            {
                Assert.Inconclusive(e.ToString());
            }

            Assert.AreEqual(false, agent["Access"].First);

            Assert.AreEqual(1, agent["Access"].Count);

            agent.Init("Secure", true);
            agent["Secure"].Add(true);

            Assert.AreEqual(true, agent["Secure"][1]);
            Assert.AreEqual(2, agent["Secure"].Count);
        }
开发者ID:velcrome,项目名称:vvvv-Game,代码行数:25,代码来源:FaceAgentTest.cs


示例2: AStar

 public AStar(Agent a)
 {
     agent = a;
     findTarget = false;
     currGoal = agent.transform.position;
     hasPath = false;
 }
开发者ID:jessmay,项目名称:oil-penguins,代码行数:7,代码来源:AStar.cs


示例3: DayStart

 public override void DayStart()
 {
     declaredPlanningVoteAgent = null;
     planningVoteAgent = null;
     SetPlanningVoteAgent();
     readTalkListNum = 0;
 }
开发者ID:AIWolfSharp,项目名称:AIWolfSharp,代码行数:7,代码来源:SampleBodyguard.cs


示例4: TestInt

        public void TestInt()
        {
            var agent = new Agent();

            agent.Init("Test", 1);
            Assert.AreEqual(1, agent["Test"][0], "Vanilla Agent int initialisation");

            agent["Test"].Add(2);
            Assert.AreEqual(2, agent["Test"][1], "Vanilla Agent int append");

            var l = new List<int> { 3, 4 };
            agent["Test"].Add(l);

            Assert.AreEqual(3, agent["Test"][2], "Vanilla Agent int add IEnumeration");
            Assert.AreEqual(4, agent["Test"][3], "Vanilla Agent int add IEnumeration");

            agent["Test"].First =0;
            Assert.AreEqual(0, agent["Test"][0], "Vanilla Agent int set First");
            Assert.AreEqual(0, agent["Test"].First, "Vanilla Agent int get First");

            agent["Test"].AssignFrom(l);
            Assert.AreEqual(3, agent["Test"][0], "Vanilla Agent int assign IEnumeration");
            Assert.AreEqual(4, agent["Test"][1], "Vanilla Agent int assign IEnumeration");

            Assert.AreEqual(2, agent["Test"].Count, "Vanilla Agent int Count");

            agent.Init<int>("SecondTestInt");
            agent["SecondTestInt"].Add(1);
            Assert.AreEqual(1, agent["SecondTestInt"].First);
        }
开发者ID:velcrome,项目名称:vvvv-Game,代码行数:30,代码来源:AgentTest.cs


示例5: DeregisterServiceOnTakeDown

 // Handles the messages associated with the take down of an agent, and deregisters the service on its behalf
 public static void DeregisterServiceOnTakeDown(Agent myAgent)
 {
     DFService.deregister(myAgent);
     MessageBox.Show(
         "Agent " + myAgent.getLocalName() +
         " was taken down.\r\nAn unhandled exception probably occured.");
 }
开发者ID:ablindu,项目名称:MASMA,代码行数:8,代码来源:YellowPages.cs


示例6: Insert

        public bool Insert(AirtimeBilling.Core.Entities.Agent entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("No Agent supplied");
            }

            if (entity.Id != null)
            {
                throw new ArgumentOutOfRangeException("Agent Id is not null");
            }

            try
            {
                using (var db = DbFactory.GetDataContext())
                {
                    var agent = new Agent();
                    PopulateAgentFromAgentEntity(entity, ref agent);
                    db.Agents.InsertOnSubmit(agent);
                    db.SubmitChanges();

                    entity.Inserted(agent.AgentId);
                    return true;
                }
            }
            catch (Exception ex)
            {
                LoggingUtility.LogException(ex);
            }
            return false;
        }
开发者ID:robgray,项目名称:Tucana,代码行数:31,代码来源:AgentRepository.cs


示例7: printSKB

        //Print the Social Knowledgebase
        private static void printSKB()
        {
            KB_S SKB = new KB_S();

            SocialGame girlGame = new SocialGame(new Subject(SubjectType.Girl));
            SocialGame playerGame = new SocialGame(new Subject(SubjectType.Player));

            Agent agent1 = new Agent("agent1");
            Agent agent2 = new Agent("agent2");
            Agent agent3 = new Agent("agent3");
            Agent agent4 = new Agent("agent4");

            SocialFact sf1 = new SocialFact(girlGame, agent1, agent2);
            SocialFact sf2 = new SocialFact(playerGame, agent1, agent2);
            SocialFact sf3 = new SocialFact(girlGame, agent3, agent1);

            SKB.addNewFact(sf1);
            SKB.addNewFact(sf2);
            SKB.addNewFact(sf3);

            List<SocialFact> factsByAgent = SKB.getSocialFactsByAgent(agent2);
            Console.WriteLine("FOUND: " + factsByAgent.Count + " FACTS.");

            List<SocialFact> factsByGame = SKB.getSocialFactsBySubject(new Subject(SubjectType.Girl));
            Console.WriteLine("FOUND: " + factsByGame.Count + " FACTS.");

            //SocialFact sf1 = new SocialFact()
        }
开发者ID:Kurios,项目名称:4803AIGame,代码行数:29,代码来源:KBTester.cs


示例8: InitBehavior

    //public WorldScript WorldScript;
    /*
     * CharacterScript (Me)
     *   -ActiveTask (stored as string)
     *   -TaskParameters (list / dictionary of strings)
     * WorldScript (MyWorld)
     */
    public override void InitBehavior(Agent actor)
    {
        //Find the relevant variables from the parent object.
        WorldScript ws = GameObject.Find("Root").GetComponent<WorldScript>();
        WorldGUI wGUI = GameObject.Find("Root").GetComponent<WorldGUI>();
        CharacterScript cs = this.transform.parent.GetComponent<CharacterScript>();

        if (ws == null || wGUI == null || cs == null) Debug.LogError("Error finding attached scripts during activation.");

        actor.actionContext.AddContextItem<WorldScript>("world", ws);
        actor.actionContext.AddContextItem<WorldGUI>("gui", wGUI);
        actor.actionContext.AddContextItem<CharacterScript>("character", cs);
        actor.actionContext.AddContextItem<GameObject>("moveTarget", cs.gameObject);

        #region Temp testing.
        //CharacterScript player = ws.PartyCharacter;
        //Item sword = ws.GetItemByName("Sword");
        //LocaleScript locale = ws.GetLocaleByName("Happyville");

        //Debug.Log(locale);

        //Task task = new Task("deliver", cs, player, sword, locale);
        //ws.DramaManager.EmergencyRepair(task);
        //cs.ActiveTask = task;
        #endregion
    }
开发者ID:boyangli,项目名称:UnityForgeAGA,代码行数:33,代码来源:MagicAgentActivater.cs


示例9: executeAction

        public override EnvironmentState executeAction(Agent a, Action agentAction)
        {

            if (ACTION_MOVE_RIGHT == agentAction)
            {
                envState.setAgentLocation(a, LOCATION_B);
                updatePerformanceMeasure(a, -1);
            }
            else if (ACTION_MOVE_LEFT == agentAction)
            {
                envState.setAgentLocation(a, LOCATION_A);
                updatePerformanceMeasure(a, -1);
            }
            else if (ACTION_SUCK == agentAction)
            {
                if (LocationState.Dirty == envState.getLocationState(envState
                        .getAgentLocation(a)))
                {
                    envState.setLocationState(envState.getAgentLocation(a),
                            LocationState.Clean);
                    updatePerformanceMeasure(a, 10);
                }
            }
            else if (agentAction.isNoOp())
            {
                // In the Vacuum Environment we consider things done if
                // the agent generates a NoOp.
                isDone = true;
            }

            return envState;
        }
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:32,代码来源:VacuumEnvironment.cs


示例10: Judge

 public Judge(int day, Agent agent, Agent target, Species result)
 {
     Day = day;
     Agent = agent;
     Target = target;
     Result = result;
 }
开发者ID:AIWolfSharp,项目名称:AIWolfSharp,代码行数:7,代码来源:Judge.cs


示例11: Instantiate

 // called before loading files, otherwise, locals have been added and will be instantiated
 public void Instantiate(Agent pAgent)
 {
     foreach(Property property_ in this.m_properties.Values)
     {
         property_.Instantiate(pAgent);
     }
 }
开发者ID:githubNil,项目名称:behaviac,代码行数:8,代码来源:AgentProperties.cs


示例12: Awake

 void Awake()
 {
     agentObject = gameObject.transform.parent.gameObject;
     agentComponent = (Agent)agentObject.GetComponent("Agent");
     clan = agentComponent.GetClan();
     facts = agentComponent.GetSubsystemFacts();
 }
开发者ID:RikardGehlin,项目名称:Exjobb,代码行数:7,代码来源:ScoutSubsystem.cs


示例13: CopyTo

        public void CopyTo(Agent pAgent, Variables target)
        {
            target.m_variables.Clear();

            var e = this.m_variables.Keys.GetEnumerator();
            while (e.MoveNext())
            {
                uint id = e.Current;
                IInstantiatedVariable pVar = this.m_variables[id];
                IInstantiatedVariable pNew = pVar.clone();

                target.m_variables[id] = pNew;
            }

            if (!Object.ReferenceEquals(pAgent, null))
            {
                e = target.m_variables.Keys.GetEnumerator();
                while (e.MoveNext())
                {
                    uint id = e.Current;
                    IInstantiatedVariable pVar = this.m_variables[id];

                    pVar.CopyTo(pAgent);
                }
            }
        }
开发者ID:Just4F,项目名称:behaviac,代码行数:26,代码来源:AgentState.cs


示例14: TestInt

        public void TestInt()
        {
            var agent = new Agent().Face<ITestAgent>(true);
            //        agent.Init("SingleInt", typeof(int));
            agent.SingleInt++;
            Assert.AreEqual(1, agent["SingleInt"].First, "Face Agent int initialisation");

            agent.TestInt = new Bin<int>(1);
            Assert.AreEqual(1, agent.TestInt[0], "Face Agent int initialisation");

            agent.TestInt.Add(2);
            Assert.AreEqual(2, agent.TestInt[1], "Face Agent int append");

            var l = new List<int> {3, 4};
            agent.TestInt.Add(l);

            Assert.AreEqual(3, agent.TestInt[2], "Face Agent int add IEnumeration");
            Assert.AreEqual(4, agent.TestInt[3], "Face Agent int add IEnumeration");

            agent.TestInt.First = 0;
            Assert.AreEqual(0, agent.TestInt[0], "Face Agent int set First");
            Assert.AreEqual(0, agent.TestInt.First, "Face Agent int get First");

            agent.TestInt.AssignFrom(l);
            Assert.AreEqual(3, agent.TestInt[0], "Face Agent int assign IEnumeration");
            Assert.AreEqual(4, agent.TestInt[1], "Face Agent int assign IEnumeration");

            Assert.AreEqual(2, agent.TestInt.Count, "Face Agent int Count");
        }
开发者ID:velcrome,项目名称:vvvv-Game,代码行数:29,代码来源:FaceAgentTest.cs


示例15: Configuration

 public Configuration()
 {
     EnvironmentSettings = new Environment();
     AgentSettings = new Agent();
     TagSettings = new Tag();
     ResourceSettings = new Resource();
 }
开发者ID:andrewanderson,项目名称:Web-Critters,代码行数:7,代码来源:Configuration.cs


示例16: GetCount

            public int GetCount(Agent pAgent)
            {
                Debug.Check(this.GetNode() is DecoratorCount);
                DecoratorCount pDecoratorCountNode = (DecoratorCount)(this.GetNode());

                return pDecoratorCountNode != null ? pDecoratorCountNode.GetCount(pAgent) : 0;
            }
开发者ID:Oswin2014,项目名称:Behavior_Tree-Practice-in-Unity,代码行数:7,代码来源:Decoratorcount.cs


示例17: EvaluteAssignment

        public static bool EvaluteAssignment(Agent pAgent, Property opl, Property opr, behaviac.CMethodBase opr_m)
        {
            bool bValid = false;

            if (opl != null)
            {
                if (opr_m != null)
                {
                    object returnValue = opr_m.Invoke(pAgent);

                    Agent pParentOpl = opl.GetParentAgent(pAgent);
                    opl.SetValue(pParentOpl, returnValue);

                    bValid = true;
                }
                else if (opr != null)
                {
                    Agent pParentL = opl.GetParentAgent(pAgent);
                    Agent pParentR = opr.GetParentAgent(pAgent);

                    opl.SetFrom(pParentR, opr, pParentL);

                    bValid = true;
                }
            }

            return bValid;
        }
开发者ID:XyzalZhang,项目名称:behaviac,代码行数:28,代码来源:Assignment.cs


示例18: fire

        public override void fire(Agent p, PhysicsEngine ph)
        {
            base.fire(p, ph);

            if (curCooldown == cooldown) {
                Random rand = new Random();
                Vector3 dir = Vector3.Normalize(p.getDirectionVector());
                Vector3 right = Vector3.Cross(dir, Vector3.Up);
                Vector3 up = Vector3.Cross(dir, right);
                up *= inaccuracy;
                right *= inaccuracy;
                dir = dir + (float)(rand.NextDouble() * 2 - 1) * up + (float)(rand.NextDouble() * 2 - 1) * right;
                inaccuracy = Math.Min(maxInaccuracy, inaccruacyJump + inaccuracy);
                inaccuracyCurCooldown = 0;

                List<Agent> l = new List<Agent>();
                l.Add(p);
                PhysicsEngine.HitScan hs = ph.hitscan(p.getPosition() + new Vector3(0, 75, 0) + p.getDirectionVector() * 10, p.getDirectionVector(), null);
                PhysicsEngine.AgentHitScan ahs = ph.agentHitscan(p.getPosition() + new Vector3(0, 60, 0) + p.getDirectionVector() * 10, dir, l);
                if (hs != null && (ahs == null || hs.Distance() < ahs.Distance()))
                    makeLaser(p, hs.ray, Vector3.Distance(hs.ray.Position, hs.collisionPoint), 5, 5, "Rifle");
                else if (ahs != null) {
                    ahs.agent.dealDamage(damage, p);
                    makeLaser(p, ahs.ray, Vector3.Distance(ahs.ray.Position, ahs.collisionPoint), 5, 5, "Rifle");
                }
            }
        }
开发者ID:elliottroland,项目名称:Emergence,代码行数:27,代码来源:Rifle.cs


示例19: update

            protected override EBTStatus update(Agent pAgent, EBTStatus childStatus)
            {
                EBTStatus s = childStatus;
                Debug.Check(this.m_activeChildIndex < this.m_children.Count);

                // Keep going until a child behavior says its running.
                for (; ;)
                {
                    if (s == EBTStatus.BT_RUNNING)
                    {
                        int childIndex = this.m_set[this.m_activeChildIndex];
                        BehaviorTask pBehavior = this.m_children[childIndex];
                        s = pBehavior.exec(pAgent);
                    }

                    // If the child succeeds, or keeps running, do the same.
                    if (s != EBTStatus.BT_FAILURE)
                    {
                        return s;
                    }

                    // Hit the end of the array, job done!
                    ++this.m_activeChildIndex;

                    if (this.m_activeChildIndex >= this.m_children.Count)
                    {
                        return EBTStatus.BT_FAILURE;
                    }

                    s = EBTStatus.BT_RUNNING;
                }
            }
开发者ID:Just4F,项目名称:behaviac,代码行数:32,代码来源:Selectorstochastic.cs


示例20: Start

        public void Start(Action<TcpClient, byte[]> onData, Action<TcpClient> onDisconnect)
        {
            TcpListener listener = new TcpListener(port);
            listener.Start();
            running = true;
            AutoResetEvent are = new AutoResetEvent(false);
            agent = new Agent<Action>(
                () => { },
                () => { },
                nextaction =>
                {

                    nextaction();

                    if (running)
                    {
                        return NextAction.WaitForNextMessage;
                    }
                    are.Set();
                    return NextAction.Finish;
                });

            agent.Start();

            agent.SendMessage(() => { StartAccepting(listener, onData, onDisconnect); });
            are.WaitOne();

            listener.Stop();
        }
开发者ID:davidsiaw,项目名称:blueblocks,代码行数:29,代码来源:TCPServer.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# AgentCircuitData类代码示例发布时间:2022-05-24
下一篇:
C# Aga类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap