Example #1
0
        public Move MakeNextMove(Move opponentsLastMove, int myLastScore, int opponentsLastScore)
        {
            var move = new Move();

            if (opponentsLastMove != null)
            {
                Area[] legalAreas = { Area.Nose, Area.Jaw, Area.Belly, Area.Groin, Area.Legs };
                foreach (Area area in legalAreas)
                {
                    if (attack1 != area && move.Attacks.Count < 2)
                    {
                        move.AddAttack(area);
                        attack1 = area;
                    }
                    if (defence != area && move.Defences.Count < 1)
                    {
                        move.AddDefence(area);
                        defence = area;
                    }
                    if (attack2 != area && move.Attacks.Count < 2)
                    {
                        move.AddAttack(area);
                        attack2 = area;
                    }
                }
            }
            else
            {
                move
                .AddAttack(Area.Nose)
                .AddAttack(Area.Nose)
                .AddDefence(Area.Nose);
            }
            return(move);
        }
Example #2
0
        public Move MakeNextMove(Move opponentLastMove, int myLastScore, int oppLastScore)
        {
            myScoreTotal       += myLastScore;
            opponentScoreTotal += oppLastScore;

            Move move = new Move()
                        .AddAttack(attack1)
                        .AddAttack(attack2);

            if (opponentLastMove != null)
            {
                if (opponentLastMove.Attacks.Contains(defence) == false)
                {
                    defence = changeDefence(defence);
                }
            }

            if (myScoreTotal >= opponentScoreTotal)
            {
                move.AddAttack(createRandomAttack());     // 3 attacks, 0 defence
            }
            else
            {
                move.AddDefence(defence);                         // 2 attacks, 1 defence
            }
            return(move);
        }
Example #3
0
        private void CounterOpponentsLastMove(Move thisMove, Move opponentsLastMove)
        {
            List <Area> hisAttacks  = opponentsLastMove.Attacks.ToList <Area>();
            List <Area> hisDefenses = opponentsLastMove.Defences.ToList <Area>();

            foreach (Area ar in hisAttacks)
            {
                thisMove.AddDefence(ar);
            }
            foreach (Area ar in hisDefenses)
            {
                thisMove.AddAttack(ar);
            }
        }
Example #4
0
        public Move MakeNextMove(Move opponentLastMove, int myLastScore, int oppLastScore)
        {
            var move  = new Move();
            var areas = new[] { Area.Belly, Area.Nose, Area.Groin, Area.Jaw, Area.Legs };

            for (var i = 0; i < 3; i++)
            {
                var area = areas[_random.Next(5)];

                if (_random.NextDouble() < 0.25)
                {
                    move.AddDefence(area);
                }
                else
                {
                    move.AddAttack(area);
                }
            }

            return(move);
        }
Example #5
0
        public static Move ParseMove(string input)
        {
            Move rez = new Move();

            int index = 0;

            while (index < input.Length)
            {
                char type = input[index++];

                switch (type)
                {
                case 'a': rez.AddAttack(GetArea(input, index++)); break;

                case 'b': rez.AddDefence(GetArea(input, index++)); break;

                case 'c': rez.SetComment(input.Substring(index)); index = input.Length + 1; break;

                default:
                    throw new ArgumentException("Unrecognized input: " + type);
                }
            }
            return(rez);
        }
Example #6
0
        public Move MakeNextMove(Move opponentsLastMove, int myLastScore, int opponentsLastScore)
        {
            var    areas   = new[] { Area.Belly, Area.Nose, Area.Groin, Area.Jaw, Area.Legs };
            Move   move    = new Move();
            double random1 = new Random().NextDouble();
            double random2 = new Random().NextDouble();
            double random3 = new Random().NextDouble();

            if (opponentsLastMove == null)
            {
                return(move.AddAttack(Area.Jaw).AddAttack(Area.Belly).AddDefence(Area.Nose));
            }
            else
            {
                oppMoves.Add(opponentsLastMove);

                /*ataks[0] = oppMoves.SelectMany(lst => lst.Attacks).Count(a => a == Area.Nose);
                 * ataks[1] = oppMoves.SelectMany(lst => lst.Attacks).Count(a => a == Area.Jaw);
                 * ataks[2] = oppMoves.SelectMany(lst => lst.Attacks).Count(a => a == Area.Belly);
                 * ataks[3] = oppMoves.SelectMany(lst => lst.Attacks).Count(a => a == Area.Groin);
                 * ataks[4] = oppMoves.SelectMany(lst => lst.Attacks).Count(a => a == Area.Legs);
                 *
                 * defens[0] = oppMoves.SelectMany(lst => lst.Defences).Count(a => a == Area.Nose);
                 * defens[1] = oppMoves.SelectMany(lst => lst.Defences).Count(a => a == Area.Jaw);
                 * defens[2] = oppMoves.SelectMany(lst => lst.Defences).Count(a => a == Area.Belly);
                 * defens[3] = oppMoves.SelectMany(lst => lst.Defences).Count(a => a == Area.Groin);
                 * defens[4] = oppMoves.SelectMany(lst => lst.Defences).Count(a => a == Area.Legs);*/


                if (opponentsLastMove.Attacks.Contains(Area.Jaw) && (random1 > 0.3))
                {
                    move.AddDefence(Area.Jaw);
                }
                else if (opponentsLastMove.Attacks.Contains(Area.Belly) && (random1 > 0.6))
                {
                    move.AddDefence(Area.Belly);
                }
                else if (opponentsLastMove.Attacks.Contains(Area.Belly) && (random1 > 0.9))
                {
                    move.AddDefence(Area.Groin);
                }
                else
                {
                    move.AddDefence(Area.Nose);
                }

                if (opponentsLastMove.Defences.Contains(Area.Nose) && (random2 < 0.8))
                {
                    if (opponentsLastMove.Defences.Contains(Area.Jaw) && (random2 < 0.8))
                    {
                        move.AddAttack(Area.Belly);
                    }
                    else
                    {
                        move.AddAttack(Area.Jaw);
                    }
                }
                else
                {
                    move.AddAttack(Area.Nose);
                }

                if (opponentsLastMove.Defences.Contains(Area.Nose) && (random3 < 0.3))
                {
                    if (opponentsLastMove.Defences.Contains(Area.Jaw) && (random3 < 0.3))
                    {
                        if (opponentsLastMove.Defences.Contains(Area.Belly) && (random3 < 0.3))
                        {
                            move.AddAttack(Area.Groin);
                        }
                        else
                        {
                            move.AddAttack(Area.Belly);
                        }
                    }
                    else
                    {
                        move.AddAttack(Area.Jaw);
                    }
                }
                else
                {
                    move.AddAttack(Area.Nose);
                }
                return(move);
            }



            /*if(opponentsLastMove == null)
             * {
             *   return move.AddAttack(Area.Jaw).AddAttack(Area.Belly).AddDefence(Area.Nose);
             * }
             * else
             * {
             *
             *   if (opponentsLastMove.Attacks.Contains(Area.Nose))
             *   {
             *       move.AddDefence(Area.Nose);
             *   }
             *   else
             *   {
             *       var area = areas[_random.Next(5)];
             *       if (_random.NextDouble() < 0.2)
             *       {
             *           move.AddDefence(area);
             *       }
             *       else
             *       {
             *           move.AddDefence(Area.Jaw);
             *       }
             *       //move.AddDefence(Area.Jaw);
             *   }
             *
             *   if (!opponentsLastMove.Defences.Contains(Area.Nose))
             *   {
             *       move.AddAttack(Area.Nose);
             *   }
             *   else
             *   {
             *       move.AddAttack(Area.Jaw);
             *   }
             *
             *   if (!opponentsLastMove.Defences.Contains(Area.Jaw))
             *   {
             *       move.AddAttack(Area.Jaw);
             *   }
             *   else
             *   {
             *       move.AddAttack(Area.Belly);
             *   }
             *
             *   return move;
             * }*/
        }
Example #7
0
        private void ActRandom(Move thisMove)
        {
            List <Area> defenses = new List <Area>();

            for (int x = 0; x < 3; x++)
            {
                int rnd = _random.Next(0, 11);

                if (rnd < 8)
                {
                    int temp = _random.Next(0, 3);
                    if (temp == 0)
                    {
                        thisMove.AddAttack(Area.Belly);
                    }

                    else if (temp == 1)
                    {
                        thisMove.AddAttack(Area.Jaw);
                    }

                    else if (temp == 2)
                    {
                        thisMove.AddAttack(Area.Nose);
                    }
                }
                else
                {
                    int temp = _random.Next(0, 3);
                    if (temp == 0)
                    {
                        if (!defenses.Contains(Area.Belly))
                        {
                            thisMove.AddDefence(Area.Belly);
                            defenses.Add(Area.Belly);
                        }
                        else
                        {
                            if (!defenses.Contains(Area.Nose))
                            {
                                thisMove.AddDefence(Area.Nose);
                                defenses.Add(Area.Nose);
                            }
                            else
                            {
                                thisMove.AddDefence(Area.Jaw);
                                defenses.Add(Area.Jaw);
                            }
                        }
                    }

                    else if (temp == 1)
                    {
                        if (!defenses.Contains(Area.Jaw))
                        {
                            thisMove.AddDefence(Area.Jaw);
                            defenses.Add(Area.Jaw);
                        }
                        else
                        {
                            if (!defenses.Contains(Area.Nose))
                            {
                                thisMove.AddDefence(Area.Nose);
                                defenses.Add(Area.Nose);
                            }
                            else
                            {
                                thisMove.AddDefence(Area.Belly);
                                defenses.Add(Area.Belly);
                            }
                        }
                    }

                    else if (temp == 2)
                    {
                        if (!defenses.Contains(Area.Nose))
                        {
                            thisMove.AddDefence(Area.Nose);
                            defenses.Add(Area.Nose);
                        }
                        else
                        {
                            if (!defenses.Contains(Area.Jaw))
                            {
                                thisMove.AddDefence(Area.Jaw);
                                defenses.Add(Area.Jaw);
                            }
                            else
                            {
                                thisMove.AddDefence(Area.Belly);
                                defenses.Add(Area.Belly);
                            }
                        }
                    }
                }
            }
        }
Example #8
0
 private void PunchHard(Move thisMove, Move opponentsLastMove)
 {
     thisMove.AddAttack(Area.Nose);
     thisMove.AddAttack(Area.Jaw);
     thisMove.AddDefence(Area.Nose);
 }