Ich versuche, einen Labyrinthgenerator in C#zu machen. Keiner der Zellen ist jemals auf Closed_top, Closed_bottom, Closed_Left, Closed_Right oder Öffnen eingestellt, selbst wenn sie diesen neuen Weg untergehen. /> Finden Sie eine zufällige benachbarte Zelle, die noch nicht besucht wurde. < /li>
Wenn Sie eine finden, ziehen Sie die Wand zwischen der aktuellen Zelle und der benachbarten Zelle. /> Das Problem kommt, wenn ich in eine frühere Zelle (Zelle A) zurückgekehrt bin und zu einer neuen benachbarten Zelle (Zelle B) weitergeht, die noch nicht besucht wurde. Ich kenne, dass mein Code die neue Zelle (Zelle B) besucht und diesen Weg fortsetzt, aber die vorherige Zelle (Zelle A) ist nie mit drei offenen Seiten markiert. < /P>
Ich weiß nicht, was in meiner Logik falsch ist. Ich weiß, dass das gesamte Netz besiedelt wird. Was mache ich falsch? < /P>
Ich versuche, einen Labyrinthgenerator in C#zu machen. Keiner der Zellen ist jemals auf Closed_top, Closed_bottom, Closed_Left, Closed_Right oder Öffnen eingestellt, selbst wenn sie diesen neuen Weg untergehen. /> Finden Sie eine zufällige benachbarte Zelle, die noch nicht besucht wurde. < /li> Wenn Sie eine finden, ziehen Sie die Wand zwischen der aktuellen Zelle und der benachbarten Zelle. /> Das [url=viewtopic.php?t=26065]Problem[/url] kommt, wenn ich in eine frühere Zelle (Zelle A) zurückgekehrt bin und zu einer neuen benachbarten Zelle (Zelle B) weitergeht, die noch nicht besucht wurde. Ich kenne, dass mein Code die neue Zelle (Zelle B) besucht und diesen Weg fortsetzt, aber die vorherige Zelle (Zelle A) ist nie mit drei offenen Seiten markiert. < /P> Ich weiß nicht, was in meiner Logik falsch ist. Ich weiß, dass das gesamte Netz besiedelt wird. Was mache ich falsch? < /P> [code]using System; using System.Collections.Generic; using System.Text;
namespace MazeGenerator { class MapGenerator { private Random random = new Random();
public const int CLOSED = -1;
public const int OPEN_TOP = 0; public const int OPEN_LEFT = 1; public const int OPEN_RIGHT = 2; public const int OPEN_BOTTOM = 3;
public const int OPEN_TOP_LEFT = 4; public const int OPEN_TOP_RIGHT = 5; public const int OPEN_TOP_BOTTOM = 6; public const int OPEN_LEFT_RIGHT = 7; public const int OPEN_LEFT_BOTTOM = 8; public const int OPEN_RIGHT_BOTTOM = 9;
public const int CLOSED_TOP = 10; public const int CLOSED_LEFT = 11; public const int CLOSED_RIGHT = 12; public const int CLOSED_BOTTOM = 13;
public const int OPEN = 14;
public int[] StartingPoint { get; } public int[] EndingPoint { get; }
public int NumCols { get; set; } public int NumRows { get; set; }
public int[,] MapGrid { get; }
public MapGenerator(int numRows, int numCols) { NumCols = numCols; NumRows = numRows;
MapGrid = new int[numRows, numCols]; for (int i = 0; i < numRows; i++) { for (int j = 0; j < numCols; j++) { MapGrid[i,j] = CLOSED; } }
StartingPoint = new int[] { 0, 0 }; EndingPoint = new int[] { numRows - 1, numCols - 1 };
GoDownPath(0, 0); }
private void GoDownPath(int row, int col) { int cellState = MapGrid[row, col];
while (NumberUnvisitedNeighbors(row, col) > 0) { // go down this path int nextCellWall = random.Next(0, 4);
if (nextCellWall == 0) { // go up if (row > 0 && MapGrid[row - 1, col] == CLOSED) { switch (cellState) { case CLOSED: MapGrid[row, col] = OPEN_TOP; break;
case OPEN_LEFT: MapGrid[row, col] = OPEN_TOP_LEFT; break; case OPEN_RIGHT: MapGrid[row, col] = OPEN_TOP_RIGHT; break; case OPEN_BOTTOM: MapGrid[row, col] = OPEN_TOP_BOTTOM; break;
case OPEN_LEFT_RIGHT: MapGrid[row, col] = CLOSED_BOTTOM; break; case OPEN_LEFT_BOTTOM: MapGrid[row, col] = CLOSED_RIGHT; break; case OPEN_RIGHT_BOTTOM: MapGrid[row, col] = CLOSED_LEFT; break;
case CLOSED_TOP: MapGrid[row, col] = OPEN; break;
default: MapGrid[row, col] = OPEN; break; }
MapGrid[row - 1, col] = OPEN_BOTTOM; GoDownPath(row - 1, col); } } else if (nextCellWall == 1) { // go down if (row < NumRows - 1 && MapGrid[row + 1, col] == CLOSED) { switch (cellState) { case CLOSED: MapGrid[row, col] = OPEN_BOTTOM; break;
case OPEN_TOP: MapGrid[row, col] = OPEN_TOP_BOTTOM; break; case OPEN_LEFT: MapGrid[row, col] = OPEN_LEFT_BOTTOM; break; case OPEN_RIGHT: MapGrid[row, col] = OPEN_RIGHT_BOTTOM; break;
case OPEN_TOP_LEFT: MapGrid[row, col] = CLOSED_RIGHT; break; case OPEN_TOP_RIGHT: MapGrid[row, col] = CLOSED_LEFT; break; case OPEN_LEFT_RIGHT: MapGrid[row, col] = CLOSED_TOP; break;
case CLOSED_BOTTOM: MapGrid[row, col] = OPEN; break;
default: MapGrid[row, col] = OPEN; break; }
MapGrid[row + 1, col] = OPEN_TOP; GoDownPath(row + 1, col); } } else if (nextCellWall == 2) { // go left if (col > 0 && MapGrid[row, col - 1] == CLOSED) { switch (cellState) { case CLOSED: MapGrid[row, col] = OPEN_LEFT; break;
case OPEN_TOP: MapGrid[row, col] = OPEN_TOP_LEFT; break; case OPEN_RIGHT: MapGrid[row, col] = OPEN_LEFT_RIGHT; break; case OPEN_BOTTOM: MapGrid[row, col] = OPEN_LEFT_BOTTOM; break;
case OPEN_TOP_RIGHT: MapGrid[row, col] = CLOSED_BOTTOM; break; case OPEN_TOP_BOTTOM: MapGrid[row, col] = CLOSED_RIGHT; break; case OPEN_RIGHT_BOTTOM: MapGrid[row, col] = CLOSED_TOP; break;
case CLOSED_LEFT: MapGrid[row, col] = OPEN; break;
default: MapGrid[row, col] = OPEN; break; }
MapGrid[row, col - 1] = OPEN_RIGHT; GoDownPath(row, col - 1); } } else if (nextCellWall == 3) { // go right if (col < NumCols - 1 && MapGrid[row, col + 1] == CLOSED) { switch (cellState) { case CLOSED: MapGrid[row, col] = OPEN_RIGHT; break;
case OPEN_TOP: MapGrid[row, col] = OPEN_TOP_RIGHT; break; case OPEN_LEFT: MapGrid[row, col] = OPEN_LEFT_RIGHT; break; case OPEN_BOTTOM: MapGrid[row, col] = OPEN_RIGHT_BOTTOM; break;
case OPEN_TOP_LEFT: MapGrid[row, col] = CLOSED_BOTTOM; break; case OPEN_TOP_BOTTOM: MapGrid[row, col] = CLOSED_LEFT; break; case OPEN_LEFT_BOTTOM: MapGrid[row, col] = CLOSED_TOP; break;
case CLOSED_RIGHT: MapGrid[row, col] = OPEN; break;
default: MapGrid[row, col] = OPEN; break; }
MapGrid[row, col + 1] = OPEN_LEFT; GoDownPath(row, col + 1); } } } }
private int NumberUnvisitedNeighbors(int row, int col) { int numUnvisited = 0;
Browser kann keine Funktion mit dem Namen loadSVG im aktuellen Bereich finden, wenn das Einklickereignis der Taste ausgelöst wird. Aus '
window.innerHeight, 0.1, 1000); Loader.Parse (svgdata); //...
Browser kann keine Funktion mit dem Namen loadSVG im aktuellen Bereich finden, wenn das Einklickereignis der Taste ausgelöst wird. Aus '
window.innerHeight, 0.1, 1000); Loader.Parse (svgdata); //...
Ich begegne einen Feder -Start -Startversagen während Maven -Build -Tests in meinem Empfehlung Microservice. Der Fehler zeigt ein ungültiges Zuordnungsmuster /eine ungültige Zuordnungsempfehlung an},...
Problem Ein Enum mit mehreren Feldern muss in der offenen API -Spezifikation definiert werden. Maven org.openapitools: OpenAPI-Generator-Maven-Plugin: 7.10.0 wird verwendet. {
myEnum : {
type :...
Ich arbeite mit der Evernote-API und bin mir nicht sicher, wie ich die Arbeit mit Blöcken richtig verwalten soll, ohne dass mein Code unglaublich chaotisch wird und überall verstreut wird.