private void xWalk(Int32 yWalk) { for (Int32 xWalk = 0; xWalk < this.Cell0x0.getGrid().getXLength(); xWalk++) { this.xWalkBuffer = xWalk == 0 ? this.yWalkBuffer : this.xWalkBuffer.getRightCell(); if (yWalk == 0) { this.bottomWall = xWalkBuffer.getBottomWall() ? this.bottomWall + "----" : this.bottomWall + " "; this.topWall = xWalkBuffer.getTopWall() ? this.topWall + "----" : this.topWall + " "; } else { this.topWall = this.xWalkBuffer.getTopWall() ? this.topWall + "----" : this.topWall + " "; } if (xWalk == 0) { leftAndrightWalls = this.xWalkBuffer.getLeftWall() ? this.leftAndrightWalls + "| " : this.leftAndrightWalls + " "; leftAndrightWalls = this.xWalkBuffer.getRightWall() ? this.leftAndrightWalls + "| " : this.leftAndrightWalls + " "; } else { leftAndrightWalls = this.xWalkBuffer.getRightWall() ? this.leftAndrightWalls + "| " : this.leftAndrightWalls + " "; } } }
public void unionAndResetPassageID() { HashSet <String> oldCurrentPassageID = new HashSet <String>(this.CurrentCell.getPassageID()); HashSet <String> oldNeighbourPassageID = new HashSet <String>(this.NeighbourCell.getPassageID()); HashSet <String> newPassageID = new HashSet <String>(); newPassageID = this.CurrentCell.getPassageID(); newPassageID.UnionWith(this.NeighbourCell.getPassageID()); CellProperties xwalkCell = new CellProperties(); CellProperties ywalkCell = new CellProperties(); for (Int32 xWalk = 0; xWalk < this.Cell0x0.getGrid().getXLength(); xWalk++) { xwalkCell = xWalk == 0 ? this.Cell0x0 : xwalkCell.getRightCell(); for (Int32 yWalk = 0; yWalk < this.Cell0x0.getGrid().getYLength(); yWalk++) { xwalkCell.setBottomWall(xWalk == 0 && yWalk == 0 ? false : xwalkCell.getBottomWall()); xwalkCell.setBottomWall(xWalk == this.Cell0x0.getGrid().getXLength() - 1 && yWalk == this.Cell0x0.getGrid().getYLength() - 1 ? false : xwalkCell.getBottomWall()); ywalkCell = yWalk == 0 ? xwalkCell : ywalkCell.getTopCell(); if (ywalkCell.getPassageID().SetEquals(oldCurrentPassageID) || ywalkCell.getPassageID().SetEquals(oldNeighbourPassageID)) { ywalkCell.setPassageID(newPassageID); } } } }
public CellProperties(GridProperties grid = null, Int32?targetXCoord = null, Int32?targetYCoord = null, CellProperties tpCell = null, CellProperties bpCell = null, CellProperties rpCell = null, CellProperties lpCell = null) { this.Grid = grid; this.xCoord = targetXCoord; this.yCoord = targetYCoord; this.updatePassageID(this.xCoord.ToString() + "|" + this.yCoord.ToString()); this.topWall = true; this.bottomWall = true; this.rightWall = true; this.leftWall = true; this.topParentCell = tpCell; this.bottomParentCell = bpCell; this.rightParentCell = rpCell; this.leftParentCell = lpCell; this.topCell = this.setTopCell(); this.bottomCell = this.setBottomCell(); if (this.yCoord == 0) { this.rightCell = this.setRightCell(); } this.leftCell = this.setLeftCell(); }
public CellProperties setLeftCell( ) { if (this.xCoord == 0) { return(new CellProperties()); } else { if (this.Grid == null) { return(null); } if (this.yCoord == 0) { return(this.leftParentCell); } else { CellProperties buffer = this.bottomCell; for (Int32 depth = 0; depth < this.yCoord - 1; depth++) { buffer = buffer.bottomParentCell; } buffer = buffer.leftParentCell.topCell; for (Int32 depth = 0; depth < this.yCoord - 1; depth++) { buffer = buffer.topCell; } buffer.rightCell = this; return(buffer); } } }
public void selectRandomNeigbhourCell() { this.selectRandomSide(new String[4] { "top", "bottom", "left", "right" }); this.NeighbourCell = this.checkWallBetweenCurrentAndNeighbour(new List <String>(new String[4] { "top", "bottom", "left", "right" })); }
public void yWalk() { for (Int32 yWalk = 0; yWalk < this.Cell0x0.getGrid().getYLength(); yWalk++) { this.yWalkBuffer = yWalk == 0 ? this.Cell0x0 : this.yWalkBuffer.getTopCell(); this.WallDrawingReset(); this.xWalk(yWalk); this.Draw(); } }
public void selectRandomCurrentCell() { this.selectRandomCellCoords(); this.CurrentCell = this.Cell0x0; for (Int32 xWalk = 0; xWalk < this.rndXCoord; xWalk++) { this.CurrentCell = this.CurrentCell.getRightCell(); } for (Int32 xWalk = 0; xWalk < this.rndYCoord; xWalk++) { this.CurrentCell = this.CurrentCell.getTopCell(); } }
static void Main(string[] args) { { CellProperties cell = new CellProperties(new GridProperties(10, 10), 0, 0, null, null, null, null); drawGrid draw = new drawGrid(cell); draw.yWalk(); KruskalMazeGenerator kmaze = new KruskalMazeGenerator(cell); cell = kmaze.createMaze(); Console.WriteLine("Final"); draw = new drawGrid(cell); draw.yWalk(); } Console.ReadKey(); }
public KruskalMazeGenerator(CellProperties cell0x0) { Cell0x0 = cell0x0; WallsDown = 0; TotalNumberOfCells = Cell0x0.getGrid().getXLength() * Cell0x0.getGrid().getYLength(); }
public drawGrid(CellProperties cell0x0) { Cell0x0 = cell0x0; }