Beispiel #1
0
        public static int SimplifiedPenguinsToSend(this Iceberg berg, Iceberg sender)
        {
            List <PenguinGroup> groups =
                (from PenguinGroup a in game.GetAllPenguinGroups()
                 where a.Destination == berg
                 select a).ToList();

            groups.Sort((x, y) =>
            {
                return(x.TurnsTillArrival - y.TurnsTillArrival);
            });

            int BergSign      = berg.BergSign();
            int CurrentTurn   = 0;
            int PenguinAmount = berg.PenguinAmount * BergSign;

            foreach (PenguinGroup penguins in groups)
            {
                int amount = penguins.GroupAmountAfterClash();
                PenguinAmount += berg.PenguinsPerTurn * (penguins.TurnsTillArrival - CurrentTurn) * BergSign;
                PenguinAmount += amount * penguins.GroupSign();
                BergSign       = System.Math.Sign(PenguinAmount);
                CurrentTurn    = penguins.TurnsTillArrival;
            }
            if (CurrentTurn < sender.GetTurnsTillArrival(berg))
            {
                PenguinAmount += berg.PenguinsPerTurn * (sender.GetTurnsTillArrival(berg) - CurrentTurn) * BergSign;
            }
            if (BergSign == sender.BergSign())
            {
                return(0);
            }
            return(PenguinAmount * sender.BergSign() * -1);
        }
Beispiel #2
0
        public static int PredictIcebergStateAfterAll(this Iceberg berg)
        {
            List <PenguinGroup> groups =
                (from PenguinGroup a in game.GetAllPenguinGroups()
                 where a.Destination == berg
                 select a).ToList();

            groups.Sort((x, y) =>
            {
                return(x.TurnsTillArrival - y.TurnsTillArrival);
            });

            int BergSign      = berg.BergSign();
            int CurrentTurn   = 0;
            int PenguinAmount = berg.PenguinAmount * BergSign;

            foreach (PenguinGroup penguins in groups)
            {
                int amount = penguins.GroupAmountAfterClash();
                PenguinAmount += berg.PenguinsPerTurn * (penguins.TurnsTillArrival - CurrentTurn) * BergSign;
                PenguinAmount += amount * penguins.GroupSign();
                BergSign       = System.Math.Sign(PenguinAmount);
                CurrentTurn    = penguins.TurnsTillArrival;
            }
            return(PenguinAmount);
        }