April 2018
Intermediate to advanced
292 pages
6h 44m
English
The last example shown in this chapter involves the application of Dijkstra's algorithm for finding the shortest path in a game map. Let's imagine that you have a board with various obstacles. For this reason, the player can use only part of the board to move. Your task is to find the shortest path between two places located on the board.
To start, let's represent the board as a two-dimensional array where a given position on the board can be available for movement or not. The suitable part of code should be added to the Main method in the Program class, as follows:
string[] lines = new string[] { "0011100000111110000011111", "0011100000111110000011111", "0011100000111110000011111", "0000000000011100000011111", "0000001110000000000011111", ...Read now
Unlock full access