Ejemplo n.º 1
0
        public CellGrowthResult CalculateCellGrowth(BioCell cell, IPlayer player, SurroundingCells surroundingCells)
        {
            var emptyCells = surroundingCells.EmptyCells;

            var newCells = GrowNewCells(player, emptyCells);

            var newDeadCells = CheckForCellDeath(cell, player, surroundingCells);

            return(new CellGrowthResult(newCells, newDeadCells));
        }
Ejemplo n.º 2
0
        private List <BioCell> CheckForCellDeath(BioCell cell, IPlayer player, SurroundingCells surroundingCells)
        {
            var newDeadCells = new List <BioCell>();

            if (player.LiveCells >= MinimumLiveCellsForCellDeath &&
                (CellDiesOfStarvation(surroundingCells.SurroundedByLiveCells, player) || CellDiesRandomly(player)))
            {
                cell.Dead           = true;
                cell.PreviousPlayer = cell.Player;
                newDeadCells.Add(cell);
            }

            return(newDeadCells);
        }
Ejemplo n.º 3
0
        public SurroundingCells GetSurroundingCells(
            BioCell bioCell,
            Dictionary <int, BioCell> currentLiveCells,
            Dictionary <int, BioCell> currentDeadCells)
        {
            var surroundingCells = new SurroundingCells();
            var checkLeft        = true;
            var checkTop         = true;
            var checkRight       = true;
            var checkBottom      = true;

            checkLeft = GetOutOfGridCells(bioCell.CellIndex, surroundingCells,
                                          ref checkLeft, ref checkRight, ref checkTop, ref checkBottom);

            GetInGridCells(bioCell.CellIndex, surroundingCells, currentLiveCells, currentDeadCells, checkLeft, checkBottom, checkTop, checkRight);

            return(surroundingCells);
        }