Question: CSC435 Programming Languages Proiect 4 Project Details In this project, you will write a simple program in Prolog to solve the following puzzle: In a

CSC435 Programming Languages Proiect 4 Project Details In this project, you will write a simple program in Prolog to solve the following puzzle: In a children's story, three foxes and three hens are traveling together. They come to a river they must cross. There is a boat, but it will hold no more than two of them at a time, so at least six trips in each direction will be required (one animal has to row the boat back each time). The problem is that the hens cannot trust the foxes; if in the process of crossing the river we ever end up with more foxes than hens on either shore, the foxes are likely to eat the hens. We need a series of moves (trips across the river in the boat) that will get the entire party across safely. Your main predicate should be a goal solve(P). It should instantiate P to be a list of configurations, each of which indicates the location of the animals and the boat. If you request additional solutions (by typing a semicolon) the interpreter should give you additional lists, as many as there are unique solutions. One simple, minimal way to represent a configuration is to give the number of foxes, hens, and boats on the near (left) shore: LF, LH, LB), where 0 You can think of the state space of this problem as a graph in which nodes are configurations and edges represent feasible boat trips. It's a large graph, however, and you won't want (nor in fact are you permitted) to represent it explicitly in your Prolog database. From any given state, you'll need to figure out the set of possible neighbors to explore. You'll also want to keep track of where you have been, so you don't get stuck in a cycle. You may find it helpful to use the not operator. You may also want to use the cut to avoid unnecessary backtracking. You are not permitted to use assert, retract, or other database- modifying predicates. For the record, you must compute your solutions. You are not allowed to figure them out by hand and simply write a program that prints them.) CSC435 Programming Languages Proiect 4 Project Details In this project, you will write a simple program in Prolog to solve the following puzzle: In a children's story, three foxes and three hens are traveling together. They come to a river they must cross. There is a boat, but it will hold no more than two of them at a time, so at least six trips in each direction will be required (one animal has to row the boat back each time). The problem is that the hens cannot trust the foxes; if in the process of crossing the river we ever end up with more foxes than hens on either shore, the foxes are likely to eat the hens. We need a series of moves (trips across the river in the boat) that will get the entire party across safely. Your main predicate should be a goal solve(P). It should instantiate P to be a list of configurations, each of which indicates the location of the animals and the boat. If you request additional solutions (by typing a semicolon) the interpreter should give you additional lists, as many as there are unique solutions. One simple, minimal way to represent a configuration is to give the number of foxes, hens, and boats on the near (left) shore: LF, LH, LB), where 0 You can think of the state space of this problem as a graph in which nodes are configurations and edges represent feasible boat trips. It's a large graph, however, and you won't want (nor in fact are you permitted) to represent it explicitly in your Prolog database. From any given state, you'll need to figure out the set of possible neighbors to explore. You'll also want to keep track of where you have been, so you don't get stuck in a cycle. You may find it helpful to use the not operator. You may also want to use the cut to avoid unnecessary backtracking. You are not permitted to use assert, retract, or other database- modifying predicates. For the record, you must compute your solutions. You are not allowed to figure them out by hand and simply write a program that prints them.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
