示例#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();
        }