Пример #1
0
        //todo change to return whole state
        private List <Line> GetState()
        {
            var state = new BoardStateBase(new List <Line>(), new List <Line>(), type, board);

            for (int i = 0; i < board.GetLength(0); i++)
            {
                for (int j = 0; j < board.GetLength(1); j++)
                {
                    var cell = CellManager.Get(i, j);
                    if (board[i, j] != type || usedCells.Contains(cell))
                    {
                        continue;
                    }
                    var factory = new LineModifier(cell, state, GetBackwardsDirections());
                    factory.AddCellToLines();
                    foreach (var lineCell in state.MyLines.SelectMany(l => l))
                    {
                        usedCells.Add(lineCell);
                    }
                }
            }
            state.MyLines.Sort();
            state.OppLines.Sort();
            return(state.MyLines);
        }
Пример #2
0
        public static void AddCellToLines(Cell cell, BoardStateBase state)
        {
            var factory = new LineModifier(cell, state);

            factory.AddCellToLines();
            state.MyLines.Sort();
            state.OppLines.Sort();
        }