Пример #1
0
    private void RecruiterSenses()
    {
        // If the other ant is eligible for recruitment, then carry them if the quorum is reached, else attempt a tandem run
        if (CanOtherAntBeRecruited() == true)
        {
            if (ant.IsQuorumReached())
            {
                ant.PickUp(otherAnt);
                return;
            }
            else if (otherAnt.passive == false) // Only non-passive ants can follow a tandem run
            {
                ant.Lead(otherAnt);
                return;
            }
        }

        // Else the other ant was not able to be recruited
    }
Пример #2
0
    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);
    }