SHARE
TWEET

Untitled

a guest Jun 25th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// MEHOTD BELONGS TO CELL<T> CLASS. WILL BE USED EVERY UPDATE FRAME
  2. public void Contains(List<PhysarumAgent> particles)
  3.        {
  4.  
  5.  
  6.  
  7.            int ptsCount = 0;
  8.            foreach (var particle in particles)
  9.            {
  10.  
  11.                if (particle.ForewordSensorB.X >= m_domainX.Min && particle.ForewordSensorB.X <= m_domainX.Max &&
  12.                    particle.ForewordSensorB.Y >= m_domainY.Min && particle.ForewordSensorB.Y <= m_domainY.Max)
  13.                {
  14.  
  15.                    ptsCount++;
  16.  
  17.  
  18.                }
  19.  
  20.  
  21.            }
  22. }
  23.  
  24.  
  25.  
  26.  
  27.  
  28. ///THIS METHOD BELONGS TO ANOTHER CLASS... HERE I ITERATE OVER THE SCALAR FIELD AND CALL THE CONTAINS METHOD FOR EVERY INDIVIDUAL CELL IN THE FIELD. COMPUTED EVERY UPDATE FRAME
  29.  
  30. private static void ComputeField(SharpField2D<double> scalarField, List<PhysarumAgent> PhysarumAgentPopulation)
  31.        {
  32.  
  33.            ParallelOptions paraOpts = new ParallelOptions();
  34.            paraOpts.MaxDegreeOfParallelism = System.Environment.ProcessorCount;
  35.  
  36.            Parallel.For(0, scalarField.Columns, paraOpts, i =>
  37.  
  38.            {
  39.  
  40.                Parallel.For(0, scalarField.Rows, paraOpts, j =>
  41.                  {
  42.  
  43.  
  44.  
  45.                       scalarField.Field[i, j].Contains(PhysarumAgentPopulation);
  46.  
  47.  
  48.                  });
  49.  
  50.  
  51.        }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top