Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This project consists of writing two programs, one in C++ and one in Java. Both programs will implement solutions of a puzzle using recursive search.

This project consists of writing two programs, one in C++ and one in Java. Both programs will implement solutions of a puzzle using recursive search. The puzzle is known by several names, one of which is Hi Q. The puzzle consists of a game board with a set of holes and a set of pegs placed in the holes. There are several variations in the shape of the board. For this problem, we will use the triangular version. The board is illustrated below: The shaded circles represent holes with pegs and the unshaded circle is a hole without a peg. Moves are made by jumping pegs over other pegs. Using the hole numbering scheme illustrated above,, we can describe moves as triples of numbers (from, over, into) so that (0, 2, 5) means remove the peg from hole, jump over hole 2 and into hole 5. The peg that was jumped over, in hole 2, is removed. The starting configuration of the puzzle has one empty hole, all the other holes have pegs. The from, over and into holes must be next to each other in a straight line, horizontally or diagonaly. In the starting configuration diagramed above, the legal moves are: (0, 2, 5) (14, 9, 5) (3, 4, 5) (12, 8, 5) There are various ways to represent this puzzle in a program. One simple way is to just use a one dimensional array, and list all possible moves as a list of (from, over, into) triples. For a possible move o be legal, the from and over holes must contain pegs, and the into hole must be empty. Moves are made until no more moves are possible.The goal of the puzzle is to leave the fewest number of pegs when the moves run out. The best case is to be left with only one peg. Your programs should allow the user to specify which hole to leave empty at the start, and the maximum number of pegs that can be left at te end to be an acceptable solution. then find and print a a solution that leaves that number of pegs. After printing a solution, allow the user the option of asking for a better solution. If the use asks for a better solution, only print a solution if it contains less pegs left than the last solution, or if it has only one peg left. Solutions can be printed as a list of from, over and into hole numbers.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced MySQL 8 Discover The Full Potential Of MySQL And Ensure High Performance Of Your Database

Authors: Eric Vanier ,Birju Shah ,Tejaswi Malepati

1st Edition

1788834445, 978-1788834445

Students also viewed these Databases questions

Question

6. How do histories influence the process of identity formation?

Answered: 1 week ago