public AirTrafficController(
            System.Guid _id,
            cessna_digital_twin.AgentLayer _layer,
            Mars.Interfaces.Layer.RegisterAgent _register,
            Mars.Interfaces.Layer.UnregisterAgent _unregister,
            Mars.Components.Environments.GeoHashEnvironment <AirTrafficController> _AirTrafficControllerEnvironment,
            double xcor = 0, double ycor = 0, int freq = 1)
        {
            _AgentLayer = _layer;
            ID          = _id;
            Position    = Mars.Interfaces.Environment.Position.CreatePosition(xcor, ycor);
            _Random     = new System.Random(ID.GetHashCode());
            _AgentLayer._AirTrafficControllerEnvironment.Insert(this);
            _register(_layer, this, freq);
            _isAlive            = true;
            _executionFrequency = freq;
            {
                initialize_general_values();
                double x_spawn = 9.501334;
                double y_spawn = 53.559712;
                new System.Func <System.Tuple <double, double> >(() => {
                    var _taget2837_88873 = new System.Tuple <double, double>(x_spawn, y_spawn);

                    var _object2837_88873 = this;

                    _AgentLayer._AirTrafficControllerEnvironment.PosAt(_object2837_88873,
                                                                       _taget2837_88873.Item1, _taget2837_88873.Item2
                                                                       );
                    return(new Tuple <double, double>(Position.X, Position.Y));
                }).Invoke();
                request_approval         = false;
                available_runway_heading = airportstade.Get_available_runway_heading_list()
                ;
            }
        }
示例#2
0
        public Wallaby(
            System.Guid _id,
            rugby_sim.Grassland _layer,
            Mars.Interfaces.Layer.RegisterAgent _register,
            Mars.Interfaces.Layer.UnregisterAgent _unregister,
            Mars.Components.Environments.SpatialHashEnvironment <Wallaby> _WallabyEnvironment,
            int speed
            , double xcor = 0, double ycor = 0, int freq = 1)
        {
            _Grassland = _layer;
            ID         = _id;
            Position   = Mars.Interfaces.Environment.Position.CreatePosition(xcor, ycor);
            _Random    = new System.Random(ID.GetHashCode());
            this.speed = speed;
            _Grassland._WallabyEnvironment.Insert(this);
            _register(_layer, this, freq);
            _isAlive            = true;
            _executionFrequency = freq;
            {
                new System.Func <System.Tuple <double, double> >(() => {
                    var _taget15_245 = new System.Tuple <int, int>(_Random.Next(250),
                                                                   5);

                    var _object15_245 = this;

                    _Grassland._WallabyEnvironment.PosAt(_object15_245,
                                                         _taget15_245.Item1, _taget15_245.Item2
                                                         );
                    return(new Tuple <double, double>(Position.X, Position.Y));
                }).Invoke();
                has_ball = true;
                speed    = 1
                ;
            }
        }
 public Weather(
     System.Guid _id,
     cessna_digital_twin.AgentLayer _layer,
     Mars.Interfaces.Layer.RegisterAgent _register,
     Mars.Interfaces.Layer.UnregisterAgent _unregister,
     Mars.Components.Environments.GeoHashEnvironment <Weather> _WeatherEnvironment,
     double gravity,
     double wind_bearing,
     double wind_speed,
     double temperature,
     double pressure_QNH
     , double xcor = 0, double ycor = 0, int freq = 1)
 {
     _AgentLayer       = _layer;
     ID                = _id;
     Position          = Mars.Interfaces.Environment.Position.CreatePosition(xcor, ycor);
     _Random           = new System.Random(ID.GetHashCode());
     this.gravity      = gravity;
     this.wind_bearing = wind_bearing;
     this.wind_speed   = wind_speed;
     this.temperature  = temperature;
     this.pressure_QNH = pressure_QNH;
     _AgentLayer._WeatherEnvironment.Insert(this);
     _register(_layer, this, freq);
     _isAlive            = true;
     _executionFrequency = freq;
     {
     }
 }
 public Observer(
     System.Guid _id,
     cessna_digital_twin.AgentLayer _layer,
     Mars.Interfaces.Layer.RegisterAgent _register,
     Mars.Interfaces.Layer.UnregisterAgent _unregister,
     Mars.Components.Environments.GeoHashEnvironment <Observer> _ObserverEnvironment,
     int number_of_spawning_points,
     int print_interval
     , double xcor = 0, double ycor = 0, int freq = 1)
 {
     _AgentLayer = _layer;
     ID          = _id;
     Position    = Mars.Interfaces.Environment.Position.CreatePosition(xcor, ycor);
     _Random     = new System.Random(ID.GetHashCode());
     this.number_of_spawning_points = number_of_spawning_points;
     this.print_interval            = print_interval;
     _AgentLayer._ObserverEnvironment.Insert(this);
     _register(_layer, this, freq);
     _isAlive            = true;
     _executionFrequency = freq;
     {
         state_list = (new Mars.Components.Common.MarsList <string>()
         {
             "Initialization", "PreflightInspection", "StartingEngine", "TakeOffPreparationRequest", "Taxiing", "TakeOffPreparation", "TakeOffHoldShortRequest", "TakeOffRequest", "TakeOff", "Climb", "LeavingFrequencyRequest", "LandingRequest", "GoAround", "Landing", "LeavingFrequency"
         });
         available_runway_heading = airportstade.Get_available_runway_heading_list();
         initialize_spawn_cor()
         ;
     }
 }
        public override bool InitLayer(
            Mars.Interfaces.Layer.Initialization.TInitData initData,
            Mars.Interfaces.Layer.RegisterAgent regHandle,
            Mars.Interfaces.Layer.UnregisterAgent unregHandle)
        {
            base.InitLayer(initData, regHandle, unregHandle);
            this._Register   = regHandle;
            this._Unregister = unregHandle;

            _InitGrid(initData);
            this._AllBlackEnvironment = new Mars.Components.Environments.SpatialHashEnvironment <AllBlack>(_dimensionX, _dimensionY, true);
            this._WallabyEnvironment  = new Mars.Components.Environments.SpatialHashEnvironment <Wallaby>(_dimensionX, _dimensionY, true);

            _AllBlackAgents = Mars.Components.Services.AgentManager.SpawnAgents <AllBlack>(
                initData.AgentInitConfigs.First(config => config.Type == typeof(AllBlack)),
                regHandle, unregHandle,
                new System.Collections.Generic.List <Mars.Interfaces.Layer.ILayer> {
                this
            });
            _WallabyAgents = Mars.Components.Services.AgentManager.SpawnAgents <Wallaby>(
                initData.AgentInitConfigs.First(config => config.Type == typeof(Wallaby)),
                regHandle, unregHandle,
                new System.Collections.Generic.List <Mars.Interfaces.Layer.ILayer> {
                this
            });

            return(true);
        }
示例#6
0
        public AllBlack(
            System.Guid _id,
            rugby_sim.Grassland _layer,
            Mars.Interfaces.Layer.RegisterAgent _register,
            Mars.Interfaces.Layer.UnregisterAgent _unregister,
            Mars.Components.Environments.SpatialHashEnvironment <AllBlack> _AllBlackEnvironment,
            double speed
            , double xcor = 0, double ycor = 0, int freq = 1)
        {
            _Grassland = _layer;
            ID         = _id;
            Position   = Mars.Interfaces.Environment.Position.CreatePosition(xcor, ycor);
            _Random    = new System.Random(ID.GetHashCode());
            this.speed = speed;
            _Grassland._AllBlackEnvironment.Insert(this);
            _register(_layer, this, freq);
            _isAlive            = true;
            _executionFrequency = freq;
            {
                System.Console.WriteLine("Initializing");;
                new System.Func <System.Tuple <double, double> >(() => {
                    var _taget49_637 = new System.Tuple <int, int>(_Random.Next(200),
                                                                   _Random.Next(10)
                                                                   );

                    var _object49_637 = this;

                    _Grassland._AllBlackEnvironment.PosAt(_object49_637,
                                                          _taget49_637.Item1, _taget49_637.Item2
                                                          );
                    return(new Tuple <double, double>(Position.X, Position.Y));
                }).Invoke();
                speed = 0.2
                ;
            }
        }
示例#7
0
        public override bool InitLayer(
            Mars.Interfaces.Layer.Initialization.TInitData initData,
            Mars.Interfaces.Layer.RegisterAgent regHandle,
            Mars.Interfaces.Layer.UnregisterAgent unregHandle)
        {
            base.InitLayer(initData, regHandle, unregHandle);
            this._Register   = regHandle;
            this._Unregister = unregHandle;

            _DistanceMetric = Mars.Mathematics.SpaceDistanceMetric.Chebyshev;
            var _gisLayerExist = false;

            if (!_isDefault && _lowerLeft != null && _upperRight != null)
            {
                this._AirTrafficControllerEnvironment = Mars.Components.Environments.GeoHashEnvironment <AirTrafficController> .BuildByBBox(_lowerLeft.Longitude, _lowerLeft.Latitude, _upperRight.Longitude, _upperRight.Latitude);

                this._AircraftEnvironment = Mars.Components.Environments.GeoHashEnvironment <Aircraft> .BuildByBBox(_lowerLeft.Longitude, _lowerLeft.Latitude, _upperRight.Longitude, _upperRight.Latitude);

                this._ObserverEnvironment = Mars.Components.Environments.GeoHashEnvironment <Observer> .BuildByBBox(_lowerLeft.Longitude, _lowerLeft.Latitude, _upperRight.Longitude, _upperRight.Latitude);

                this._PilotEnvironment = Mars.Components.Environments.GeoHashEnvironment <Pilot> .BuildByBBox(_lowerLeft.Longitude, _lowerLeft.Latitude, _upperRight.Longitude, _upperRight.Latitude);

                this._WeatherEnvironment = Mars.Components.Environments.GeoHashEnvironment <Weather> .BuildByBBox(_lowerLeft.Longitude, _lowerLeft.Latitude, _upperRight.Longitude, _upperRight.Latitude);
            }
            else if (_gisLayerExist)
            {
                var geometries = new List <GeoAPI.Geometries.IGeometry>();
                var _factory   = new NetTopologySuite.Utilities.GeometricShapeFactory();
                var _feature   = new NetTopologySuite.Geometries.GeometryCollection(geometries.ToArray()).EnvelopeInternal;
                _minLon = _feature.MinX;
                _minLat = _feature.MinY;
                _maxLon = _feature.MaxX;
                _maxLat = _feature.MaxY;

                this._AirTrafficControllerEnvironment = Mars.Components.Environments.GeoHashEnvironment <AirTrafficController>
                                                        .BuildByBBox(_feature.MinX, _feature.MinY, _feature.MaxX, _feature.MaxY);

                this._AircraftEnvironment = Mars.Components.Environments.GeoHashEnvironment <Aircraft>
                                            .BuildByBBox(_feature.MinX, _feature.MinY, _feature.MaxX, _feature.MaxY);

                this._ObserverEnvironment = Mars.Components.Environments.GeoHashEnvironment <Observer>
                                            .BuildByBBox(_feature.MinX, _feature.MinY, _feature.MaxX, _feature.MaxY);

                this._PilotEnvironment = Mars.Components.Environments.GeoHashEnvironment <Pilot>
                                         .BuildByBBox(_feature.MinX, _feature.MinY, _feature.MaxX, _feature.MaxY);

                this._WeatherEnvironment = Mars.Components.Environments.GeoHashEnvironment <Weather>
                                           .BuildByBBox(_feature.MinX, _feature.MinY, _feature.MaxX, _feature.MaxY);
            }
            else if (_lowerLeft != null && _upperRight != null)
            {
                this._AirTrafficControllerEnvironment = Mars.Components.Environments.GeoHashEnvironment <AirTrafficController> .BuildByBBox(_lowerLeft.Longitude, _lowerLeft.Latitude, _upperRight.Longitude, _upperRight.Latitude);

                this._AircraftEnvironment = Mars.Components.Environments.GeoHashEnvironment <Aircraft> .BuildByBBox(_lowerLeft.Longitude, _lowerLeft.Latitude, _upperRight.Longitude, _upperRight.Latitude);

                this._ObserverEnvironment = Mars.Components.Environments.GeoHashEnvironment <Observer> .BuildByBBox(_lowerLeft.Longitude, _lowerLeft.Latitude, _upperRight.Longitude, _upperRight.Latitude);

                this._PilotEnvironment = Mars.Components.Environments.GeoHashEnvironment <Pilot> .BuildByBBox(_lowerLeft.Longitude, _lowerLeft.Latitude, _upperRight.Longitude, _upperRight.Latitude);

                this._WeatherEnvironment = Mars.Components.Environments.GeoHashEnvironment <Weather> .BuildByBBox(_lowerLeft.Longitude, _lowerLeft.Latitude, _upperRight.Longitude, _upperRight.Latitude);
            }
            else
            {
                throw new ArgumentException("No environment boundary was used for agent layer 'TestLayer'");
            }

            _AirTrafficControllerAgents = Mars.Components.Services.AgentManager.SpawnAgents <AirTrafficController>(
                initData.AgentInitConfigs.First(config => config.Type == typeof(AirTrafficController)),
                regHandle, unregHandle,
                new System.Collections.Generic.List <Mars.Interfaces.Layer.ILayer> {
                this
            });
            _AircraftAgents = Mars.Components.Services.AgentManager.SpawnAgents <Aircraft>(
                initData.AgentInitConfigs.First(config => config.Type == typeof(Aircraft)),
                regHandle, unregHandle,
                new System.Collections.Generic.List <Mars.Interfaces.Layer.ILayer> {
                this
            });
            _ObserverAgents = Mars.Components.Services.AgentManager.SpawnAgents <Observer>(
                initData.AgentInitConfigs.First(config => config.Type == typeof(Observer)),
                regHandle, unregHandle,
                new System.Collections.Generic.List <Mars.Interfaces.Layer.ILayer> {
                this
            });
            _PilotAgents = Mars.Components.Services.AgentManager.SpawnAgents <Pilot>(
                initData.AgentInitConfigs.First(config => config.Type == typeof(Pilot)),
                regHandle, unregHandle,
                new System.Collections.Generic.List <Mars.Interfaces.Layer.ILayer> {
                this
            });
            _WeatherAgents = Mars.Components.Services.AgentManager.SpawnAgents <Weather>(
                initData.AgentInitConfigs.First(config => config.Type == typeof(Weather)),
                regHandle, unregHandle,
                new System.Collections.Generic.List <Mars.Interfaces.Layer.ILayer> {
                this
            });

            return(true);
        }
        public Human(
            System.Guid _id,
            VirusSpreading.City _layer,
            Mars.Interfaces.Layer.RegisterAgent _register,
            Mars.Interfaces.Layer.UnregisterAgent _unregister,
            Mars.Components.Environments.SpatialHashEnvironment <Human> _HumanEnvironment,
            int Human_gain_by_age,
            int Vulnerable_class_ratio,
            int Obey_ratio,
            int Government_announce_date,
            int Initial_infected_rate,
            int Infection_rate1,
            int Infection_rate2
            , double xcor = 0, double ycor = 0, int freq = 1)
        {
            _City    = _layer;
            ID       = _id;
            Position = Mars.Interfaces.Environment.Position.CreatePosition(xcor, ycor);
            _Random  = new System.Random(ID.GetHashCode());
            this.Human_gain_by_age        = Human_gain_by_age;
            this.Vulnerable_class_ratio   = Vulnerable_class_ratio;
            this.Obey_ratio               = Obey_ratio;
            this.Government_announce_date = Government_announce_date;
            this.Initial_infected_rate    = Initial_infected_rate;
            this.Infection_rate1          = Infection_rate1;
            this.Infection_rate2          = Infection_rate2;
            _City._HumanEnvironment.Insert(this);
            _register(_layer, this, freq);
            _isAlive            = true;
            _executionFrequency = freq;
            {
                new System.Func <System.Tuple <double, double> >(() => {
                    var _taget35_1049 = new System.Tuple <int, int>(_Random.Next(city.DimensionX()
                                                                                 ),
                                                                    _Random.Next(city.DimensionY()
                                                                                 )
                                                                    );

                    var _object35_1049 = this;

                    _City._HumanEnvironment.PosAt(_object35_1049,
                                                  _taget35_1049.Item1, _taget35_1049.Item2
                                                  );
                    return(new Tuple <double, double>(Position.X, Position.Y));
                }).Invoke();
                R0        = 0;
                Ticks     = 0;
                LossTicks = 0;
                int Class = _Random.Next(100);
                if (Class < Vulnerable_class_ratio)
                {
                    {
                        Energy     = _Random.Next(Human_gain_by_age);
                        Vulnerable = true
                        ;
                    }
                    ;
                }
                else
                {
                    {
                        Energy = _Random.Next(Human_gain_by_age)
                                 + 40
                        ;
                    }
                    ;
                };
                int infect = _Random.Next(100);
                if (infect < Initial_infected_rate)
                {
                    {
                        Infected = true
                        ;
                    }
                    ;
                }
                ;
            }
        }