コード例 #1
0
 public static void DoSimpleStrategy(this Game game)
 {
     try
     {
         Iceberg[] MyBergs      = game.GetMyIcebergs();
         Iceberg[] EnemyBergs   = game.GetEnemyIcebergs();
         Iceberg   MyBest       = MyBergs.Best();
         Iceberg   EnemyWorst   = EnemyBergs.Worst();
         Iceberg[] NeutralBergs = game.GetNeutralIcebergs();
         if (NeutralBergs.Length == 0 && !MyBest.CanAttack(EnemyWorst))
         {
             if (MyBergs.SumPenguins() > EnemyWorst.PenguinAmount * 1.3)
             {
                 foreach (Iceberg i in MyBergs)
                 {
                     i.SendPenguins(EnemyWorst, (int)(i.PenguinAmount / 1.2));
                 }
             }
         }
         if (MyBergs.Length > 1)
         {
             Iceberg MySecondBest = MyBergs.SecondBest();
             if (MySecondBest.CanAttack(EnemyWorst))
             {
                 MySecondBest.SendPenguins(EnemyWorst, MySecondBest.PenguinsToSendto(EnemyWorst));
             }
         }
         if (MyBest.CanUpgrade() && !MyBest.AlreadyActed)
         {
             MyBest.Upgrade();
         }
         if (MyBest.CanAttack(EnemyWorst))
         {
             MyBest.SendPenguins(EnemyWorst, MyBest.PenguinsToSendto(EnemyWorst));
         }
         else
         {
             if (NeutralBergs.Length > 0)
             {
                 Iceberg NeutralWorst = NeutralBergs.Worst();
                 if (NeutralWorst.PenguinAmount < MyBest.PenguinAmount && !MyBest.AlreadyActed)
                 {
                     MyBest.SendPenguins(NeutralWorst, NeutralWorst.PenguinAmount + 1);
                 }
             }
         }
     }
     catch (System.Exception e)
     {
         System.Console.WriteLine(e);
     }
 }
コード例 #2
0
 public static bool CanAttack(this Iceberg a, Iceberg b)
 {
     return(a.PenguinsToSendto(b) < a.PenguinAmount && !a.AlreadyActed);
 }