예제 #1
0
파일: Grid.cs 프로젝트: stwehrli/Segreg
 public Grid()
 {
     GridGuid = System.Guid.NewGuid().ToString().Substring(0, 8);
     GridStats = new GridStats();
     Cells = new List<Cell>();
     Players = new List<Player>();
 }
예제 #2
0
        /// <summary>
        /// Compute and save statistics
        /// </summary>
        /// <param name="grid">The grid</param>
        /// <param name="nei">The neighborhoods</param>
        public void GridStats(Grid grid, IList<Neighborhood> nei)
        {
            var stats = new GridStats
            {
                MoveCount = grid.Players.Count(p => p.RequestMove),
                TypeChangeCount = grid.Players.Count(p => p.RequestTypeChange),
                TimeoutCount = grid.Players.Count(p => p.HasTimeout),
                SegregAvg = nei.Average(x => x.OwnShare),
                SegregStd = nei.StdDev(x => x.OwnShare)
            };

            grid.GridStats = stats;
            db.Save();
        }