Пример #1
0
        public static IEnumerable <Cell> GetAdjustmentCells(BoardCell[,] board, Cell startCell)
        {
            var x    = startCell.X;
            var y    = startCell.Y;
            var cell = CellManager.Get(x + 1, y + 1);

            if (cell.IsEmpty(board))
            {
                yield return(cell);
            }
            cell = CellManager.Get(x + 1, y - 1);
            if (cell.IsEmpty(board))
            {
                yield return(cell);
            }
            cell = CellManager.Get(x - 1, y + 1);
            if (cell.IsEmpty(board))
            {
                yield return(cell);
            }
            cell = CellManager.Get(x - 1, y - 1);
            if (cell.IsEmpty(board))
            {
                yield return(cell);
            }
            //////////////////////

            cell = CellManager.Get(x + 1, y);
            if (cell.IsEmpty(board))
            {
                yield return(cell);
            }
            cell = CellManager.Get(x - 1, y);
            if (cell.IsEmpty(board))
            {
                yield return(cell);
            }
            cell = CellManager.Get(x, y + 1);
            if (cell.IsEmpty(board))
            {
                yield return(cell);
            }
            cell = CellManager.Get(x, y - 1);
            if (cell.IsEmpty(board))
            {
                yield return(cell);
            }
        }
Пример #2
0
        public IEnumerable <Cell> GetNearEmptyCells()
        {
            var set = new HashSet <Cell>();

            for (int x = 0; x < 15; ++x)
            {
                for (int y = 0; y < 15; ++y)
                {
                    if (Board[x, y] != BoardCell.None)
                    {
                        set.UnionWith(Game.GetAdjustmentCells(Board, CellManager.Get(x, y)));
                    }
                }
            }
            set.UnionWith(GetNextNextCells(MyLines));
            set.UnionWith(GetNextNextCells(OppLines));
            return(set.OrderBy(c => c.X * 15 + c.Y));
        }
Пример #3
0
        public List <Line> GetLines(BoardCell type)
        {
            var lines = new List <Line>();

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    if (board[i, j] != type)
                    {
                        continue;
                    }
                    FillLines(CellManager.Get(i, j), lines);
                }
            }
            var sorted = lines.ToList();

            sorted.Sort();
            return(sorted);
        }
Пример #4
0
        public Cell Normalize()
        {
            int nx = 0, ny = 0;

            if (X > 0)
            {
                nx = 1;
            }
            if (X < 0)
            {
                nx = -1;
            }
            if (Y > 0)
            {
                ny = 1;
            }
            if (Y < 0)
            {
                ny = -1;
            }
            return(CellManager.Get(nx, ny));
        }
Пример #5
0
 private Cell FirstMoveCase()
 {
     return(board[7, 7] == BoardCell.None ? CellManager.Get(7, 7) : CellManager.Get(8, 8));
 }
Пример #6
0
 public static Cell operator *(int a, Cell cell)
 {
     return(CellManager.Get(cell.X * a, cell.Y * a));
 }
Пример #7
0
 public static Cell operator -(Cell first, Cell second)
 {
     return(CellManager.Get(first.X - second.X, first.Y - second.Y));
 }