Arama butonu
Bu konudaki kullanıcılar: 1 misafir, 1 mobil kullanıcı
12
Cevap
2364
Tıklama
0
Öne Çıkarma
YOL BULMA ALGORİTMASI (YARDIM LAZIM)
G
11 yıl
Yüzbaşı
Konu Sahibi

Arkadaşlar resimde gördüğünüz harita üzerinde uğraşıyorum. X noktası bulunduğumuz yer ve hedef Y noktası.

1'ler duvar görevinde yani geçilmez alan. 0'lar ise yollar.

Biz X'den Y'ye giden yolu bulacağız. Ve izlediğimiz rotayı yazdıracağız.

Programın çoğu noktası hazır ancak sadece ihtiyacımız olan yolları kullanmamız lazım burada problem yaşıyorum. Algoritmada yardımcı olabilecek ya da örnek bir kod gösterebilecek birileri çıkarsa çok memnun olurum.

Teşekkürler.


< Resime gitmek için tıklayın >

DH forumlarında vakit geçirmekten keyif alıyor gibisin ancak giriş yapmadığını görüyoruz.

Üye olduğunda özel mesaj gönderebilir, beğendiğin konuları favorilerine ekleyip takibe alabilir ve daha önce gezdiğin konulara hızlıca erişebilirsin.

Üye Ol Şimdi Değil



C
11 yıl
Yarbay

Bizimde bir labirent ödevimiz vardı. Stack yapısıyla çözmüştük. Mantığını anlarsan en uygun yapının stack olacağını anlarsın.

Belki faydası olur bir incele verdiğim siteleri

http://www.cs.bu.edu/teaching/alg/maze/

http://www.codeproject.com/Articles/230295/Solve-Maze-Problem-tortuous-game

 
The simplest (to implement) algorithm would be to just keep a stack of locations you've been at, and the route you took from each, unless backtracking gives you that information.

To go back, just pop off old locations from the stack and check for more exits from that location until you find an old location with an untested exit.

By consistently testing the exits in the same order each time, if you know that backtracking to a location comes from down (ie. last time you were at the old location you went down), then you simply pick the next direction after down.

I am not entirely sure what you mean by going back too far though, I would assume you would want to go back to the previous place you have untested routes, is that not what you want?

Note that unless you try to keep track of the path from the starting point to your current location, and avoiding those squares when you try to find new routes, you might end up going in circle, which would eventually make the stack too large.

A simple recursive method which marks the path it takes and never enters areas that are marked can easily do this.

Also, if your thing that moves through the maze is slightly smarter than just being able to move, and hit (stop at) walls, in that it can see from its current point in all directions, I have other algorithms that might help.


Bu mesaja 1 cevap geldi.
DH Mobil uygulaması ile devam edin. Mobil tarayıcınız ile mümkün olanların yanı sıra, birçok yeni ve faydalı özelliğe erişin. Gizle ve güncelleme çıkana kadar tekrar gösterme.