Example #1
0
        static void Main(string[] args)
        {
            //Some testing.
            DateTime start = DateTime.Now;

            PlayField playField = new PlayField();
            //playField.InsertMine(1, 2);
            //playField.InsertChicken(0, 0, 1);
            //playField.InsertChicken(5, 5, 1);
            //playField.InsertMine(0, 0);

            for (int x = 0; x < playField.Size; x++)
            {
                for (int y = 0; y < playField.Size; y++)
                {
                    playField.InsertChicken(x, y);
                }
            }

            //playField.AttackWithPigs(100, 100, 10);

            playField.AttackWithBomb(50, 50, 50);

            //for (int i = 0; i < 25; i++)
            //{
            //    playField.EvaluatePlayFieldForPigs();
            //}

            playField.EvaluatePlayFieldForBomb();

            playField.EvaluatePlayFieldForPigs();

            //Console.WriteLine(playField.ToString());
            //Console.WriteLine(result);
            //Console.WriteLine(playField.GetPigsScores());

            //for (int i = 0; i < 90; i++)
            //{
            //    playField.AttackWithPigs(5 + i, 5 + i, 7);
            //}

            //Console.WriteLine(playField.GetPigsScores());

            //int[,] testM = {
            //                   {1,2,5,3},
            //                   {8,1,6,2},
            //                   {1,2,1,2}
            //               };

            //MatrixPartialSumsFinder sf = new MatrixPartialSumsFinder(testM);
            //for (int i = 0; i < 400000; i++)
            //{
            //    sf.GetSum(0, 0, 0, 0);
            //}
            //Console.WriteLine(sf.GetSum(-1, -2, -1, 23));

            Console.WriteLine((DateTime.Now - start).TotalMilliseconds);
        }
Example #2
0
        static void Main(string[] args)
        {
            PlayField playFieldMaster = new PlayField();

            //Read input.
            InputReader[] commands = GetInput();

            //DateTime start = DateTime.Now;

            if (commands.Length == 0)
            {
                return;
            }

            //Execute commands from input.
            for (int current = 0; current < commands.Length; current++)
            {
                playFieldMaster.InsertDefenseUnit(commands[current].X, commands[current].Y, commands[current].UnitType, commands[current].UnitCount);
            }

            //Evaluate for bomb.
            playFieldMaster.EvaluatePlayFieldForBomb();
            //Console.WriteLine("Bomb scores:");
            //Console.WriteLine(playField.GetBombsScores(2));
            //Console.WriteLine();

            //Console.WriteLine(playFieldMaster.ToString());

            PlayField playFieldBranchPc = new PlayField(playFieldMaster);
            PlayField playFieldBranchMpc = new PlayField(playFieldMaster);
            PlayField playFieldBranchRel = new PlayField(playFieldMaster);
            PlayField playFieldBranchRelPc = new PlayField(playFieldMaster);
            PlayField playFieldBranchRelMpc = new PlayField(playFieldMaster);
            PlayField playFieldBranchNb = new PlayField(playFieldMaster);
            PlayField playFieldBranchNbPc = new PlayField(playFieldMaster);
            PlayField playFieldBranchNbMpc = new PlayField(playFieldMaster);

            //Find highest score for bomb.
            Bomb bombGreedy = playFieldMaster.GetMostEffectiveBombGreedy();
            Bomb bombRelative = playFieldBranchRel.GetMostEffectiveBombRelative();

            GetOutput(playFieldMaster, bombGreedy);
            GetOutputPC(playFieldBranchPc, bombGreedy);
            GetOutputMPC(playFieldBranchMpc, bombGreedy);
            GetOutput(playFieldBranchRel, bombRelative);
            GetOutputPC(playFieldBranchRelPc, bombRelative);
            GetOutputMPC(playFieldBranchRelMpc, bombRelative);
            GetOutput(playFieldBranchNb);
            GetOutputPC(playFieldBranchNbPc);
            GetOutputMPC(playFieldBranchNbMpc);

            //Console.WriteLine(GetOutput(playFieldMaster, bombGreedy));
            //PrintStatistics(playFieldMaster);

            //Console.WriteLine(GetOutputPC(playFieldBranchPc, bombGreedy));
            //PrintStatistics(playFieldBranchPc);

            //Console.WriteLine(GetOutputMPC(playFieldBranchMpc, bombGreedy));
            //PrintStatistics(playFieldBranchMpc);

            //Console.WriteLine(GetOutput(playFieldBranchRel, bombRelative));
            //PrintStatistics(playFieldBranchRel);

            //Console.WriteLine(GetOutputPC(playFieldBranchRelPc, bombRelative));
            //PrintStatistics(playFieldBranchRelPc);

            //Console.WriteLine(GetOutputMPC(playFieldBranchRelMpc, bombRelative));
            //PrintStatistics(playFieldBranchRelMpc);

            //Console.WriteLine(GetOutput(playFieldBranchNb));
            //PrintStatistics(playFieldBranchNb);

            //Console.WriteLine(GetOutputPC(playFieldBranchNbPc));
            //PrintStatistics(playFieldBranchNbPc);

            //Console.WriteLine(GetOutputMPC(playFieldBranchNbMpc));
            //PrintStatistics(playFieldBranchNbMpc);

            Console.WriteLine(GetMaxScoreOutput(playFieldMaster, playFieldBranchPc, playFieldBranchMpc,
                                                playFieldBranchRel, playFieldBranchRelPc, playFieldBranchRelMpc,
                                                playFieldBranchNb, playFieldBranchNbPc, playFieldBranchNbMpc));

            //Console.WriteLine("Time data: {0} ms", (DateTime.Now - start).TotalMilliseconds);
        }