Ejemplo n.º 1
0
        private IEnumerable <CharCoordinate> GetEmptySiblings(CharCoordinate coordinate)
        {
            var emptyCells    = GetEmptyCells();
            var emptySiblings = emptyCells.Where(x => x.IsSiblingOf(coordinate)).ToList();

            return(emptySiblings);
        }
Ejemplo n.º 2
0
        public bool HasEmptySibling(CharCoordinate coordinate)
        {
            var emptyCells        = GetEmptyCells();
            var siblingEmptyCells = emptyCells.Where(x => x.IsSiblingOf(coordinate));

            return(siblingEmptyCells.Any());
        }
Ejemplo n.º 3
0
        public bool IsTrapped(CharCoordinate coordinate, List <CharCoordinate> previouslyUsedPath = null)
        {
            previouslyUsedPath = previouslyUsedPath ?? new List <CharCoordinate>();
            var empty   = GetEmptySiblings(coordinate);
            var trapped = empty.All(x => previouslyUsedPath.Contains(x));

            return(trapped);
        }
Ejemplo n.º 4
0
        private CharCoordinate GetRandomEmptySibling(CharCoordinate coordinate, List <CharCoordinate> except = null)
        {
            except = except ?? new List <CharCoordinate>();
            var siblingEmptyCells = GetEmptySiblings(coordinate).Where(x => !except.Contains(x));

            var randomIndex = UnityEngine.Random.Range(0, siblingEmptyCells.Count());
            var nextSibling = siblingEmptyCells.ElementAt(randomIndex);

            return(nextSibling);
        }
Ejemplo n.º 5
0
        private List <CharCoordinate> GetEmptyCells()
        {
            var emptyCells = new List <CharCoordinate>();

            for (var i = 0; i < _size; i++)
            {
                for (var j = 0; j < _size; j++)
                {
                    var current = new CharCoordinate(i, j);

                    if (IsEmpty(current))
                    {
                        emptyCells.Add(current);
                    }
                }
            }
            return(emptyCells);
        }
Ejemplo n.º 6
0
 public char GetCharAt(CharCoordinate coordinate)
 {
     return(_matrix[coordinate.Row, coordinate.Column]);
 }
Ejemplo n.º 7
0
 private bool IsEmpty(CharCoordinate coordinate)
 {
     return(_matrix[coordinate.Row, coordinate.Column] == '\0');
 }
Ejemplo n.º 8
0
 private void SetCharAt(CharCoordinate coordinate, char c)
 {
     _matrix[coordinate.Row, coordinate.Column] = c;
 }
Ejemplo n.º 9
0
 private void DelCharAt(CharCoordinate coordinate)
 {
     _matrix[coordinate.Row, coordinate.Column] = '\0';
 }