private void FollowingMovement() { // If follower is waiting (tactile contact with tandem leader) do not update movement if (ShouldTandemFollowerWait() == true) { return; } // If the follower has line of sight of the leader (within antennal contact range) then turn to face them if (ant.LineOfSight(ant.leader) == true) { WalkToGameObject(ant.leader.gameObject, false); ResetTurnParameters(moreFrequentTurns: true); } // Update direction only if the required time has elapsed if (simulation.TotalElapsedSimulatedTime("s") >= nextTurnTime) { // If this is the first follower movement estimated leader position is not yet set, move ant towards leader if (ant.estimateNewLeaderPos == Vector3.zero) { ant.estimateNewLeaderPos = ant.leader.transform.position; } // The follower must walk towards where they predict the leader is float predictedLeaderAngle = AngleToFacePosition(ant.estimateNewLeaderPos); float newDirection = RandomGenerator.Instance.NormalRandom(predictedLeaderAngle, maxVarFollower); TurnAnt(newDirection); ResetTurnParameters(moreFrequentTurns: true); } // Move forward at the required speed (if there are no obstructions) MoveForward(Speed.v[Speed.TandemRunFollow], false);//? }
private bool CanOtherAntBeRecruited() { // Assessing and following ants can't be recruited // The other ant cannot be recruited if: // - It is in the assessing or following state // - It already has the same nest allegiance as this ant // - Cannot be seen by this ant if (otherAnt.state == BehaviourState.Assessing || otherAnt.state == BehaviourState.Following || otherAnt.myNest == ant.myNest || ant.LineOfSight(otherAnt) == false) { return(false); } // If the other ant is a recruiter, use the probability parameters to test if it can be recruited. if (otherAnt.state == BehaviourState.Recruiting || otherAnt.state == BehaviourState.Reversing) { float r = RandomGenerator.Instance.Range(0f, 1f); float probability = AntScales.Other.tandRecSwitchProb; if (otherAnt.IsQuorumReached()) { probability = AntScales.Other.carryRecSwitchProb; } if (r < probability) { return(true); } else { return(false); } } // All remaining cases are eligible for recruitment, but passive ants can only be carried return(true); }