Exemplo n.º 1
0
        // Save the data of each agent (position, velocity, acceleration, distance with the closer, local density and agent's leader
        internal static void saveData(RVOSimulator sim, bool looped, bool follow)
        {
            string name = "Data/n";
            string num  = sim.getNumAgents().ToString();

            name += num;
            if (follow)
            {
                name += "f";
            }
            name += "_agents_data.csv";
            System.IO.Directory.CreateDirectory("Data/");
            if (!File.Exists(name))
            {
                File.Create(name).Dispose();
                using (TextWriter tw = new StreamWriter(name))
                {
                    tw.WriteLine("Agent \t Position X \t  Position Y \t Velocity X \t Velocity Y \t  Acceleration X + \t  Acceleration Y + \t Closer Agent Distance  \t LocalDensity 2  \t  LocalDensity 9  \t AgentLeaderNo \t Heure");
                }
            }


            for (int i = 0; i < sim.getNumAgents(); i++)
            {
                using (TextWriter tw = new StreamWriter(name, true))
                {
                    tw.WriteLine(i + "\t" + sim.getAgentPosition(i).x() + "\t" + sim.getAgentPosition(i).y() + "\t" + sim.getAgentVelocity(i).x() + "\t" + sim.getAgentVelocity(i).y() + "\t" + sim.getAgentAcceleration(i).x() + "\t" + sim.getAgentAcceleration(i).y() + "\t"
                                 + sim.getAgentDistanceWithCloserAgent(i, looped) + '\t'
                                 + sim.getAgentLocalDensity(i, looped, 2) + '\t' + sim.getAgentLocalDensity(i, looped, 9) + '\t'
                                 + sim.getAgentLeaderNo(i) + "\t" + DateTime.Now);
                }
            }
        }
Exemplo n.º 2
0
        public static void saveSimulatorData(RVOSimulator sim, bool follow)
        {
            string name = "Agents_moy_data.csv";


            if (!File.Exists(name))
            {
                string tmp = " ";
                foreach (Agent a in sim.agents_)
                {
                    tmp += a.id_ + " : vitesse_moy \t";
                }
                File.Create(name).Dispose();
                using (TextWriter tw = new StreamWriter(name))
                {
                    tw.WriteLine(tmp);
                }
            }



            using (TextWriter tw = new StreamWriter(name, true))
            {
                string tmp = " ";
                foreach (Agent a in sim.agents_)
                {
                    tmp += " " + Vector2.abs(a.velocity_) + "\t";
                }
                tw.WriteLine(tmp);
            }
        }
Exemplo n.º 3
0
 /**
  * <summary>Constructs and initializes a worker.</summary>
  *
  * <param name="start">Start.</param>
  * <param name="end">End.</param>
  * <param name="doneEvent">Done event.</param>
  */
 internal Worker(int start, int end, ManualResetEvent doneEvent, RVOSimulator simulator, bool looped)
 {
     start_      = start;
     end_        = end;
     doneEvent_  = doneEvent;
     simulator_  = simulator;
     this.looped = looped;
 }
Exemplo n.º 4
0
 /**
  * <summary>Constructs and initializes a worker.</summary>
  *
  * <param name="start">Start.</param>
  * <param name="end">End.</param>
  * <param name="doneEvent">Done event.</param>
  */
 internal Worker(ManualResetEvent doneEvent, RVOSimulator simulator, bool looped)
 {
     agents      = new List <Agent>();
     vit_moy     = new Vector2();
     doneEvent_  = doneEvent;
     simulator_  = simulator;
     this.looped = looped;
 }
Exemplo n.º 5
0
        public HelbingAgent(RVOSimulator sim, int type) : base(sim)
        {
            lambda_ = 5;
            A_      = 25.0f;
            B_      = 0.13f;
            tau_    = 0.2f;
            m_      = 80.0f;
            k_      = 120000.0f;
            type_   = type;
            //,A_(0.5),B_(1.65),tau_(10),lambda_(5)

            // laure : A = 0.5, B = 1.65, tau = 2, lambda = 0.12
        }
Exemplo n.º 6
0
        // Save the agent's data when it attempts the end of the corridor
        //Not used
        static void saveAgentData(RVOSimulator sim, int agentNo, bool follow)
        {
            string name = "Data/n";
            string num  = sim.getNumAgents().ToString();

            name += num;
            if (follow)
            {
                name += "f";
            }
            name += "_end_data.csv";


            System.IO.File.WriteAllText(@name, agentNo.ToString() + '\t' + sim.getAgentCptDist(agentNo).ToString() + '\t' + sim.getAgentCptTime(agentNo));
        }
Exemplo n.º 7
0
 public RVOAgent(RVOSimulator sim) : base(sim)
 {
 }
Exemplo n.º 8
0
 /** Constructor - Will be used in all Child class **/
 public Scenario()
 {
     goals  = new List <RVO.Vector2>();
     random = new System.Random();
     sim_   = new RVOSimulator(0.895f, 0.5f, 8, 0.25f, 0.25f, 0.85f, 0.5f);
 }
Exemplo n.º 9
0
 public GroupAgent(RVOSimulator sim)
 {
     sim_ = sim;
 }
Exemplo n.º 10
0
 /**
  * <summary>Builds an agent k-D tree.</summary>
  */
 internal KdTree(RVOSimulator sim)
 {
     sim_       = sim;
     agentTree_ = new AgentTreeNode[sim_.getNumAgents()];
 }