Esempio n. 1
0
        public Cell[,] Init(Func <CellState> initFunc, RuleEngine rules)
        {
            NeighborhoodCache.Reset();
            State = new Cell[Width, Height];

            BoardIterator((x, y) =>
            {
                State[x, y] = new Cell(initFunc(), x, y, rules);
            });

            return(State);
        }
Esempio n. 2
0
        public void InitFromString(string boardState, RuleEngine engine)
        {
            NeighborhoodCache.Reset();
            var singleString = string.Join("", boardState.Trim().Split(Environment.NewLine));
            var i            = 0;
            var board        = this;

            BoardIterator((x, y) => {
                int state = 0;
                int.TryParse(boardState[i++].ToString(), out state);
                var cell          = new Cell((CellState)state, x, y, engine);
                board.State[x, y] = cell;
            });
        }