예제 #1
0
        /// <summary>
        /// Creates a new environment with the specified list of agents, environment dimensions, list of barriers,
        /// and radiation source(s).
        /// </summary>
        /// <param name="Agents">Represents all agents in the enviroment.</param>
        /// <param name="Width">Represents the width of the enviroment.</param>
        /// <param name="Height">Represents the height of the enviroment.</param>
        /// <param name="Barriers">Represents all barriers in the enviroment.</param>
        /// <param name="Source">Represents the source(s) of radiation in the environment.</param>
        public Environment(List <Agent> Agents, double Width, double Height, List <Barrier> Barriers, RadiationSource Source)
        {
            //A uniform random generator for generating the X coordinate of agents' positions.
            NumberGenerator PXRandomGenerator = new UniformRandom(0.0, Width, (int)(DateTime.Now.Ticks));

            //A uniform random generator for generating the Y coordinate of agents' positions.
            NumberGenerator PYRandomGenerator = new UniformRandom(0.0, Height, (int)(DateTime.Now.Ticks + 1));

            //A uniform random generator for generating the X coordinate of agents' velocities.
            NumberGenerator VXRandomGenerator = new UniformRandom(-Width, Width, (int)(DateTime.Now.Ticks + 2));

            //A uniform random generator for generating the Y coordinate of agents' velocities.
            NumberGenerator VYRandomGenerator = new UniformRandom(-Height, Height, (int)(DateTime.Now.Ticks + 3));

            this.Source   = Source;
            this.Barriers = Barriers;
            this.Agents   = Agents;

            // Ensure that the agents are initialized properly.
            foreach (Agent a in Agents)
            {
                a.RadiationFunction = Source.GetRadiation;
                a.MyBestValue       = a.RadiationFunction(a.PX, a.PY);
                a.SendMessage       = Send;
            }
        }
예제 #2
0
        /// <summary>
        /// Creates a new environment with the specified number of agents, environment dimensions, list of barriers,
        /// and radiation source(s).
        /// </summary>
        /// <param name="NumberOfAgents">Represents the number of all agents in the environment.</param>
        /// <param name="Width">Represents the width of the enviroment.</param>
        /// <param name="Height">Represents the height of the enviroment.</param>
        /// <param name="Barriers">Represents all barriers in the enviroment.</param>
        /// <param name="Source">Represents the source(s) of radiation in the environment.</param>
        public Environment(int NumberOfAgents, double Width, double Height, List <Barrier> Barriers, RadiationSource Source)
        {
            //A uniform random generator for generating the X coordinate of agents' positions.
            NumberGenerator PXRandomGenerator = new UniformRandom(0.0, Width, (int)(DateTime.Now.Ticks));

            //A uniform random generator for generating the Y coordinate of agents' positions.
            NumberGenerator PYRandomGenerator = new UniformRandom(0.0, Height, (int)(DateTime.Now.Ticks + 1));

            //A uniform random generator for generating the X coordinate of agents' velocities.
            NumberGenerator VXRandomGenerator = new UniformRandom(-Width, Width, (int)(DateTime.Now.Ticks + 2));

            //A uniform random generator for generating the Y coordinate of agents' velocities.
            NumberGenerator VYRandomGenerator = new UniformRandom(-Height, Height, (int)(DateTime.Now.Ticks + 3));

            this.Source   = Source;
            this.Barriers = Barriers;

            // Populate the list of agents with random positions and velocities.
            Agents = new List <Agent>(NumberOfAgents);
            for (int i = 0; i < NumberOfAgents; i++)
            {
                Agents.Add(new Agent(
                               PXRandomGenerator.NextDouble(),
                               PYRandomGenerator.NextDouble(),
                               VXRandomGenerator.NextDouble(),
                               VYRandomGenerator.NextDouble(),
                               Source.GetRadiation,
                               Send
                               ));
            }
        }