Thanks to visit codestin.com
Credit goes to www.scribd.com

100% found this document useful (1 vote)
127 views3 pages

Knight's Travails CST 8203 - Advanced Programming and Data Structure Final Project

This document provides instructions for a final project to use depth-first search (DFS) or breadth-first search (BFS) to find the shortest path a knight can take to move between squares on a chess board. Students are asked to write a function that takes starting and ending square coordinates as input and outputs all squares the knight will stop on along the shortest path between those squares. The document explains the knight's valid L-shaped move pattern and provides examples of the expected output format. It also lists specific tasks for building a game board representation with knight moves as connections in a tree and using an appropriate search algorithm to find the shortest path between starting and ending nodes.

Uploaded by

sppppp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
127 views3 pages

Knight's Travails CST 8203 - Advanced Programming and Data Structure Final Project

This document provides instructions for a final project to use depth-first search (DFS) or breadth-first search (BFS) to find the shortest path a knight can take to move between squares on a chess board. Students are asked to write a function that takes starting and ending square coordinates as input and outputs all squares the knight will stop on along the shortest path between those squares. The document explains the knight's valid L-shaped move pattern and provides examples of the expected output format. It also lists specific tasks for building a game board representation with knight moves as connections in a tree and using an appropriate search algorithm to find the shortest path between starting and ending nodes.

Uploaded by

sppppp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Knight’s Travails

CST 8203 - Advanced programming and Data Structure


Final Project

Now that you learned DFS and BFS, let’s try using our search algorithms on a real
problem. For this project, you’ll need to use a data structure that’s similar (but not
identical) to a binary tree. For a summary of a few different examples, reference this
article:

https://www.khanacademy.org/computing/computer-
science/algorithms/graph-representation/a/describing-graphs

A knight in chess can move to any square on the standard 8x8 chess board from any
other square on the board, given enough turns (don’t believe it? See this animation):

https://upload.wikimedia.org/wikipedia/commons/thumb/d/da/Knight%27s_t
our_anim_2.gif/250px-Knight%27s_tour_anim_2.gif

Its basic move is two steps forward and one step to the side. It can face any direction.
All the possible places you can end up after one move look like this:
Your task is to build a function knight_moves that shows the simplest possible way
to get from one square to another by outputting all squares the knight will stop on
along the way.
You can think of the board as having 2-dimensional coordinates. Your function
would therefore look like:

knight_moves([0,0],[1,2]) == [[0,0],[1,2]]
knight_moves([0,0],[3,3]) == [[0,0],[1,2],[3,3]]
knight_moves([3,3],[0,0]) == [[3,3],[1,2],[0,0]]

 Put together a script that creates a game board and a knight.


 Treat all possible moves the knight could make as children in a tree. Don’t
allow any moves to go off the board.
 Decide which search algorithm is best to use for this case. Hint: one of them
could be a potentially infinite series.
 Use the chosen search algorithm to find the shortest path between the starting
square (or node) and the ending square. Output what that full path looks like,
e.g.:
Ø knight_moves([3,3],[4,3])
=> You made it in 3 moves! Here is your path:
[3,3]
[4,5]
[2,4]
[4,3]

You might also like