示例#1
0
        public void Evaluate(int SpreadMax)
        {
            FKilled.SliceCount = 0;
            if (FClear[0])
            {
                FKilled.AssignFrom(FAgents);
                FAgents.Clear();
            }

            if (FDeleteNow[0])
            {
                var del = FDeleteIndex.ToList();

                int size = FAgents.Count();

                for (int i = 0; i < del.Count; i++)
                {
                    del[i] = VMath.Zmod(del[i], size);
                }
                del.Sort();

                for (int i = 0; i < del.Count; i++)
                {
//                    if (FAgents.Count > i)
                    FAgents.RemoveAt(del[i] - i);
                }
            }

            var killed = from a in FAgents
                         where a.Killed
                         select a;

            FKilled.AddRange(killed);
            FAgents.RemoveAll(IsKilled);

            if (!FAdd.IsAnyInvalid())
            {
                var count = FAgents.Count;
                foreach (var agent in FAdd)
                {
                    if (agent != null && !Limited(count))
                    {
                        FAgents.Add(agent);
                        count++;
                    }
                }
                FAgents.Sort();
            }

            FTick.Sync();
            if (!FInput.IsAnyInvalid() && FInput.PluginIO.IsConnected && FTick[0])
            {
                FInput[0].Agents.Clear();
                FInput[0].Agents.AddRange(FAgents);

                foreach (var agent in FInput[0].Agents)
                {
                    agent.ReturnCode = ReturnCodeEnum.Success;
                }

                FInput.Sync();

                FOutput.SliceCount = 0;
                FOutput.AssignFrom(FInput[0].Agents);
            }
            else
            {
                FOutput.SliceCount = 0;
                FOutput.AssignFrom(FAgents);
            }
            FOutput.Flush();
            FKilled.Flush();
        }