CSCI-1200 Data Structures
Hashi - How to Play
Your program will accept one, two, three command line arguments. The fifirst argument is the name of a puzzle board fifile similar to the fifile on the left. Each row contains information for an island in the puzzle.
The fifirst two numbers are the x and y coordinates. It may be helpful to grab some graph paper. The third number for each island is the total number of bridges connecting this island to the neighboring islands. The islands may be in any order and the fifile may include blank lines. The middle image is a diagram of the initial
We will connect the islands in our puzzle with horizontal and/or vertical bridges. The bridges must be straight and may not cross other bridges or touch other islands. A pair of islands may be connected by at most two direct parallel bridges. This example Hashi puzzle has only one solution (drawn on the right). Your task for the core of this homework is to fifind a solution to the puzzle – a set of edges/bridges (if it exists).
An additional rule of the original Hashi puzzle game is that the islands must be connected. A valid connected solution must allow residents of each island to move to all other islands by following a path of one or more bridges. If the optional --connected command line argument is provided, your code should return a solution that is connected (if a connected solution exists).
Output Formatting
points of the edge may be swapped, and the edges may be listed in any order. If two bridges connect a pair of islands, the edge will be listed twice. After listing the edges, we display an ASCII art representation of the islands and bridges.
If the optional argument --find_all_solutions is specifified, your program should output all valid, unique solutions (in any order) and then also print at the bottom the number of solutions found, e.g., “Found 3 solution(s)”. If the puzzle has no solutions, your program should print “No solutions”. Note that we defifine solution uniqueness by the resulting graph drawn, not the order of the edges or endpoints of an edge.
We provide starter code to read the input puzzle fifile and print a solved or unsolved Hashi puzzle board. You may use or modify any or all of this provided code.
You must use recursion in a non-trivial way in your solution to this homework. As always, we recommend you work on this program in logical steps. Partial credit will be awarded for each component of the assignment. IMPORTANT NOTE: This problem is computationally expensive, even for medium-sized puzzles! Be sure to create your own simple test cases as you debug your program.
Once you have fifinished your implementation, analyze the performance of your algorithm using order notation. What important variables control the complexity of a particular problem? The dimensions of the board (w and h)? The number of nodes/islands (n) and edges/bridges (e)? In your README.txt fifile write a concise paragraph (< 200 words) justifying your answer. Include a table summarizing the running time and number of solutions found by your program on each of the provided examples. Note: It’s ok if your program can’t solve the biggest puzzles in a reasonable amount of time.
You must do this assignment on your own, as described in the “Collaboration Policy & Academic Integrity” handout. If you did discuss this assignment, problem solving techniques, or error messages, etc. with anyone, please list their names in your README.txt fifile.
Homework 6 Hashi Contest Rules
2020-01-29