Beispiel #1
0
        // Уставить башню
        public CommonTower SetTower(ETowers tower, Vector2 position)
        {
            CommonTower outTower = null;

            if (tower == ETowers.SingleTower)
            {
                outTower = new SingleTower(RenderTarget2D, position);
            }

            if (tower == ETowers.CrazyTower)
            {
                outTower = new CrazyTower(RenderTarget2D, position);
            }

            if (outTower != null)
            {
                outTower.eventMouseOver += outTower_isMouseOver;
                _towers.Add(outTower);
            }
            return(outTower);
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            /**
             *
             * SolutionMaker solutionMaker = new SolutionMaker(new UniformGaussianRandomTowers(1, 4, 10), new DamagePolicyByTowerCount());
             * solutionMaker.Make(300, 15 * 2, 10000);
             * return;
             *
             * /**/
            ITowerStateMaker towerStateMaker;
            IScoringPolicy   xScoringPolicy;
            int toolemasir;


            if (args.Length > 0)
            {
                towerStateMaker = new UniformRandomTowers(int.Parse(args[0]), int.Parse(args[1]), int.Parse(args[2]));
                toolemasir      = 25;
                xScoringPolicy  = new ExplorePolicyByTowerCount();
            }
            else
            {
                Console.WriteLine("Tower maker type?");
                var tower = Console.ReadLine();
                if (tower == "ThreeTowers")
                {
                    towerStateMaker = new ThreeTowers();
                }
                else if (tower == "FourTowers")
                {
                    towerStateMaker = new FourTowers();
                }
                else if (tower == "SingleTower")
                {
                    towerStateMaker = new SingleTower();
                }
                else if (tower == "TwoTowers")
                {
                    towerStateMaker = new TwoTowers();
                }
                else if (tower == "TwoDoubleTowers")
                {
                    towerStateMaker = new TwoDoubleTowers();
                }
                else if (tower == "RandomTowers")
                {
                    towerStateMaker = new RandomTowers(5, 20, 500);
                }
                else if (tower == "UniformRandom")
                {
                    Console.WriteLine("Min tower count?");
                    var minTowerCount = int.Parse(Console.ReadLine());

                    Console.WriteLine("Max tower count?");
                    var maxTowerCount = int.Parse(Console.ReadLine());

                    Console.WriteLine("How many of each?");
                    var eachCount = int.Parse(Console.ReadLine());

                    towerStateMaker = new UniformRandomTowers(minTowerCount, maxTowerCount, eachCount);
                }
                else if (tower == "GaussianRandom")
                {
                    towerStateMaker = new UniformGaussianRandomTowers(1, 30, 10);
                }
                else
                {
                    throw new Exception("Invalid response.");
                }

                Console.WriteLine("policy?");
                var policy = Console.ReadLine();

                Console.WriteLine("Money?");
                var money = int.Parse(Console.ReadLine());

                Console.WriteLine("Length?");
                toolemasir = int.Parse(Console.ReadLine());



                if (policy == "Damage")
                {
                    xScoringPolicy = new DamagePolicy(money);
                }
                else if (policy == "Explore")
                {
                    xScoringPolicy = new ExplorePolicy(money);
                }
                else if (policy == "Damage2")
                {
                    xScoringPolicy = new DamagePolicyByTowerCount();
                }
                else if (policy == "Explore2")
                {
                    xScoringPolicy = new ExplorePolicyByTowerCount();
                }
                else
                {
                    throw new Exception("Invalid response.");
                }
            }
            var solutionMaker = new SolutionMaker(towerStateMaker, xScoringPolicy);

            solutionMaker.Make(toolemasir, 40, 5000);

            /**
             *
             * int[] cannons, archers;
             *
             * //cannons = new int[] { 1, 3, 5, 7, 9, 11, 13};
             * //archers = new int[] { 1, 3, 5, 7, 9, 11, 13};
             *
             * //cannons = new int[] { };
             * //archers = new int[] { 3, 5, 7, 9, 12 };
             *
             * //cannons = new int[] { 2, 2, 3, 3, 4, 4 };
             * //archers = new int[] { };
             *
             * //cannons = new int[] { 2, 2 };
             * //archers = new int[] { 5, 7, 9 };
             *
             * //cannons = new int[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6 };
             * //archers = new int[] { 7, 7, 8, 8, 9, 9, 10, 10, 11, 11 };
             *
             * //cannons = new int[] { 1, 1, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15, 17, 17, 19, 19, 21, 21, 23, 23 };
             * //archers = new int[] { 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24 };
             *
             * cannons = new int[] { 3, 9 };
             * archers = new int[] { 6, 9 };
             *
             *
             *
             * var length = 15;
             * var preferredMoneyToSpend = 400;
             * var generationPopulation = 100;
             * var lengthOfGene = length * 2;
             * var maximumCountOfGenerations = 1000;
             * var geneToTroopMean = 0;
             *
             * //var towerCount = 20;
             * //var archerTowerCount = (int)gaussianRandom(towerCount / 2.0, 1);
             * //var canonTowerCount = towerCount - archerTowerCount;
             * //preferredMoneyToSpend = archerTowerCount * 100 + canonTowerCount * 1000;
             *
             * //cannons = randomTowerOrder(canonTowerCount, length);
             * //archers = randomTowerOrder(archerTowerCount, length);
             *
             *
             * IScoringPolicy scoringPolicy;
             *
             * //scoringPolicy = new ExplorePolicy(preferredMoneyToSpend);
             * scoringPolicy = new DamagePolicy(preferredMoneyToSpend);
             *
             * var bestGene = findBestGeneForTowerPattern(cannons, archers, length, preferredMoneyToSpend,
             *  generationPopulation, maximumCountOfGenerations, geneToTroopMean, 15 * 2, scoringPolicy, printEvaluationLog: true);
             *
             * Console.WriteLine(bestGene.Score);
             * Console.ReadLine();
             * /**/
        }