public Agent(string name, Color color, Point startPoint, int senseOfPurpose, Purpose purpose, int worship, Temper temper, int lifeCircle, Engine engine, int timeToStart) { _active = true; _name = name; _color = color; _startPoint = startPoint; InitTimeStep(); _senseOfPurpose = senseOfPurpose; _purpose = purpose; _worship = worship; _temper = temper; LifeCircle = lifeCircle; _timeToStart = timeToStart; Engine = engine; EndOfLife = false; _startTime = DateTime.Now; _idMessage = 0; _oldMessage = null; _newMessage = null; _registred = false; _space = new List <PointState>(); Length = 10; CalculateResponceTime(); InitCountAttempt(); Environment.EnvironmentMessage += ReceiveMessage; }
public void Clear() { _space.Clear(); _name = ""; _color = new Color(); _senseOfPurpose = 0; _purpose = null; _worship = 0; _temper = Temper.Сангвінік; _lifeCircle = 0; _timePause = 0; responceTime.Clear(); responceTime = null; _countAttempt = 0; _id = 0; _endOfLife = true; _engine = null; _startTime = DateTime.Now; _startPoint = new Point(); _space.Clear(); _space = null; _idMessage = 0; _oldMessage = null; _newMessage = null; _env = null; _registred = false; _denyEnvironment = true; _length = 0; listConfig.Clear(); listConfig = null; queue.Clear(); queue = null; GC.Collect(); }
public override bool Equals(object obj) { bool result = true; if (obj is Purpose) { Purpose tempObj = (Purpose)obj; result &= _importance.Equals(tempObj.Importance); result &= _worship.Equals(tempObj.Worship); if ((_entity is Point) && (tempObj.Entity is Point)) { Point _point = (Point)_entity; Point point = (Point)tempObj.Entity; result &= _point.Equals(point); } else { result &= _entity.Equals(tempObj.Entity); } } else { result = base.Equals(obj); } return(result); }
public AgentConfig(string name, Color color, int senseOfPurpose, Purpose purpose, int worship, Temper temper, double lifeCircle, int attempt, SortedList <TypeMessege, int> responceTime, Point startPoint, int length, List <List <Point> > listConfig) { Name = name; Color = color; SenseOfPurpose = senseOfPurpose; // Целеустремленность. Диапазон (0..100). Измеряется в процентах Purpose = purpose; // Цель, см. класс Purpose Worship = worship; // Вероисповедание. Диапазон (-100..100). -100 - агент антагонист любым вероучениям. 100 - полностью верующий агент. Temper = temper; // Характер. Значение по умолчанию Temper.Сангвінік LifeCircle = lifeCircle; // Время жизни агента. Если _lifeCircle = 0 - бессмертен. Время задается в милисекундах. Значение по умолчанию 0 - бессмертен. Attempt = attempt; // Количество попыток построить фигуру ResponceTime = responceTime; // Время выполнения (отклика) на каждое из действий агента StartPoint = startPoint; // Начальная точка фигуры Length = length; // Длина агента (линейки) ListConfig = listConfig; }
public Agent(string name, Color color, Point startPoint, int senseOfPurpose, Purpose purpose, int worship, Temper temper, int lifeCircle, Engine engine) : this(name, color, startPoint, senseOfPurpose, purpose, worship, temper, 0, new RealEngine(), 0) { }
public Agent(string name, Color color, Point startPoint, int senseOfPurpose, Purpose purpose, int worship, Temper temper) : this(name, color, startPoint, senseOfPurpose, purpose, worship, temper, 0) { }
public Agent(string name, Color color, Point startPoint, int senseOfPurpose, Purpose purpose, int worship) : this(name, color, startPoint, senseOfPurpose, purpose, worship, Temper.Сангвінік) { }
public Agent(string name, Color color, Point startPoint, int senseOfPurpose, Purpose purpose) : this(name, color, startPoint, senseOfPurpose, purpose, 20) { }
public EnvironmentMessage Clone() { Object obj = null; if (_entity == null) { _entity = new SendPoint(0, new Point()); } else if (_entity is Point) { Point temp = (Point)_entity; obj = new Point(temp.X, temp.Y); } else if (_entity is SendPoint) { SendPoint temp = (SendPoint)_entity; obj = new SendPoint(temp.ID, new Point(temp.Point.X, temp.Point.Y)); } else if (_entity is AgentConfig) { AgentConfig temp = (AgentConfig)_entity; Purpose tempPurpose = new Purpose(temp.Purpose.Importance, temp.Purpose.Worship, new Point(((Point)(temp.Purpose.Entity)).X, ((Point)(temp.Purpose.Entity)).Y)); SortedList <TypeMessege, int> tempSortedList = new SortedList <TypeMessege, int>(); List <List <Point> > listConfig = new List <List <Point> >(); if (temp.ListConfig != null) { List <Point> tempConfig; foreach (List <Point> config in temp.ListConfig) { tempConfig = new List <Point>(); foreach (Point point in tempConfig) { tempConfig.Add(point); } listConfig.Add(tempConfig); } } if (temp.ResponceTime != null) { foreach (var i in temp.ResponceTime) { tempSortedList.Add(i.Key, i.Value); } } Point tempPoint = new Point(temp.StartPoint.X, temp.StartPoint.Y); obj = new AgentConfig(temp.Name, temp.Color, temp.SenseOfPurpose, tempPurpose, temp.Worship, temp.Temper, temp.LifeCircle, temp.Attempt, tempSortedList, tempPoint, temp.Length, listConfig); } else if (_entity is EnvironmentConfig) { EnvironmentConfig temp = (EnvironmentConfig)_entity; Point tempPoint = new Point(temp.OffsetXY.X, temp.OffsetXY.Y); SortedList <TypeMessege, int> tempSortedList = new SortedList <TypeMessege, int>(); if (tempSortedList != null) { foreach (var i in temp.Response) { tempSortedList.Add(i.Key, i.Value); } } obj = new EnvironmentConfig(temp.Height, temp.Width, tempPoint, tempSortedList); } return(new EnvironmentMessage(_id, _idOwner, _typeMessege, _action, obj)); }