Exemple #1
0
        public int InsertTwoOrFour(List <EmptyCells> emptyCells)
        {
            Random     rng               = new Random();
            int        index             = rng.Next(0, emptyCells.Count - 1);
            EmptyCells SelectedCell      = emptyCells[index];
            int        SelectIntToInsert = rng.Next(1, 10);

            if (SelectIntToInsert == 9)
            {
                SelectIntToInsert = 4;
            }
            else
            {
                SelectIntToInsert = 2;
            }
            BoardTiles[SelectedCell.XIndex, SelectedCell.YIndex] = SelectIntToInsert;
            return(SelectIntToInsert);
        }
Exemple #2
0
        public static List <EmptyCells> GetEmpty(this int[,] arr)
        {
            List <EmptyCells> EmptyCells = new List <EmptyCells>();

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    if (arr[i, j] == 0)
                    {
                        EmptyCells emptyCell = new EmptyCells()
                        {
                            XIndex = i,
                            YIndex = j
                        };
                        EmptyCells.Add(emptyCell);
                    }
                }
            }
            return(EmptyCells);
        }