Zdrojové kódy: maze.rb
Číselné bludisko je prevedené do grafovej podoby a cesta zo štartu do ciela je nájdená pomocou Dijkstrovho algoritmu na hladanie najkratších ciest.
2.0 2.0 2.0 1.0
2.0 3.0 3.0 3.0
3.0 3.0 1.0 3.0
3.0 1.0 1.0 0.0
Solution: [0,0] -> [0,2] -> [2,2] -> [3,2] -> [3,3] of distance: 6.0
3.0 1.0 1.0 2.0 3.0
2.0 2.0 1.0 2.0 3.0
2.0 1.0 4.0 4.0 1.0
3.0 1.0 4.0 2.0 4.0
3.0 1.0 2.0 3.0 0.0
Solution: [0,0] -> [0,3] -> [0,1] -> [1,1] -> [3,1] -> [4,1] -> [4,2] -> [4,4] of distance: 12.0
1.0 2.0 3.0 1.0 1.0
1.0 3.0 4.0 1.0 1.0
1.0 1.0 3.0 1.0 4.0
1.0 3.0 4.0 2.0 2.0
3.0 1.0 3.0 1.0 0.0
Solution: [0,0] -> [1,0] -> [2,0] -> [3,0] -> [4,0] -> [4,3] -> [4,4] of distance: 8.0
9.0 7.0 9.0 4.0 1.0 3.0 4.0 2.0 8.0 8.0
2.0 5.0 8.0 8.0 1.0 2.0 5.0 1.0 2.0 2.0
3.0 8.0 2.0 6.0 8.0 9.0 5.0 9.0 1.0 2.0
4.0 1.0 4.0 9.0 9.0 7.0 5.0 9.0 5.0 3.0
6.0 9.0 3.0 5.0 1.0 3.0 6.0 7.0 2.0 8.0
1.0 2.0 9.0 9.0 2.0 8.0 9.0 9.0 5.0 9.0
3.0 9.0 5.0 6.0 4.0 9.0 7.0 9.0 1.0 4.0
7.0 9.0 6.0 1.0 7.0 6.0 2.0 5.0 4.0 7.0
1.0 4.0 1.0 2.0 2.0 5.0 1.0 5.0 2.0 6.0
2.0 4.0 6.0 3.0 3.0 3.0 2.0 2.0 9.0 0.0
Solution: [0,0] -> [9,0] -> [9,2] -> [3,2] -> [3,6] -> [8,6] -> [9,6] -> [9,4] -> [9,7] -> [9,9] of distance: 34.0
Zdrojové kódy: