Esempio n. 1
0
        public Bomb(Agent agentParent, int id)
        {
            m_ID = id;
            this.m_AgentParent = agentParent;

            //to trace bombs parent
            m_AgentIdTag = agentParent.Id;

            m_World = agentParent.World;

            //inherits parents position
            this.m_Position = agentParent.Position;

            //heading is initially 0
            Heading = 0.0f;

            //load model
            loadContent(agentParent.World.Content, "bomb");
            m_Position = agentParent.Position;

            //velocity, acceleration, speed are initially zero
            Velocity = Vector3.Zero;
            Acceleration = Vector3.Zero;
            Speed = 0.0f;

            //init max speed
            //?MaxSpeed = Bann.MAX_SPEED;

            //lifetime initialy set to 3000 ( 3 seconds )
            LifeTime = 1500;

            //sensory radius will be range of bomb
            /*
             *          |
             *          |
             *       ---o---
             *          |
             *          |
             *
            */
            SensoryRadius = (float)Bomb.RADIUS;

            //logic to figure out what gets hit in explosion to be done
            // using all objects in a range and check if they
            //collide with 2 rectangles looks to be the best way
        }
Esempio n. 2
0
        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;
        }
Esempio n. 3
0
        /// <summary>
        /// 
        /// </summary>
        protected void InitializePlayGameTraining()
        {
            //instantiate a new map
            m_World = new Map(Content, "Maps//Map1.ini");

            //set the state to running
            m_CurrentPlayGameState = PlayGameState.Running;

            m_World.AverageFitness = new List<double>();
            m_World.BestFitness = new List<double>();
            int numWeights = ((Agent)m_World.Agents[0]).Brain.GetNumberWeights();
            List<int> splitPoints = ((Agent)m_World.Agents[m_World.NumAgents - 1]).Brain.CalculateSplitPoints();
            m_World.GeneticAlgorithm = new AgentGA(Params.POP_SIZE, Params.MUTATION_RATE, Params.CROSSOVER_RATE, numWeights, splitPoints);
            m_World.GenomePopulation = m_World.GeneticAlgorithm.Population;
            for (int i = 0; i < m_World.Agents.Count; i++)
            {
                ((Agent)m_World.Agents[i]).Brain.PutWeights(m_World.GenomePopulation[i].Weights);
            }

            ResetTrainingStrings();
        }
Esempio n. 4
0
        /// <summary>
        /// 
        /// </summary>
        protected void InitializePlayGamePerson()
        {
            //create the new map
            LevelGenerator LG = new LevelGenerator();
            LG.genLevel();
            m_World = new Map(Content, "Maps\\MapRand.ini");

            m_CurrentPlayGameState = PlayGameState.Running;

            //init game over flag
            m_GameOverFlag = false;
            m_WinFlag = false;
        }