Esempio n. 1
0
    /// <summary>
    /// Used to set up the defender type tree
    /// </summary>
    void SetupDefender()
    {
        DecisionNode isHealthLow       = new DecisionNode(Decisions.Shared_IsHealthLow, this);
        ActionNode   findPickup        = new ActionNode(Actions.Shared_SearchForHealthpack, this);
        DecisionNode enemyInRadiusNode = new DecisionNode(Decisions.Shared_IsEnemyInAttackRadius, this);

        isHealthLow.AddSuccessNode(findPickup);
        isHealthLow.AddFailureNode(enemyInRadiusNode);

        DecisionNode enemyHasFlag = new DecisionNode(Decisions.Defender_DoesEnemyHaveTeamFlag, this);
        ActionNode   attackTarget = new ActionNode(Actions.Shared_AttackEnemyTarget, this);

        enemyInRadiusNode.AddFailureNode(enemyHasFlag);
        enemyInRadiusNode.AddSuccessNode(attackTarget);

        ActionNode   attackEnemyWithFlag = new ActionNode(Actions.Defender_AttackEnemyWithTeamFlag, this);
        DecisionNode teamFlagOutsideBase = new DecisionNode(Decisions.Defender_IsTeamFlagOutsideBase, this);

        enemyHasFlag.AddSuccessNode(attackEnemyWithFlag);
        enemyHasFlag.AddFailureNode(teamFlagOutsideBase);

        DecisionNode hasTeamFlagInside  = new DecisionNode(Decisions.Defender_HasFriendlyFlag, this);
        DecisionNode hasTeamFlagOutside = new DecisionNode(Decisions.Defender_HasFriendlyFlag, this);

        teamFlagOutsideBase.AddFailureNode(hasTeamFlagInside);
        teamFlagOutsideBase.AddSuccessNode(hasTeamFlagOutside);

        DecisionNode hasSpottedEnemy = new DecisionNode(Decisions.Shared_HasSeenEnemy, this);
        ActionNode   dropTeamFlag    = new ActionNode(Actions.Defender_DropTeamFlag, this);

        hasTeamFlagInside.AddFailureNode(hasSpottedEnemy);
        hasTeamFlagInside.AddSuccessNode(dropTeamFlag);

        ActionNode goToTeamBase = new ActionNode(Actions.Defender_ReturnToBase, this);
        ActionNode attackEnemy  = new ActionNode(Actions.Shared_AttackEnemyTarget, this);

        hasSpottedEnemy.AddFailureNode(goToTeamBase);
        hasSpottedEnemy.AddSuccessNode(attackEnemy);

        DecisionNode teamMateHasFriendlyFlag = new DecisionNode(Decisions.Shared_TeamHasFriendlyFlag, this);

        hasTeamFlagOutside.AddFailureNode(teamMateHasFriendlyFlag);
        hasTeamFlagOutside.AddSuccessNode(goToTeamBase);

        ActionNode   collectFriendlyFlag            = new ActionNode(Actions.Defender_CollectFriendlyFlag, this);
        DecisionNode hasSpottedEnemyNearFlagCarrier = new DecisionNode(Decisions.Shared_HasSeenEnemy, this);

        teamMateHasFriendlyFlag.AddSuccessNode(hasSpottedEnemyNearFlagCarrier);
        teamMateHasFriendlyFlag.AddFailureNode(collectFriendlyFlag);

        ActionNode followTeamFlagCarrier = new ActionNode(Actions.Defender_FollowTeamMateWithFlag, this);

        hasSpottedEnemyNearFlagCarrier.AddSuccessNode(attackEnemy);
        hasSpottedEnemyNearFlagCarrier.AddFailureNode(followTeamFlagCarrier);

        decTree = new DecisionTree(isHealthLow);
    }
Esempio n. 2
0
    /// <summary>
    /// Used to set up the attacker type tree
    /// </summary>
    void SetupAttacker()
    {
        DecisionNode hasFlagNode = new DecisionNode(Decisions.Attacker_HasEnemyFlag, this);

        DecisionNode teamHasEnemyFlagNode = new DecisionNode(Decisions.Shared_TeamHasEnemyFlag, this);
        ActionNode   runBackAndScore      = new ActionNode(Actions.Attacker_GoBackToTeamFlag, this);

        hasFlagNode.AddFailureNode(teamHasEnemyFlagNode);
        hasFlagNode.AddSuccessNode(runBackAndScore);

        DecisionNode enemyInRadiusNode       = new DecisionNode(Decisions.Shared_IsEnemyInAttackRadius, this);
        DecisionNode enemySpottedNotInRadius = new DecisionNode(Decisions.Shared_HasSeenEnemy, this);

        teamHasEnemyFlagNode.AddFailureNode(enemyInRadiusNode);
        teamHasEnemyFlagNode.AddSuccessNode(enemySpottedNotInRadius);

        ActionNode attackTarget           = new ActionNode(Actions.Shared_AttackEnemyTarget, this);
        ActionNode followTeamMateWithFlag = new ActionNode(Actions.Shared_FollowTeamMateWithFlag, this);

        enemySpottedNotInRadius.AddSuccessNode(attackTarget);
        enemySpottedNotInRadius.AddFailureNode(followTeamMateWithFlag);

        DecisionNode isHealthLow = new DecisionNode(Decisions.Shared_IsHealthLow, this);
        ActionNode   findPickup  = new ActionNode(Actions.Shared_SearchForHealthpack, this);

        enemyInRadiusNode.AddFailureNode(isHealthLow);
        enemyInRadiusNode.AddSuccessNode(attackTarget);

        DecisionNode canTakeEnemyFlag = new DecisionNode(Decisions.Attacker_CanTakeEnemyFlag, this);

        isHealthLow.AddFailureNode(canTakeEnemyFlag);
        isHealthLow.AddSuccessNode(findPickup);

        ActionNode moveToEnemyFlag = new ActionNode(Actions.Attacker_MoveToEnemyFlag, this);
        ActionNode takeEnemyFlag   = new ActionNode(Actions.Attacker_TakeEnemyFlag, this);

        canTakeEnemyFlag.AddSuccessNode(takeEnemyFlag);
        canTakeEnemyFlag.AddFailureNode(moveToEnemyFlag);

        decTree = new DecisionTree(hasFlagNode);
    }