Esempio n. 1
0
        public int Compute(double[] input)
        {
            //editing input to match learned form
            for (int i = 0; i < 15; i++)
            {
                input[i] /= 10.0;
            }
            input[15] = Math.Min(input[15] / 2000.0, 1);

            double[] result;
            result = ActNetwork.Compute(input);

            for (int i = 0; i < 4; i++)
            {
                result[i] = Math.Round(result[i]);
            }

            for (int i = 0; i < 4; i++)
            {
                Console.Write(result[i]);
                Console.Write(" ");
            }
            Console.WriteLine();
            Console.ReadKey();

            int decision = 0;

            for (int i = 0; i < 4; i++)
            {
                decision += (int)result[i] * (int)Math.Pow(2.0, i);
            }
            Console.WriteLine(decision);
            Console.ReadKey();
            return(decision);
        }
Esempio n. 2
0
        public int Decision(Player player, Player bot)
        {
            List <Force> enemyForcesAll = player.ListOfForces;
            List <Force> yourForcesAll  = bot.ListOfForces;

            int[] upgrades = bot.Upgrades;
            int   cash     = bot.Cash;

            double[] input = new double[16];

            for (int i = 0; i < upgrades.Length; i++)
            {
                input[i] = upgrades[i];
            }

            for (int i = 5; i < 10; i++)
            {
                if (i - 5 < enemyForcesAll.Count())
                {
                    input[i] = (double)((int)enemyForcesAll[i - 5].Id);
                }
                else
                {
                    input[i] = 9;
                }
            }
            ;

            for (int i = 10; i < 15; i++)
            {
                if (i - 10 < yourForcesAll.Count())
                {
                    input[i] = (double)((int)yourForcesAll[i - 10].Id);
                }
                else
                {
                    input[i] = 9;
                }
            }
            ;

            input[15] = cash;


            //editing input to match learned form
            for (int i = 0; i < 15; i++)
            {
                input[i] /= 10.0;
            }
            input[15] = Math.Min(input[15] / 2000.0, 1);

            double[] result;
            result = ActNetwork.Compute(input);

            for (int i = 0; i < 4; i++)
            {
                result[i] = Math.Round(result[i]);
            }

            int decision = 0;

            for (int i = 0; i < 4; i++)
            {
                decision += (int)result[i] * (int)Math.Pow(2.0, i);
            }

            return(decision);

            //0 - buy explosive
            //1 - buy rifle
            //2 - buy rocket
            //3 - buy drone
            //4 - buy cannon
            //5 - wait (do nothing)
            //6 - upgradeExplosive
            //7 - upgradeRifle
            //8 - upgradeRocket
            //9 - upgradeDrone
            //10 - upgradeCannon
            //11 - wait (do nothing)
            //12 - wait (do nothing)
            //13 - wait (do nothing)
            //14 - wait (do nothing)
            //15 - wait (do nothing)
        }