C# чтобы найти путь на доске
The board has 10 row and 10 Column buttons all Green color the board randomly generate 9 red color obstacle. My question is to find the path (changing the green color to white color)starting from entry to exit going horizontally and vertically using only the Green color button.Every time when i hit Go button the green button will change in to white.The program only find one path at a time. for example the first path execute on (2(10)-1) then when i hit Go button again it will find another path. This will continue until all the green button changing in to white. btn 1 is the entry and btn 100 is the exit. i use the click event .....?
file:///C:/Users/Tesfahun/Desktop/c2.png
Что я уже пробовал:
for (int i = 1; i <= 99;) { string btn_name = "btn" + Convert.ToString(i+10); var btn_now = this.Controls.Find(btn_name, true)[0]; btn_name = "btn" + Convert.ToString(i + 1); var btn_next = this.Controls.Find(btn_name, true)[0]; var btn_below = btn_next; if (i <= 10 || i == 20 || i == 30 || i == 40 || i == 50 || i == 60 || i == 70 || i == 80 || i == 90) { btn_name = "btn" + Convert.ToString(i); btn_below = this.Controls.Find(btn_name, true)[0]; } if(btn_next.BackColor == Color.GreenYellow) { if (i <= 10 || i == 20 || i == 30 || i == 40 || i == 50 || i == 60 || i == 70 || i == 80 || i == 90) i+= 1; else i++; btn_now = btn_next; } else { btn_now = btn_next; i+=1; } btn_now.BackColor = Color.White; }