private IEnumerable <CharCoordinate> GetEmptySiblings(CharCoordinate coordinate) { var emptyCells = GetEmptyCells(); var emptySiblings = emptyCells.Where(x => x.IsSiblingOf(coordinate)).ToList(); return(emptySiblings); }
public bool HasEmptySibling(CharCoordinate coordinate) { var emptyCells = GetEmptyCells(); var siblingEmptyCells = emptyCells.Where(x => x.IsSiblingOf(coordinate)); return(siblingEmptyCells.Any()); }
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); }
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); }
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); }
public char GetCharAt(CharCoordinate coordinate) { return(_matrix[coordinate.Row, coordinate.Column]); }
private bool IsEmpty(CharCoordinate coordinate) { return(_matrix[coordinate.Row, coordinate.Column] == '\0'); }
private void SetCharAt(CharCoordinate coordinate, char c) { _matrix[coordinate.Row, coordinate.Column] = c; }
private void DelCharAt(CharCoordinate coordinate) { _matrix[coordinate.Row, coordinate.Column] = '\0'; }