Write recursive programs with lists and backtracking

Assignment Help Programming Languages
Reference no: EM13920533

Objectives: For this assignment, you'll learn how to use Prolog to write recursive programs with lists and backtracking.

Problem: There are three parts to this assignment. They are all related.

Part I) (see the included file "chess.pl")

Consider the problem of chess moves of a Knight on a 5x5 chess board. (For now, we shall simplify our problem to just a 5x5 chess board. The solution is the same when we expand it to a 8x8 chess board.)

570_img1.png

Starting at position A (3,3), a Knight can move to any position B. Its rule is that a Knight can move 1 step in the x-direction and 2 steps in the y-direction in one move, or 2-step in the x-direction and 1 step in the y-direction.

The predicate "move1( (X1,Y1), (X2,Y2) )" holds if a Knight can move from the position (X1,Y1) to the position (X2,Y2) in a single move. (See the file "chess.pl" for details.)

Your problem for part (I) is to define a new predicate "path( (X1,Y1), (X2,Y2) , N, P )" which holds if there exists a non-cyclic path P from (X1,Y1) to (X2,Y2) in less than N moves.

Part II) Using your solution to part (I), you are required to define a predicate "shortest( (X1,Y1), (X2,Y2) , P )" which holds if P is a shortest path from position (X1,Y1) to (X2,Y2).

Part III) Finally, you are required to define a predicate "visit ( (X,Y), P, N )" which holds if P is a path starting from (X,Y) from which a Knight can move and that the path ends in exactly N moves.

Attachment:- chess-in-prolog.zip

Reference no: EM13920533

Questions Cloud

Explain the importance of standardized protocol or systems : Explain the importance of standardized protocol or systems when a practice has multiple offices in a given geographic area and employees are expected to rotate among different offices.
Determine the percentage of assets : Determine the percentage of assets that were provided by retained earnings. How much cash is in the retained earnings account?
Flexibility to identify many different information systems : The case study company has provided you with the flexibility to identify many different information systems that are used by the employees. Some systems need strict access control while others should be available to everyone.
Implications of health economic concepts for health care : Assess the value of health care professionals and decision makers understanding the discipline of health economics - Assess current economic trends that influence the cost, quality, and access to care.
Write recursive programs with lists and backtracking : Objectives: For this assignment, you'll learn how to use Prolog to write recursive programs with lists and backtracking. Problem: There are three parts to this assignment. They are all related
Formulate a linear programming model and then solve it : Formulate a linear programming model, and then solve it, to determine how many hours process 1 should be operated each week and how many hours process 2 should be operated each week.
Example of the coercive power of a manager : Question 1: Write down an example of the coercive power of a manager? Question 2: According to the trait model, which of the following trait of leadership helps managers avoid acting selfishly, control their feelings, and admit when they have made..
Service companies that manage inventory : Determine the types of inventories these companies currently manage and describe their essential inventory characteristics. Analyze how each of their goods and service design concepts are integrated.
Total liabilities and stockholders : Total liabilities and stockholders' equity $3,640,500 It was determined at the date of the purchase that the fair value of the identifiable net assets of Conchita was $2,786,200.

Reviews

Write a Review

Programming Languages Questions & Answers

  Framework of the program

Write a program to read in up to 100 positive real values from a data file that everyone will name "p4data.dat" , output them in ascending order , calculate and print the average , the median , the variance , and the standard deviation . The..

  Write a program that will keep track of golf handicaps.

Write a program that will keep track of golf handicaps. To find a player's handicap, you will need to know the player's score, the course rating and the course slope.

  Write a program that display amount of discount on item

Write a program that asks the user to enter number of packages purchased. Program must then display amount of the discount (if any) and total amount of the purchase after the discount.

  Questions on programing problem with the process of analysis

Questions on Programing Problem with the process of analysis and reflection that went on as you developed the project.

  Design implement application displays button-label on screen

Design an implement an application that displays a button and a label on a screen. Every time the button is pushed, the label will display a random number.

  Write statement to determine whether array elements are full

Write the statements needed to determine whether any of the the array elements are null or refer to the empty String. Set the variable hasEmpty to true if any elements are null or empty-- otherwise set it to false.

  Give greedy algorithm to get all n people across bridge

Give a greedy algorithm to get all these n people across the bridge in a fastest way. Describe the algorithm briefly. Prove the correctness.

  Instantiate button group object-add radio buttons to panel

Do the following to add radio buttons to panel: Declare three objects small, medium, and large of type JRadioButton. Instantiate button group object and add buttons to it.

  Write a program using the rand function

Write a program using the rand() function and a large array to find the standard deviation, variance and mean as well as the min and max values of the array.

  Write program to accept data for each student in school

Write the program which accepts data for each student in school- student ID, classroom number, and score on achievement test. Create program which lists total points scored for each of the 30 classrooms.

  Write a program that prompts the user to enter the mass

Write a program that prompts the user to enter the mass of a person in kilograms and outputs the equivalent weight in pounds. Output both the mass and the weight rounded to two decimal places

  Solution-p1mygrade

a) Name this Solution "p1MyGrade" and this project "MyGrade01". b) Write a simple program that does the following:

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd