private void Worker()
        {
            BestWins = Player;
            var test = new Commander(new int[] { });

            iterations = oneMax * twoMax * threeMax * fourMax * fiveMax * sixMax * sevenMax * eightMax * nineMax * tenMax;
            for (int one = CastleOne; one < oneMax; one++)
            {
                //{
                for (int two = CastleTwo; two < twoMax; two++)
                {
                    for (int three = CastleThree; three < threeMax; three++)
                    {
                        for (int four = CastleFour; four < fourMax; four++)
                        {
                            for (int five = CastleFive; five < fiveMax; five++)
                            {
                                for (int six = CastleSix; six < sixMax; six++)
                                {
                                    for (int seven = CastleSeven; seven < sevenMax; seven++)
                                    {
                                        for (int eight = CastleEight; eight < eightMax; eight++)
                                        {
                                            for (int nine = CastleNine; nine < nineMax; nine++)
                                            {
                                                for (int ten = CastleTen; ten < tenMax; ten++)
                                                {
                                                    if (one + two + three + four + five + six + seven + eight + nine + ten != 100)
                                                    {
                                                        continue;
                                                    }
                                                    currentI = tenMax * (nineMax * (eightMax * (sevenMax * (sixMax * (fiveMax * (fourMax * (threeMax * ((twoMax * one) + two) + three) + four) + five) + six) + seven) + eight) + nine) + ten;

                                                    test.Soldiers = new[] { one, two, three, four, five, six, seven, eight, nine, ten };
                                                    test.ResetRecord();
                                                    this.model.AddCommander(test);
                                                    this.model.Fight();

                                                    if (model.Player.Wins >= BestWins.Wins)
                                                    {
                                                        BestWins        = new Commander(test.Soldiers);
                                                        BestWins.Wins   = test.Wins;
                                                        BestWins.Losses = test.Losses;
                                                        BestWins.Ties   = test.Ties;
                                                        continue;
                                                    }
                                                    if (model.Player.Wins == BestWins.Wins && model.Player.Losses < BestWins.Losses)
                                                    {
                                                        BestWins        = new Commander(test.Soldiers);
                                                        BestWins.Wins   = test.Wins;
                                                        BestWins.Losses = test.Losses;
                                                        BestWins.Ties   = test.Ties;
                                                        continue;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void AddCommander(Commander player)
 {
     this.Player = player;
     //this.Solutions.Add(player);
 }