Esempio n. 1
0
        /// <summary>
        /// Calculates z-scores for certain analytics compared to the rest of the data.
        /// </summary>
        /// <param name="all">Other team analyses to compare to</param>
        public void CalculateZScores(IEnumerable <TeamAnalysis> all)
        {
            IEnumerable <double> winrates = from ta in all
                                            select ta.WinRate;
            Distribution distWins = winrates.ToList().MakeDistribution();

            WinRateZ = distWins.Model.ZScore(WinRate);

            IEnumerable <double> respRates = from ta in all
                                             select ta.ResponsivenessRate;
            Distribution distResp = winrates.ToList().MakeDistribution();

            ResponsivenessRateZ = distResp.Model.ZScore(ResponsivenessRate);

            IEnumerable <Distribution> bigData = from ta in all
                                                 select ta.ScoredPoints;

            ScoredPoints.CalculateZ(bigData);

            bigData = from ta in all select ta.FinalScore;
            FinalScore.CalculateZ(bigData);

            bigData = from ta in all select ta.Penalties;
            Penalties.CalculateZ(bigData);

            bigData = from ta in all select ta.Defense;
            Defense.CalculateZ(bigData);
        }
Esempio n. 2
0
        private void Move(int deltaX, int deltaY)
        {
            if (State != TetrisBoardState.Running)
            {
                return;
            }

            if (CurrentPiece == null)
            {
                return;
            }

            var didMove = CurrentPiece.Move(deltaX, deltaY);

            if (didMove)
            {
                CurrentPiece.Draw();
            }

            if (!didMove && deltaY > 0)
            {
                // Make the cells filed and apwn a new piece
                ForEachCell(c => { if (!c.IsEmpty)
                                   {
                                       c.Fix();
                                   }
                            });

                // Score as many times as possible
                var hasScored = false;
                while (true)
                {
                    var addedScore = TryScore();
                    if (addedScore <= 0)
                    {
                        break;
                    }

                    hasScored = true;
                    Score    += addedScore;
                }

                if (hasScored)
                {
                    ScoredPoints?.Invoke(this, EventArgs.Empty);
                }

                SpawnPiece();
            }
        }