public void Initialise(GraphicsDevice graphicsDevice) { this.GraphicsDevice = graphicsDevice; Centre = new Vector3(this.GraphicsDevice.Viewport.Width / 2, this.GraphicsDevice.Viewport.Height / 2, 0); for (int i = 0; i < MaxAiThreads; i++) { this.randoms[i] = new Random(); } BrainWeightings weightings; weightings.flockCentre = 5f; weightings.goal = 5f; weightings.nearestPeer = 5f; weightings.nearestObject = 10f; weightings.randomInitialVelocity = 10f; weightings.peerVelocity = 3f; AgentBrain agentBrain = new AgentBrain(weightings, 4f); Enumerable.Range(0, this.Agents.Length).Select(x => this.Agents[x] = new Agent(agentBrain, GetNextRandomPosition())).ToList(); Enumerable.Range(0, this.AllocatedPoints.Length).Select(x => this.AllocatedPoints[x] = new Vector3[4]).ToList(); }
public override void Initialize() { agentBody = GetComponent <AgentBrain>(); m_TargetArea = TargetArea.GetComponent <TargetFinderArea>(); numTargets = m_TargetArea.numTargets; }
public Agent AsexuallyReproduce() { Agent myPreciousOnlyChild = new Agent(); myPreciousOnlyChild.sprite = sprite; myPreciousOnlyChild.AgentBrain = AgentBrain.Copy(); return(myPreciousOnlyChild); }
void Start() { this.Body = Body.HumanoidBody; var moveBrain = new MoveBrain(this.GetComponent <NavMeshAgent>()); var attackBrain = new AttackBrain(); agentBrain = new AgentBrainModerate(this.gameObject, moveBrain, attackBrain); }
/// <summary> /// Initialize the agent. Can be called by event when button is clicked. /// </summary> public void BeginLearning() { envVars.total_correct = 0; envVars.num_things = 48; // how many things to learn, in this case is 48 hiragana characters bool optimistic = true; agent = new AgentBrain(envVars.num_things, optimistic); //ReadString(ref agent.value_table); brainMemory = new Agent.AgentMemory(2); mainRoutine = StartCoroutine(Act()); }
void OnTriggerExit(Collider other) { AgentBrain agent = other.transform.parent.GetComponent <AgentBrain>(); if (agent != null) { Task planningTask = agent.GetCurrentGridTask(); if (planningTask != null) { observable.unregisterObserver(Event.NON_DETERMINISTIC_OBSTACLE_CHANGED, planningTask); } } }
void OnTriggerEnter(Collider other) { AgentBrain agent = other.transform.parent.GetComponent <AgentBrain>(); if (agent != null) { Task planningTask = agent.GetCurrentGridTask(); if (planningTask != null) { observable.registerObserver(Event.NON_DETERMINISTIC_OBSTACLE_CHANGED, planningTask); planningTask.setTaskPriority(TaskPriority.RealTime); // first time we saw this guy } } }
public void PopulateBumblr(GameObject bee) { //populate with agent stuff AgentBase beeAgent = bee.GetComponent <AgentBase>(); AgentBrain beeBrain = bee.GetComponent <AgentBrain>(); beeNameTxt.text = beeAgent.info.name; beeAgeTxt.text = beeAgent.info.capacity.ToString(); beePhysicalTxt.text = beeAgent.info.trait; beeTaskTxt.text = beeBrain.currentTask.type.ToString(); beeBumblrTxt.text = "BumblrText"; //for(int i = 0; i < beeAgent.bumblrText.Count; i++) //{ // PrintToBumblr(beeAgent.bumblrText[i]); //} }
public void Update(List <EnemyPlanet> enemies, BoundingSphere centerLimit, GameTime gt) { if (Alive) { if (AgentBrain.FeedFoward(genInputs(enemies))[0] > 0.5f) { Radius += (VerticalSpeed * (float)gt.ElapsedGameTime.TotalSeconds); } position = new Vector2(centerOfAttraction.X + (float)Math.Cos(Angle) * Radius, centerOfAttraction.Y + (float)Math.Sin(Angle) * Radius); boundingSphere = new BoundingSphere(new Vector3(position, 0), Size); Angle = ((Angle + Speed * (float)gt.ElapsedGameTime.TotalSeconds) % (2 * Math.PI)); if (Radius >= 430) { Radius = 430; Speed = 1.5f; } else if (Radius > 300) { Speed = 2.0f; counter += 2 * (float)gt.ElapsedGameTime.TotalSeconds; } else if (Radius > 200) { Speed = 2.5f; counter += 3 * (float)gt.ElapsedGameTime.TotalSeconds; } else if (Radius > 100) { Speed = 3; counter += 5 * (float)gt.ElapsedGameTime.TotalSeconds; } if (counter > threshold) { Score++; counter = 0; lastScoreIncrease = gt.TotalGameTime.TotalSeconds; } //kill agents if they haven't scored for 5 seconds if (gt.TotalGameTime.TotalSeconds - lastScoreIncrease > 5) { Alive = false; justDied = true; } Radius -= 200 * (float)gt.ElapsedGameTime.TotalSeconds; foreach (var enemy in enemies) { if (boundingSphere.Intersects(enemy.boundingSphere)) { Alive = false; justDied = true; } } if (boundingSphere.Intersects(centerLimit)) { Alive = false; justDied = true; } //Fitness = (float)Math.Pow((double)Score + counter / threshold, 2); if (Fitness == 0) { Fitness = Score + counter / threshold; } else { Fitness = (Score + counter / threshold + Fitness) / 2; } } else if (justDied) { diedAt = gt.TotalGameTime.TotalSeconds; //Fitness /= (float)runTime; justDied = false; } }
public Agent(AgentBrain brain, Vector3 position) { this.Position = position; this.Velocity = Vector3.Zero; this.Brain = brain; }