public void Handling_Fight_Event_Distance_Medium_Attack_Type_Punch()
        {
            // make sure that in the event both the distance and the attack type are close the
            // resut will be that of a close and close respons

            //arrange
            AIFighter    attacker = new AIFighter(1);
            NonAIFighter defender = new NonAIFighter(1, false, false);

            IGameWorld gw = new GameWorld();

            //set up
            gw.Distance     = "Medium";
            attacker.Attack = new Punch();

            String expected = "AI-Fighter <<Punch>> Non-AI-Fighter <<MISSED>>";



            //act
            string actual = gw.wAttack(attacker, defender, attacker.Attack);

            //assert

            Assert.AreEqual(expected, actual, " the correct attack result was returned");
        }
        public void Handling_Fight_Event_Distance_Close_Attack_Type_Special()
        {
            // make sure that in the event both the distance and the attack type are close the
            // resut will be that of a close and close respons

            //arrange
            AIFighter    attacker = new AIFighter(1);
            NonAIFighter defender = new NonAIFighter(1, false, false);

            IGameWorld gw = new GameWorld();

            //set up
            gw.Distance     = "Close";
            attacker.Attack = new Special();

            String expected = "Close Damage: AI-Fighter <<Special Move>> Non-AI-Fighter <<For>> <-30>";



            //act
            string actual = gw.wAttack(attacker, defender, attacker.Attack);

            //assert

            Assert.AreEqual(expected, actual, " the correct attack result was returned");
        }
Пример #3
0
        //+++++++++++++++++++++++++++++New Code++++++++++++++++++++++++++++++++++
        /// <summary>
        /// Create an action node which is Punch attack type.
        /// modified Do (action) Node.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="AI">The ai.</param>
        /// <param name="NAI">The nai.</param>
        /// <returns></returns>
        /// <exception cref="System.ApplicationException">Can't create an unnested ActionNode, it must be a leaf node.</exception>
        public MyTreeBuilder Punch(GameWorld context, AIFighter AI, NonAIFighter NAI)
        {
            if (parentNodeStack.Count <= 0)
            {
                throw new ApplicationException("Can't create an unnested ActionNode, it must be a leaf node.");
            }

            Func <MyTimeData, MyBehaviourTreeStatus> fr;

            fr = t =>
            {
                // A Punch Attack
                Punch punch = new Punch();

                GameWorld gw = context;
                gw.wAttack(AI, NAI, punch);

                gw.ListOfEvents.Add("Punch non AI player");
                return(MyBehaviourTreeStatus.Success);
            };

            var actionNone = new ActionNode("Punch", fr);

            parentNodeStack.Peek().AddChild(actionNone);
            return(this);
        }/// <summary>
        /// <summary>
        /// Initializes a new instance of the <see cref="GeneticProgramming"/> class.
        /// </summary>
        /// <param name="gw">The gw.</param>
        /// <param name="AI">The ai.</param>
        /// <param name="NAI">The nai.</param>
        /// <param name="torniment_Size">Size of the torniment_.</param>
        /// <param name="pop_size">The pop_size.</param>
        public GeneticProgramming(GameWorld gw, AIFighter AI, NonAIFighter NAI, int torniment_Size, int pop_size)
        {
            generation  = new List <Indevidual>();
            mating_pool = new List <Indevidual>();

            this.gw  = gw;
            this.AI  = AI;
            this.NAI = NAI;

            Torniment_size  = torniment_Size;
            Population_size = pop_size;
        }
Пример #5
0
        /// <summary>
        /// Set up fighters for fight.
        /// </summary>
        /// <param name="isBlocking">if set to <c>true</c> [is blocking].</param>
        /// <param name="isCrouched">if set to <c>true</c> [is crouched].</param>
        /// <param name="torn_size"></param>
        /// <param name="pop_size"></param>
        public void SetUp(bool isBlocking, bool isCrouched, int torn_size, int pop_size) 
        {
            //reset the counters
            treeCounter = 0;
            fighterCounter = 0;
            roundNum = 0;

            ListEventsAlgorithm.Clear();
            ListOfEvents.Clear();

            listOfEvents.Add(":: SET-UP FIGHTERS ::");

            roundNum++;

            listOfEvents.Add("Round NO: " + roundNum);

            //CREATE new NON_AI_FIGHTER
            NoAiFighter = new NonAIFighter(roundNum, isBlocking, isCrouched);

            //set relevent values for NON_AI_FIGHTER
            //NoAiFighter.Blocking = isBlocking;
            //NoAiFighter.Crouching = isCrouched;
            //add new fighter o event list
            listOfEvents.Add(NoAiFighter.ToString());

            //CREATE new AI_FIGHTER
            AiFighter = new AIFighter(roundNum);

             //create a new connection to Genetic programming class
            gp = new GeneticProgramming(this, AiFighter, NoAiFighter,torn_size,pop_size);

            gp.Crouched = Crouched;
            gp.Close = Close;
            gp.Medium = Medium;
            gp.Far = Far;

            //set up the Genetic programming class
            gp.setup();

            //set tree to first in generation list
            treeCounter = 0;
            AiFighter.Tree = gp.Generation[treeCounter];

            //add AI fighter to list
            listOfEvents.Add(AiFighter.ToString());
        }
        public void Handling_Fight_Event_Distance_Far_Attack_Type_Special()
        {
            //arrange
            AIFighter    attacker = new AIFighter(1);
            NonAIFighter defender = new NonAIFighter(1, false, false);

            IGameWorld gw = new GameWorld();

            //set up
            gw.Distance     = "Far";
            attacker.Attack = new Special();

            String expected = "Far Damage: AI-Fighter <<Special Move>> Non-AI-Fighter <<For>> <-30>";

            //act
            string actual = gw.wAttack(attacker, defender, attacker.Attack);

            //assert
            Assert.AreEqual(expected, actual, "The correct attack result was returned");
        }
        public void Handling_Fight_Event_Distance_Close_Attack_Type_Punch_Blocking()
        {
            //arrange
            AIFighter    attacker = new AIFighter(1);
            NonAIFighter defender = new NonAIFighter(1, true, false);

            //Attack attack = attacker.GenAttack();

            IGameWorld gw = new GameWorld();

            //set up
            gw.Distance     = "Close";
            attacker.Attack = new Punch();

            String expected = "Close Damage: AI-Fighter <<Punch>> Non-AI-Fighter <<For>> <-5>";

            //act
            string actual = gw.wAttack(attacker, defender, attacker.Attack);

            //assert

            Assert.AreEqual(expected, actual, " the incorrect attack result was returned");
        }