public void Move(double time, bool abnormalEvent, RouteClassifier rc) { if (abnormalEvent) { if (!_abnormalEvent) { _abnormalEvent = true; _crashedPosition = new Position(_currentPosition.X, _currentPosition.Y);; } // TODO if (_agentType == 0) { EstimatedMove(time, rc); } else { Move(time); // Real Agent } //Move(time); // Simulated Agent } else { _abnormalEvent = false; _crashedPosition = null; Move(time); } }
public ScenarioManager(string xmlFilePath) { Initalize(); XmlDocument xmlDoc = new XmlDocument(); try { xmlDoc.Load(xmlFilePath); } catch (System.Exception ex) { throw new Exception(ex.Message + " Xml Load Error: There is no file that you want to load."); } XmlNode rootNode = xmlDoc.SelectSingleNode("ObjectList"); MapSizeX = Int32.Parse(rootNode.Attributes["MapSizeX"].Value); MapSizeY = Int32.Parse(rootNode.Attributes["MapSizeY"].Value); HandleShips(rootNode.SelectSingleNode("ShipList")); HandleObscles(rootNode.SelectSingleNode("ObstcleList")); HandleColors(rootNode.SelectSingleNode("ColorList")); // TODO //Initalize RouteClassifier _rc = new RouteClassifier(xmlFilePath); }
public void EstimatedMove(double time, RouteClassifier rc) { Position targetPosition; string next_data = rc.GetNextPoint(AgentID); if (next_data != "no matching") { char[] delimiter = { ',' }; string [] token = next_data.Split(delimiter); targetPosition = new Position(Double.Parse(token[0]), Double.Parse(token[1])); } else { targetPosition = new Position(_currentPosition.X, _currentPosition.Y); } _prevPosition.X = _currentPosition.X; _prevPosition.Y = _currentPosition.Y; // X Move : total distance if ((targetPosition.X - _currentPosition.X) < 0) { _currentPosition.X -= AgentSpeed * time; } else { _currentPosition.X += AgentSpeed * time; } // Y Move if ((targetPosition.Y - _currentPosition.Y) < 0) { _currentPosition.Y -= AgentSpeed * time; } else { _currentPosition.Y += AgentSpeed * time; } rc.SetNextWaypoint(AgentID, (int)_currentPosition.X, (int)_currentPosition.Y); }