Пример #1
0
        public void CheckForClears(List <int> rowsToCheck, List <int> colsToCheck)
        {
            int score = 0, count = 0;

            List <int> rowsToRemove = new List <int>(), colsToRemove = new List <int>();

            foreach (int i in rowsToCheck)
            {
                int numSpots = Spots.Where(x => x[0] == i).Count() - Obstacles.Where(x => x[0] == i).Count();

                IEnumerable <Bit> matches = Bits.Where(x => x.Coordinates.X == i);

                if (numSpots == matches.Count())
                {
                    rowsToRemove.Add(i);

                    score += matches.Count();
                    count++;
                }
            }

            foreach (int i in colsToCheck)
            {
                int numSpots = Spots.Where(x => x[1] == i).Count() - Obstacles.Where(x => x[1] == i).Count();

                IEnumerable <Bit> matches = Bits.Where(x => x.Coordinates.Y == i);

                if (numSpots == matches.Count())
                {
                    colsToRemove.Add(i);

                    score += matches.Count();
                    count++;
                }
            }

            foreach (int i in rowsToRemove)
            {
                Bits.RemoveAll(x => x.Coordinates.X == i);
            }

            foreach (int i in colsToRemove)
            {
                Bits.RemoveAll(x => x.Coordinates.Y == i);
            }

            Score += score * count;
        }
Пример #2
0
        private Spot GetRandomSpot()
        {
            var skip = RandomHelper.Value(Spots.Count(x => x.Available()));

            return(Spots.Where(x => x.Available()).Skip(skip).FirstOrDefault());
        }