Knights Travails is the solution to a programming challenge given to me through the Odin Project, where I had to use a pathfinding algorithm to get the minum amount of moves a knight should take to go from point A to point B.
My algorthim of choice was the A* since it is optimized to find the result where there is only one exit, on the A* I used the manhattan heuristic formula only a bit modified to better suit the movements of a Knight.
Use the git clone git to install Knights Travails.
git clone https://github.com/ZamboniL/knights_travail.git
You should also have ruby installed in your pc for that check ruby's official installation guide.
Execute:
ruby lib/knights_travail.rb
With the Knighst_Travail folder open in you terminal.
You will then be asked to insert the coordinates for the starting condition, where the knight will start on the board, and the end position, where the knight should get at the end.
What is the start position?
Give a X (from 1 to 8) position:
Give a Y (from 1 to 8) position:
What is the end position?
Give a X (from 1 to 8) position:
Give a Y (from 1 to 8) position:
After this the program will calculate the necessary moves and output to the terminal a chess board with each movement the knight made
You can also test the code on this repl without installing anything!
-
A better understanding of pathfinding algorithms
-
Ruby project organization
-
Even more understanding of OOP
-
How to better plan my projects before starting to code
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.