private void ProcessActions()
    {
        //process action should be considered in runtime performance
        gameTurnSW.Start();

        //Rotate the order the player actions are processed so there is no advantage given to
        //any one player
        for (int i = playerIDToProcessFirst;
             i < pendingActions.CurrentActions.Length; i++)
        {
            pendingActions.CurrentActions[i].ProcessAction();
            runtimeAverage.Add(pendingActions.CurrentActions[i].RuntimeAverage, i);
            networkAverage.Add(pendingActions.CurrentActions[i].NetworkAverage, i);
        }

        for (int i = 0; i < playerIDToProcessFirst; i++)
        {
            pendingActions.CurrentActions[i].ProcessAction();
            runtimeAverage.Add(pendingActions.CurrentActions[i].RuntimeAverage, i);
            networkAverage.Add(pendingActions.CurrentActions[i].NetworkAverage, i);
        }

        playerIDToProcessFirst++;
        if (playerIDToProcessFirst >= pendingActions.CurrentActions.Length)
        {
            playerIDToProcessFirst = 0;
        }

        //finished processing actions for this turn, stop the stopwatch
        gameTurnSW.Stop();
    }
        public void GetAverageTest1()
        {
            RollingAverage target   = new RollingAverage();
            double         expected = 2F;
            double         actual;

            target.Add(1);
            target.Add(2);
            target.Add(3);
            actual = target.GetAverage();
            Assert.AreEqual(expected, actual);
        }
Exemple #3
0
        /// <summary>
        /// </summary>
        /// <param name="Block"></param>
        private void UpdateLatency(ManifestPendingDownloadBlock Download)
        {
            ulong Elapsed = TimeUtils.Ticks - Download.TimeStarted;

            //Console.WriteLine("Recieved block {0} in {1} ms", Download.BlockIndex, Elapsed);
            BlockRecieveLatency.Add(Elapsed);
            AverageBlockSize.Add(Download.Size);
        }
Exemple #4
0
        public void Add_N_Values_Returns_Average(double expectedaverage, params int[] sampleset)
        {
            var average = new RollingAverage(10);

            foreach (int value in sampleset)
            {
                average.Add(value);
            }

            var result = average.CurrentAverage;

            Assert.Equal(expectedaverage, result);
        }
        public void GetAverageTest3()
        {
            RollingAverage target   = new RollingAverage(16);
            double         expected = 100F;
            double         actual;

            for (int i = 0; i < 10000; i++)
            {
                target.Add(100F);
            }
            actual = target.GetAverage();
            Assert.AreEqual(expected, actual);
        }
Exemple #6
0
    private void ProcessActions()
    {
        //process action should be considered in runtime performance
        _gameTurnSW.Start();

        //Rotate the order the player actions are processed so there is no advantage given to
        //any one player
        // TODO : Consider fairness between players, rotating first action
        foreach (KeyValuePair <int, Action> currentAction in _pendingActions.currentActions)
        {
            if (currentAction.Value != null)
            {
                currentAction.Value.ProcessAction();
                _runtimeRollingAverage.Add(currentAction.Value.gameLagTime, currentAction.Key);
                _networkRollingAverage.Add(currentAction.Value.networkLagTime, currentAction.Key);
            }
        }

        //finished processing actions for this turn, stop the stopwatch
        _gameTurnSW.Stop();
    }