Ejemplo n.º 1
0
        public override void Process(T context, TimeSpan span)
        {
            _ = context ?? throw new ArgumentNullException(nameof(context));
            indexer.Clear();
            for (int i = 0; i < context.VirusData.Items.Span.Length; i++)
            {
                var item = context.VirusData.Items.Span[i];
                if (item.IsInfected == InfectionData.Infected)
                {
                    indexer.AddItem(context.Persons.Items.Span[i]);
                }
            }
            //try to infection

            context.VirusData.ForAllParallelWtihReference(context.Persons, (ref InfectionData data, ref PositionItem p) =>
            {
                if (data.IsInfected == InfectionData.NotInfected)
                {
                    int count = indexer.GetItemsCountInDistance(p.Position, InfectionRadius);
                    if (count > 0 && Helper.RandomFloat(1) <= 1 - (Math.Pow((1 - InfectionRate), count)))
                    {
                        data.IsInfected = InfectionData.Infected;
                    }
                    else
                    {
                        data.IsInfected = InfectionData.NotInfected;
                    }
                }
            });
        }
Ejemplo n.º 2
0
    /// <summary>
    /// Clears the QuadTree of all objects, including any objects living in its children.
    /// </summary>
    internal void Clear()
    {
        // Clear out the children, if we have any
        if (childTL != null)
        {
            lock (lockObject)
            {
                childTL.Clear();
                childTR.Clear();
                childBL.Clear();
                childBR.Clear();
            }
        }

        // Clear any objects at this level
        if (objects != null)
        {
            lock (lockObject)
            {
                objects.Clear();
                objects = null;
            }
        }

        // Set the children to null
        lock (lockObject)
        {
            childTL = null;
            childTR = null;
            childBL = null;
            childBR = null;
        }
    }
Ejemplo n.º 3
0
        public override void Process(T context, TimeSpan span)
        {
            infectedItems.Clear();
            //refresh infected person indexer
            context.SIRInfo.ForAllWtihReference(context.Persons, (ref SIRData sir, ref PositionItem pos) =>
            {
                if (sir.Status == SIRData.Infective)
                {
                    infectedItems.AddItem(pos);
                }
            });

            //try to be infected
            ProcessInfection(context, span);
            //update ground info
            ProcessGround(context, span);
            ProcessCure(context, span);
        }
    private void SimulateWithBarnesHut()
    {
        quadtree.Clear();
        quadtree.TryAddRange(planets);

        if (!IntegrateMovement)
        {
            return;
        }

        foreach (PlanetController planet in planets)
        {
            planet.Acceleration =
                quadtree.CalculateForce(
                    planet, CalculateNewtonGravityAcceleration
                    );
        }
    }
Ejemplo n.º 5
0
 public void Clear()
 {
     m_root.Clear();
 }
Ejemplo n.º 6
0
 ///<summary>
 ///Removes all items from the <see cref="T:System.Collections.Generic.ICollection`1" />.
 ///</summary>
 ///
 ///<exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.ICollection`1" /> is read-only. </exception>
 public void Clear()
 {
     wrappedDictionary.Clear();
     quadTreeRoot.Clear();
 }