-1
我買了我的迷宮求解一個問題,當我運行求解它在圖形變量給出了一個錯誤C#迷宮求解圖形
private bool solveMaze(int xPos, int yPos, bool[,] alreadySearched)
{
bool correctPath = false;
bool shouldCheck = true;
Bitmap map = (Bitmap)Mazebox.Image;
Graphics gfx = null;
gfx = Graphics.FromImage(map);
Brush b = new SolidBrush(Color.CornflowerBlue);
//out of index check
if (xPos >= XTILES || xPos < 0 || yPos >= YTILES || yPos < 0)
shouldCheck = false;
if (map.GetPixel(xPos , yPos) == Color.Green)
{
correctPath = true;
}
//Search the Tile
if (shouldCheck)
{
//mark tile as searched
alreadySearched[xPos, yPos] = true;
//Check right tile
correctPath = correctPath || solveMaze(xPos + 1, yPos, alreadySearched);
//Check down tile
correctPath = correctPath || solveMaze(xPos, yPos + 1, alreadySearched);
//check left tile
correctPath = correctPath || solveMaze(xPos - 1, yPos, alreadySearched);
//check up tile
correctPath = correctPath || solveMaze(xPos, yPos - 1, alreadySearched);
}
//make correct path gray
if (correctPath)
{
gfx.FillRectangle(b, xPos, yPos, 10, 10);
Mazebox.Image = map;
}
return correctPath;
}
我認爲問題是,他打開它了很多,然後它墜毀(無窮大) 任何人都可以幫助我解決這個問題嗎?
做到這一點,你可以包括錯誤? – Henrik 2013-04-07 12:29:48
我修復了這個錯誤,但現在我的問題是它說我不能解決我的迷宮,但idk爲什麼 – Pay4yourlife 2013-04-07 12:32:04
你嘗試執行A *權? – 2013-04-07 12:52:25