public AiMapCell(AiMap map, int x, int y, MapCellDetail mapCellDetail) { _map = map; X = x; Y = y; MapCellDetail = mapCellDetail; Reset(); }
/// <summary> /// Check the nine squares around the given cell for matching with pattern /// </summary> /// <param name="board"></param> /// <returns></returns> public bool DoCellsMatchPattern(MapCellDetail board) { for (int y = -1; y < 2; y++) { for (int x = -1; x < 2; x++) { var onBoard = board.Cell(x, y); var compare = PatternCell(x, y); if (compare == 'G' && onBoard.BasicType != BasicMapPiece.GhostWall) { return(false); } if (compare == 'D' && onBoard.BasicType != BasicMapPiece.Door) { return(false); } if (compare == 'X' && onBoard.BasicType != BasicMapPiece.SingleWall) { return(false); } if (compare == 'W' && onBoard.BasicType != BasicMapPiece.SingleWall && onBoard.BasicType != BasicMapPiece.DoubleWall && onBoard.BasicType != BasicMapPiece.Portal) { return(false); } if (compare == '0' && onBoard.BasicType != BasicMapPiece.Space && onBoard.BasicType != BasicMapPiece.PlayArea && onBoard.BasicType != BasicMapPiece.Portal) { return(false); } if (compare == '#' && onBoard.BasicType != BasicMapPiece.DoubleWall) { return(false); } if (compare == '~' && onBoard.BasicType != BasicMapPiece.OuterSpace) { return(false); } } } return(true); }
/// <summary> /// Check the nine squares around the given cell for matching with pattern /// </summary> /// <param name="middleOfNine"></param> /// <returns></returns> public bool DoCellsMatchPattern(MapCellDetail middleOfNine) { for (int y = -1; y < 2; y++) { for (int x = -1; x < 2; x++) { var onBoard = middleOfNine.Cell(x, y); var compare = PatternCell(x, y); if (compare == 'G' && onBoard.CellType != CellType.GhostWall) { return(false); } if (compare == 'D' && onBoard.CellType != CellType.Door) { return(false); } if (compare == 'X' && onBoard.CellType != CellType.SingleWall) { return(false); } if (compare == 'W' && onBoard.CellType != CellType.SingleWall && onBoard.CellType != CellType.DoubleWall) { return(false); } if (compare == '0' && !onBoard.IsPlayArea) { return(false); } if (compare == '#' && onBoard.CellType != CellType.DoubleWall) { return(false); } if (compare == '~' && onBoard.CellType != CellType.DeadSpace) { return(false); } } } return(true); }