public Agent(Map world, int id, bool outputGenes) : base() { //heading is initially 0 m_Heading = 0.0f; //side is 90 degrees CW from heading m_Side = m_Heading - (float)Math.PI / 2.0f; //velocity, acceleration, speed are initially zero m_Velocity = Vector3.Zero; m_Acceleration = Vector3.Zero; m_Speed = 0.0f; m_TurnAmount = 0.0f; //init max speed m_MaxSpeed = MAX_SPEED; m_AgentAdjacencyList = new List<Tuple<Agent, float, float>>(); //agent is initially inactive m_IsActive = false; //sensory radius for adjacent agents and pie slice m_SensoryRadius = 400; //do no initially output info m_OutputAdjacentAgents = false; m_OutputInfo = false; m_OutputRayInfo = false; //init agent's id this.m_ID = id; m_SteeringBehaviors = new SteeringBehaviors(this); m_World = world; m_Brain = new NeuralNetwork(); m_OutputGenes = outputGenes; if (m_OutputGenes == true) { m_GeneticFile = new System.IO.StreamWriter("Agent" + Id + ".gene"); } m_MemoryOutputs = new List<double>(); m_MemoryOutputs.Add(0); m_MemoryOutputs.Add(0); m_MemoryOutputs.Add(0); m_MemoryOutputs.Add(0); m_Fitness = 0; //init rangefinder list InitializeRangefinderWalls(); InitializeRangefinderBlocks(); //init pie slices InitializePieSliceSensors(); //init node adj list InitializeAdjacencyListNodes(); //init state is navigate m_CurrentState = new State_Navigate(); m_NavDelay = DateTime.Now; //begin invulnerability timer m_Invuln = true; m_InvulnTimer = DateTime.Now.AddSeconds(12); // Initialize the Escape node to null to set it later m_EscapeNode = null; m_StartingLocation = Vector3.Up; m_MovementSpeed = MAX_SPEED; m_TurnSpeed = MAX_TURN_SPEED; }
/// <summary> /// Transition to appropriate state. /// </summary> /// <param name="newState">State to transition to.</param> public void ChangeState(State newState) { m_CurrentState = newState; }