public void GrowToSize(PerTurnPlayerCounters counts)
 {
     while (this.sumAtTurnPerPlayer[0].Count < counts.sumAtTurnPerPlayer[0].Count)
     {
         this.GrowListsBy1();
     }
 }
 private void AggregateAllDataIfNecessary()
 {
     if (aggregatedResult == null)
     {
         aggregatedResult = PerTurnPlayerCounters.Sum(this.counters.AllEntries, playerCount);
     }
 }
 public PerTurnPlayerCountersSeparatedByGame(int playerCount)
 {
     this.counters    = new MapOfGame <PerTurnPlayerCounters>();
     this.playerCount = playerCount;
     this.counters.InitAllEntries(delegate()
     {
         return(new PerTurnPlayerCounters(playerCount));
     });
     this.aggregatedResult = null;
 }
        static public PerTurnPlayerCounters Sum(IEnumerable <PerTurnPlayerCounters> counters, int playerCount)
        {
            var result = new PerTurnPlayerCounters(playerCount);

            foreach (var counter in counters)
            {
                result.Add(counter);
            }

            return(result);
        }
        public void Add(PerTurnPlayerCounters other)
        {
            for (int playerIndex = 0; playerIndex < this.sumAtTurnPerPlayer.Length; ++playerIndex)
            {
                var thisSumAtTurn  = this.sumAtTurnPerPlayer[playerIndex];
                var otherSumAtTurn = other.sumAtTurnPerPlayer[playerIndex];

                GrowListToTurn(thisSumAtTurn, otherSumAtTurn.Count);

                for (int turn = 0; turn < otherSumAtTurn.Count; ++turn)
                {
                    thisSumAtTurn[turn] += otherSumAtTurn[turn];
                }
            }
        }
        public float[] GetAveragePerTurn(int playerIndex, int throughTurn, PerTurnPlayerCounters counts)
        {
            if (throughTurn > PlayerTurnLength)
            {
                throw new Exception("There aren't that many turns");
            }

            List <int> totalGoldPerTurn     = this.sumAtTurnPerPlayer[playerIndex];
            List <int> totalCountOfThisTurn = counts.sumAtTurnPerPlayer[playerIndex];

            float[] result = new float[throughTurn];

            for (int turn = 1; turn <= throughTurn; ++turn)
            {
                result[turn - 1] = ((float)totalGoldPerTurn[turn]) / (totalCountOfThisTurn[turn] == 0 ? 1 : totalCountOfThisTurn[turn]);
            }

            return(result);
        }