Exemple #1
0
        public override string ToString()
        {
            var sources = string.Join(", ", SourceNodes.Select(x => x.GetType().Name));
            var targets = string.Join(", ", TargetNodes.Select(x => x.GetType().Name));

            return($"{ThisNode.GetType().Name}, Builder='{Builder.Name}', Sources=[{sources}], Targets=[{targets}]");
        }
        public ISequenceFilterNode CreateFilterNode()
        {
            var elementNodes = VixenSystem.Nodes.Distinct().ToDictionary(x => x.Id);

            IEnumerable <Guid> targetNodeIds   = TargetNodes.Select(x => x.NodeId);
            IEnumerable <Guid> validElementIds = targetNodeIds.Intersect(elementNodes.Keys);

            ISequenceFilterModuleInstance filter = Modules.ModuleManagement.GetSequenceFilter(TypeId);

            filter.InstanceId  = InstanceId;
            filter.TimeSpan    = TimeSpan;
            filter.TargetNodes = validElementIds.Select(x => elementNodes[x]).ToArray();

            return(new SequenceFilterNode(filter, StartTime));
        }
        public IEffectNode CreateEffectNode()
        {
            // Create a element node lookup of elements that are currently valid.
            var elementNodes = VixenSystem.Nodes.Distinct().ToDictionary(x => x.Id);

            IEnumerable <Guid> targetNodeIds   = TargetNodes.Select(x => x.NodeId);
            IEnumerable <Guid> validElementIds = targetNodeIds.Intersect(elementNodes.Keys);

            IEffectModuleInstance effect = Modules.ModuleManagement.GetEffect(TypeId);

            effect.InstanceId  = InstanceId;
            effect.TimeSpan    = TimeSpan;
            effect.TargetNodes = validElementIds.Select(x => elementNodes[x]).ToArray();

            return(new EffectNode(effect, StartTime));
        }
 /// <summary>
 /// Sets the fixed attribute values from <see cref="AbstractSolver{T}.TargetNodes"/> and
 /// from <see cref="AdvancedSolverSettings.InitialAttributes"/>.
 /// </summary>
 private void CreateFixedAttributes()
 {
     _fixedNodes = TargetNodes.Select(n => n.Id).ToList();
     // Set start stats from start and target nodes.
     AddAttributes(_fixedNodes, _fixedAttributes);
     // Add the initial stats from the settings.
     foreach (var initialStat in Settings.InitialAttributes)
     {
         var name = initialStat.Key;
         if (_attrNameLookup.ContainsKey(name))
         {
             foreach (var i in _attrNameLookup[name])
             {
                 _fixedAttributes[i] += initialStat.Value * _attrConversionMultipliers[Tuple.Create(name, i)];
             }
         }
     }
 }
Exemple #5
0
        private HashSet <ushort> DnaToUsedNodes(BitArray dna)
        {
            // Convert dna to corresponding GraphNodes.
            var mstNodes   = new List <GraphNode>();
            var mstIndices = new List <int>();

            for (var i = 0; i < dna.Length; i++)
            {
                if (dna[i])
                {
                    mstNodes.Add(SearchSpace[i]);
                    mstIndices.Add(i);
                }
            }
            mstNodes.AddRange(TargetNodes);
            mstIndices.AddRange(TargetNodes.Select(n => n.DistancesIndex));

            // Calculate MST from nodes.
            var mst = new MinimalSpanningTree(mstIndices, Distances);

            if (_orderedEdges != null)
            {
                mst.Span(_orderedEdges);
            }
            else
            {
                mst.Span(StartNode.DistancesIndex);
            }

            // Convert GraphNodes and GraphEdges to SkillNode-Ids.
            var usedNodes = new HashSet <ushort>(mstNodes.Select(n => n.Id));

            foreach (var edge in mst.SpanningEdges)
            {
                usedNodes.UnionWith(Distances.GetShortestPath(edge.Inside, edge.Outside));
            }
            return(usedNodes);
        }