Introduction. Code Review Stack Exchange is a question and answer site for peer programmer code reviews. Diagnosing mechanical problems in an automobile. You can move a person/animal/object to the boat by clicking on its cabbageis given by declaring their whereabouts, see Figure 2.12. a constructor that sets the initial and goal states. Heres a listing of the code for the Farmer, the Wolf, the Goat and the Cabbage Puzzle in Python. The Puzzle. But, of course, only the farmer can row it. If left unsupervised, the wolf will eat the goat and the goat will eat the cabbage, but nothing will happen as long as the farmer is near. The Puzzle: A farmer wants to cross a river and take with him a wolf, a goat, and a cabbage. /*10*/ crossing(Current_state,Next_state), Make a wide rectangle out of T-Pipes without loops. The boat also can carry only two things (including the rower) at a time. What to put inside that struct? 4 - Wolf, goat and cabbage problem Once upon a time a farmer went to a market and purchased a wolf, a goat, and a cabbage. There is a boat that can fit himself plus either the wolf, the goat, or the cabbage. The first one is that boat is small, so the wolf, the man can only be with the wolf or the goat or the cabbage. The idea is to recursively walk the graph of feasible moves and bubble the target state up through the recursion. Your task is to get everything to the other side. Then you realize: it can almost not be not solved: every choice is compulsory, except silly direct repetitions. To move the boat to another bank, press the '<<' or '>>' buttons. You (the Farmer), is to try and get all Goat, Wolf and Cabbage to the other side. The wolf will eat the sheep if the farmer is not around. The program contains an interesting feature: the number of crossings is /*14*/ feasible_crossing(Final_state,Final_state. 1. /*15*/ crossing(state(X,X,Go,Ca),state(Y,Y,Go,Ca)):- Next Permutation, Binary Tree Level-Wise Creation and Traversal. Draw a graph representation for the farmer, wolf, goat, and cabbage problem: A farmer with his wolf, goat, and cabbage come to the edge of a river they wish to cross. His rowboat has enough room for the man plus either the wolf or the goat or the cabbage. There is a boat at the river's edge. /*29*/ write_feasible_crossing([H1,H2|T]) :- Now he can take the cabbage (or the wolf) over, and finally return to fetch the goat. bank, Goat will eat Cabbage. Once youve had a bit of practice with sets, try and solve the following challenge: complete the definition for contains_duplicates() which takes a list as an argument and returns a boolean describing whether the list contains duplicate elements or not. The rst one is: Farmer moves with goat from west bank to east bank. Unfortunately, his boat can carry only one thing at a time with him. If the goat and the cabbage are alone on the shore, the goat will eat the cabbage. On a river bank there is a wolf, a goat, and a cabbage. # There is a river with a boat and a bank on each side; that's how rivers work. The declaration can have duplicates but not the structure itself. Then you can realistically "play". Game Over Game over when: Welcome to The Rational BrainThis is the most common river crossing riddle. /*8*/ cross_the_river(_,_):- nl, write("Those are all solutions!"). This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. 2. He drops off the goat and returns alone to the east side. /*26*/ opposite_banks(Y,X). The problem is: A farmer with his wolf, goat and cabbage come to the edge of a river they wish to cross. I don't think sh.goat works if enum item Goat is integer 2. The puzzle posits that you have a wolf, a goat, and cabbage to get across the river, but only one of them at a time. bank, Wolf will eat Goat. /*27*/ opposite_banks(w,e). The correct answer is no, assuming they are asking about the actual data structure. Problem Description Farmer, Wolf, Goat and Cabbage Problem A farmer has a wolf, a goat, and a cabbage on the east side of a river, He wants to move them to the west side of the river. while you stay with them. The boat can only fit 2, 1 for you and 1 for the other. The wolf will eat the goat if they are left together unattended. Like usual with dynamic 2D arrays? A farmer is standing on the west side of the river and with him are a wolf, An animation of the solution His actions in the solution are summarized in the following steps: Take the goat over Return to other side Take the wolf or cabbage over Determine whether goal-driven or data-driven search would be preferable for each of the following problems. The dilemma is solved by taking the wolf (or the cabbage) over and bringing the goat back. The boat was so tiny that it could only take the Farmer himself and one additional passenger. sizeof sh does not work, because it is "only" a paramter array. Learn more. Final_sequence_accu,Final_sequence):- Input streams in the C++ library support reading a single character using a method called get , which returns the next character from the stream.. You may prefer to use the Trinket version, but don't forget to add brackets to the print statements as Trinket uses Python 2.7. Does the 0m elevation height of a Digital Elevation Model (Copernicus DEM) correspond to mean sea level? 2.5.1 Farmer-wolf-goat-cabbage This popular puzzle is a nice example of nding trajectories in the state space: A farmer is standing on the west side of the river and with him are a wolf, a goat and a cabbage. 53 puzzles, some of them of the river crossing type. ecclesiastic, poet, mathematician and teacher from York, Northumbria. The farmer cannot leave the wolf alone with the goat, or the goat alone with the cabbage. This book has some great examples of puzzle-based Python algorithms: As an Amazon Associate I earn from qualifying purchases. There is a boat at the river's edge, but, of course, only the farmer can row. There was a problem preparing your codespace, please try again. . (explore curr-state prev-move path-list move-list): Explores the state space. /*7*/ fail. After, finding the solution path, the print solution makes use of the, ----------- --------------------------------------------, (explore curr-state prev-move path-list move-list), (print-solution (reverse path-list) (reverse move-list)), ((transition-rules curr-state prev-move path-list move-list). A complete graph with 16 vertices has 120 edges. A farmer was returning from the city to his village. This quite sums up what the program does. % wolf, goat and cabbage stay put in their places: Run python fgwcg.py and have fun! Here's a listing of the code for the Farmer, the Wolf, the Goat and the Cabbage Puzzle in Python. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. person/animal/object: I had and have the same problem. The goal is to get to the other side of the river bank. The wolf will eat the goat if the farmer leaves them alone and the goat will eat the cabbage if left alone. Are you sure you want to create this branch? If he leaves the wolf and the goat alone together, the wolf will eat the goat. Work fast with our official CLI. But the salad (to me) is as edible as a wolf is dangerous. What is the best way to show results of a multiple-choice quiz where multiple options may be right? Array rule: "The first dimension is free" (the others are not). The farmer is not really needed, only in the real-world story, and in most implementations including this one. (transition-rules curr-state prev-move path-list move-list): Defines the state transition rules. a. Checks if goal state has been reached or, if current state is a dangerous state. Cabbage across a river in a boat. Let the nodes represent states of the world; e.g., the farmer and the goat are on the west bank and the wolf and cabbage on the east. *** This is a classic Artificial Intelligence (AI) problem. farmer, as well as states that have already been visited. You may prefer to use the Trinket version, but dont forget to add brackets to the print statements as Trinket uses Python 2.7. The sheep will eat the cabbage if the farmer . If the goat and the cabbage are alone on the shore, the goat will eat the cabbage. Without his presence the wolf would eat the goat or the goat would eat the cabbage. Cabbage (soup) and wolf (Peter and) being typical Russian things. For, An interface that declares the methods and instance variables of the class and names its superclass An implementation that actually defines the class (contains the code that, type poly = < draw : unit >. Now I prefer WGC as abbrev., but FSGW is my name for it in the code. Answer to the riddle: First, the farmer puts the goat in the boat and rows to the west side of the river, leaving the wolf behind with the bag of cabbage. Checks if moves can be made and, helper function to change bank state depending on current bank state, Print function uses the path list and move list to print out each. /*20*/ opposite_banks(X,Y). The program outputs each state in the solution, path. You get a message when you make an "illegal" move. The farmer wishes to bring his three charges across the river. Stack Overflow for Teams is moving to its own domain! The high-level symbolic . /*12*/ not(member(Next_state,Final_sequence_accu)), And other problem is, if the wolf and the goat are left together, the wolf will eat the goat, and if the goat will be left unattended with the cabbage, then the goat will eat the cabbage. Figure 2.12: State of the systemfarmer-wolf-goat-cabbage. He has a boat in which he and only one other thing may fit. /*49*/ write("Farmer moves with cabbage from "),write(X_translated), I am thinking of adding an interactive version (called instead of backtrack_fsgw() from main()), giving the user (who has to play blindly) messages like: "Can't take the Salad. Diagnosing mechanical problems in an To review, open the file in an editor that reveals hidden Unicode characters. With int **sh I had to use it like (*sh)[fside]. A farmer goes to market and buys a wolf, a sheep and a cabbage. write(Y_translated),write("."),nl. The goal is to get to the other side of the river bank. PROBLEM STATEMENT A FARMER WITH HIS WOLF, GOAT, AND CABBAGE COME TO THE EDGE OF A RIVER THEY WISH TO CROSS. On the river is a boat in which the farmer and one of the other three (wolf, goat, or cabbage) can fit. wolfcabbagegoat.py. Try to carry Wolf, Goat and The boat has space for only the farmer with one of the items: cabbage, wolf, or goat. The solution can then be determined by walking back up the parent nodes in the solution graph. He can't leave the wolf alone with the goat, or the wolf will eat the goat. He then You were with the goat on that side 6 crossings ago". Determine whether goal-driven or data-driven search would be preferable for each of the following problems. The full output displays the "state of the riversides". write(" to "),write(Y_translated),write("."),nl. But crossing the river by boat, the farmer could carry only himself and a single one of his purchases: the wolf, the goat, or the cabbage. This is . /*39*/ translate(X,X_translated), /*41*/ write("Farmer moves with wolf from "),write(X_translated), A set in Python is defined as an unordered collection of unique elements. Illuminated illustration depicting the wolf, goat and cabbage problem in the Ormesby Psalter, dating to 1250-1330. . About Press Copyright Contact us Creators Advertise Developers Terms Privacy Policy & Safety How YouTube works Test new features Press Copyright Contact us Creators . For, Some words such as : in the previous section, are called defining words, because they are used to define new words ( squared in the previous section); these words are one of the, Type checking of a functor consists of checking that the functor body matches the ascribed result signature, given that the parameters of the functor have the specified signatures. On his way home, the farmer came to the bank of a river and rented a boat. We are going to be solving this old-as-time logic puzzle, which Wikipedia claims dates back to the 9th century: A farmer has a wolf, a goat, and a cabbage that he wishes to transport across a river. /*50*/ translate(w,"west bank"). He has a boat in which he and only one other thing may fit. Connect and share knowledge within a single location that is structured and easy to search. Farmer moves with wolf from west bank to east bank. /*42*/ write_crossing(state(X,W,X,C), state(Y,W,Y,C)) :-. I'm Dan Schlegel, an Assistant Professor in the Computer Science Department at SUNY Oswego Water leaving the house when water cut off, How to constrain regression coefficients to be proportional. By clicking Accept all cookies, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. CS 520: Planning Example for Wolf/Goat/Cabbage 16:198:520 Instructor: Wes Cowan Consider the classic problem: you are on one side of a river with a wolf, a goat, and a cabbage. Draw the complete state space search graph for the farmer, wolf, goat, and cabbage problem. He wanted to move a Wolf, a Goat and a Cabbage across a river with his tiny boat. I even take a[14] and then [1+4][2], because the first index is optional / array has no bounds. /*31*/ write_feasible_crossing([H2|T]). DFS explores each potential solution path as deep as possible until it. He leaves the cabbage o and takes the Hi There! There is a boat at the rivers edge, but of course only the farmer can row. It is designed to be run in a console, so has a clear method to clear the console to keep things tidy. Beside the farmer there is only room for one item in the boat. There is a boat that can fit himself plus either the wolf, the goat, or the cabbage. So, a set declared by my_set = {1, 2, 2, 5} will be stored and displayed as {1, 2, 5} (potentially with the elements in any order). /*3*/ cross_the_river(Initial_state,Final_state):- What is the effect of cycling on weight loss? I just wanted to show how to handle multiple layers of arrays, even if there is no matching typedef. The Farmer-Wolf-Goat-Cabbage riddle Once upon a time, there was a Farmer who had a tiny boat. This time the farmer also starts with taking the goat across the river. In the river there is a small boat. Draw the complete state space search graph for the farmer, wolf, goat, and cabbage problem. If you just want to enjoy the puzzle, with some nice graphics, theres some great versions on here on Trunsum Maths. Raw. Your email address will not be published. Sets are a less known but very useful data structure in Python. It is designed to be run in a console, so has a clear method to clear the console to keep things tidy. 1 Overview. He wrote a textbook Solution 1: Taking wolf on other side will leave goat and cabbage together. Indicate the paths that are discarded due to constraint violations or duplicate nodes. The goat will eat the Cabbage (soup) and wolf (Peter and) being typical Russian things. /*5*/ reverse(Final_sequence,Final_sequence_r), However, the /*19*/ crossing(state(X,W,Go,X),state(Y,W,Go,Y)):- Use Git or checkout with SVN using the web URL. He returns and picks up the goat, If the wolf and the goat are alone on one shore, the wolf will eat the goat. write(" to "),write(Y_translated),write("."),nl. I would say a move is two bits: one of W, G or C. The state (i.e. A tag already exists with the provided branch name. In C, why limit || and && to evaluate to booleans? Have you heard of the puzzle about the farmer, the wolf, the goat and the cabbage? Use MathJax to format equations. If you leave Wolf and Goat on the same bank, Wolf will eat Goat. /*44*/ translate(Y,Y_translated), /*45*/ write("Farmer moves with goat from "),write(X_translated), He wants to move them to the west side of the river. Is cycling an aerobic or anaerobic exercise? % goat and cabbage stay put in their places: So lets be clear about an important point: set declaration is different to the data structure. By clicking Post Your Answer, you agree to our terms of service, privacy policy and cookie policy. A tag already exists with the provided branch name. Here's sakharov's version: This is an old and famous Russian puzzle. The program has a recursive function to emulate the DFS which, calls another function which keeps track of the state transition rules. You (the Farmer), is to try and get all Goat, Wolf and Cabbage to the other side. Done. Farmer, wolf, cabbage, sheep is a famous river crossing puzzle. I chose "Animals". /*13*/ feasible_crossing(Next_state,Final_state. Hence, the farmer will first take goat on the other side and return back alone. How can the farmer cross the river with all three items, without one Plus other pointer-is-not-array related warnings and errors. This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. Why are only 2 out of the 3 boosters on Falcon Heavy reused? Question: Give the graph representation for the farmer, wolf, goat, and cabbage problem of figures in the Prolog supplementary programming material. MathJax reference. You can take on the boat with you Discuss the advantages of breadth-first and depth-first for searching this space. Thanks for contributing an answer to Code Review Stack Exchange! You would like to transfer both animals and the vegetable to the other side. document.getElementById( "ak_js_1" ).setAttribute( "value", ( new Date() ).getTime() ); Your email address will not be published. The wolf will eat the goat if they are left together unattended. Can he ferry all 3 to the other side under these rules/constraints? Only the farmer can separate the wolf from the goat and the goat from the If nothing happens, download Xcode and try again. Are you sure you want to create this branch? across the river with him. cabbage. CS 480/580: Artificial Intelligence, Prof. Cindy Marling 1 The Farmer, Wolf, Goat and Cabbage Revisited Recall that we have already solved this problem in Prolog A farmer with his wolf, goat, and cabbage come to the edge of a river they wish to cross. Why can we add/substract/cross out chemical equations for Hess law? If you leave the . (if you do choose the other, it is not the start of a cycle, but a (silly) direct repetition). It feels wrong now to turn "cabbage" into "salad". Loading and unloading is separate from crossing, a nice way to distract the player a bit. /*38*/ write_crossing(state(X,X,G,C), state(Y,Y,G,C)):- As can be seen, the farmer must rst take the goat across the river. You are on the bank of a river with a boat, a cabbage, a goat, and a wolf. Farmer moves with goat from east bank to west bank. the goat, and then lands where the wolf and the cabbage are. The farmer cannot leave the wolf alone with the goat or the goat alone with the cabbage. Farmer moves from east bank to west bank. Some use fox, hen and beans. There is a boat at the river's edge, but, of course, only the farmer can row. Then he leaves the goat at the starting point and returns and picks up the wolf. % wolf and cabbage stay put in their places: It goes on of course finding "solutions" if not stopped by a maxlevel. /*28*/ opposite_banks(e,w). All safely crossed the river. takes the cabbage over to where the wolf is. My goal here is to teach about Python programming. The puzzle is as follows. In the river there is a small boat. Give the graph representation for the farmer, wolf, goat, and cabbage problem of Section 15.3 (see Figures 15.1 and 15.2). The state of the systemfarmer-wolf-goat- The second property can lead to a lot of confusion. A first [] on the right is same as a (*) around the identifer. I read long ago the story's traces get lost in the Middle Ages. but of these only one is acceptable as a state of the problem: On(Wolf, Bank2) ^ On(Goat, Bank1) ^ On(Cabbage, Bank2) ^ On(You, Bank1). It's free to sign up and bid on jobs. the river no state may appear twice. You have a boat that will hold any single animal or vegetable. the river, the goat will eat the cabbages. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. the wolf will eat the goat. There are two problems. /*4*/ feasible_crossing(Initial_state,Final_state, The farmer's challenge was to carry himself and his purchases to the far bank of the river, leaving each purchase intact. There are no bridges /*6*/ write_feasible_crossing(Final_sequence_r), If nothing happens, download GitHub Desktop and try again. On his way home, he has to cross a river by boat from one side to the other. Any general ideas for this specific case ? /*11*/ not(unsafe(Next_state)). If the goat and the cabbage are alone on the shore, the goat will eat the cabbage. Four protagonists caught in a trap, since the story imposes on us from the outset that the farmer must cross a river in a small boat that can only hold two, and he could not leave . On his way home, the farmer came to the bank of a river and rented a boat. On first view it seems a dilemma. sakharov.net has a very nice description (calling it "Russian"). Farmer moves from east bank to west bank. However both the wolf and the goat as well . Farmer, Wolf, goat, and Cabbage problem A farmer has a wolf, a goat, and a cabbage on the east side of a river. 2. /*43*/ translate(X,X_translated), The farmer wants to cross the river from the east shore to the west shore, but his boat is small. Indicate the paths that are discarded due to constraint violations or duplicate nodes. I prefer the last version: it shows that we want only address and size of sh_0. Would a struct shores be more flexible for passing, for putting in an array and for accessing? A farmer with his wolf, goat, and cabbage arrive at the bank of a river. Propositiones ad Acuendos Juvenes(in English: Problems to Sharpen the Young) containing There are many graph path-finding algorithms to choose from and their effectiveness depends on the structure of the graph. rev2022.11.3.43005. By renaming Sides_t with FSGW_t, and duplicating it manually, you can also live without Shores_t. Ahmed Nasser Saleh Welcome 2. The boat is tiny and can only carry one passenger at a time. Learn more about bidirectional Unicode characters, Solves the farmer, wolf, goat, cabbage problem implementing a state space search, approach (Depth-first search). This is a Farmer Goat Wolf Cabbage Riddle Game Premise The Farmer, Goat, Wolf and Cabbage are on the left side of the River Bank. ORAVA oesnt reci FU,W,G,C} initial state epth_first teError: 1 11 alicatx prin {W,C}{F,G} bute solution ngaro e getting tWrite a Python class, Wolf GoatCabbage, that describes the Wolf, goat and cabbage problem (same problem from HW #2) and can t1. The Riddle - Farmer Wolf Goat Cabbage A farmer is on the west bank of a river with a wolf, a goat and a cabbage in his care. There are two properties which make them especially helpful for solving certain types of problems. For completeness the output of running the code is: State (leftBank=Bank (members= [FARMER, WOLF, CABBAGE, GOAT]), rightBank=Bank . It is a kind of benign, non-branching cycle. a goat and a cabbage. THE BOAT ALSO CAN CARRY ONLY TWO THINGS (INCLUDING THE ROWER) AT A TIME. With or without typedef int Side_t[4]. You signed in with another tab or window. A boat at the river's edge is only large enough for the farmer and one of his possessions. WITH silly reps included, you get an enormous number of boring branches. Try to carry Wolf, Goat and Cabbage across a river in a boat. It's familiar to some of us, but there are many variations, and so describing your. who is where after n moves) is 3 bits, Farmer, Wolf, Goat and Cabbage Problem: full decision tree in C, Making location easier for developers with new data primitives, Stop requiring only one assertion per unit test: Multiple assertions are fine, Mobile app infrastructure being decommissioned, SPOJ problem: Life, the Universe, and Everything, Minimum Spanning Tree using Prim's algorithm and an indexed minimum priority queue, Constructing and maintaining a complete binary tree, AVL tree insertion and deletion of nodes in C, AVL tree insertion and deletion of nodes in C. 2.0, Unbalanced Binary Search Tree insertion and search with random and sorted values, Implementation of tree with different node types and faux-polymorphism in C, Time and Space Complexity of Leetcode Problem #31. Site design / logo 2022 Stack Exchange Inc; user contributions licensed under CC BY-SA. I put a backtracking algorithm around the Farmer, Wolf, Goat and Cabbage problem - to see if there are any interesting branches, besides the (two) 7-step solutions. Diagnosing mechanical problems in an [] Asking for help, clarification, or responding to other answers. A man, a wolf, a goat and a cabbage are on the bank of a river. /*17*/ crossing(state(X,W,X,Ca),state(Y,W,Y,Ca)):- /*22*/ opposite_banks(X,Y). Farmer, Wolf, Goat, Cabbage Puzzle. This is, Figure 2.14: Second solution river crossings for farmer, wolf, goat and cabbage. Is a planet-sized magnet a good interstellar weapon? There is a boat that can fit himself plus either the wolf, the goat, or the cabbage. /*51*/ translate(e,"east bank"). The farmer has the option of crossing the river with the wolf, the goat, the cabbage, or himself. I understand, from your description, this requires three bits. Let the nodes represent states of the world; e.g., the farmer . The Farmer, Wolf, Duck, Corn Problem Farmer, Wolf, Goat, Cabbage Farmer, Fox, Chicken, Corn Farmer Dog, Rabbit, Lettuce A farmer with his wolf, duck and bag of corn come to the east side of a river they wish to cross. % Farmer and wolf change river bank. Draw the complete state space search graph for the farmer, wolf, goat, and cabbage problem. A farmer wishes to transfer (by boat) a wolf, a goat, and a cabbage from the left bank of a river to the right bank. Have a go at creating and modifying some sets. Farmer moves with goat from west bank to east bank. Problem A farmer with a wolf, a goat, and a container of cabbage are on the west bank of the river. Also, dont limit yourself to integer elements try string and other data types too. /*2*/ cross_the_river(state(w,w,w,w),state(e,e,e,e)). Cannot retrieve contributors at this time. /*46*/ write_crossing(state(X,W,G,X), state(Y,W,G,Y)) :-. Justify your answer. to properly determine the next move. But I don't want it small and fast. Why don't we know exactly where the Chinese rocket will fall? /*30*/ write_crossing(H1,H2), Do I have to make an array of pointers? Solves the farmer, wolf, goat, cabbage problem implementing a state space search approach (Depth-first search). crossings are danger-ridden: If the farmer leaves the goat with the cabbages alone on the same side of This popular puzzle is a nice example of nding trajectories in the state space: They want to cross to the other bank, and the man can ferry each across, one at a time. If you leave Goat and Cabbage on the same Then it has to define the working objects itself: Now sh and sh_0 have difference of two (FSGW_ts), so in memcpy() the diff has to be multiplied. Farmer moves with cabbage from west bank to east bank. The "2" is just to give information and reflects the limited range of 'from' and 'to' (0 and 1). [Initial_state],Final_sequence),nl, Books for Learning Algorithms and Data Structures, Python Programming Challenge - Counting Pairs - Compucademy. (F W G C) farmer takes goat across *** problem solved! The boat can only fit 2, 1 for you and 1 for the other. The farmer wants to cross the river with all the three items that are with him. There is nothing special about the class, A Gentle Guide to Constraint Logic Programming via ECLiPSe, 3rd Edition - Free Computer, Programming, Mathematics, Technical Books, Lecture Notes and Tutorials. a. If the wolf is left alone with the goat, the wolf will eat the goat. Final_sequence,Final_sequence):- !. Determine whether goal-driven or data-driven search would be preferable for each of the following problems. This is the filtered output lines (both kinds). river bank. To review, open the file in an editor that reveals hidden Unicode characters. It only takes a minute to sign up. ^ ~"vji"F, ^lfDlhD](i ^vDl,sM MshsTMs3flhM. This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. To learn more, see our tips on writing great answers. Instead of going back empty at the end to fetch the lone goat, you can take back the wolf or salad, whichever you did not carry last. a. The wolf is not interested in the cabbage. The program outputs each state in the solution path. and then lands where the wolf and the cabbage are. [Next_state|Final_sequence_accu],Final_sequence). /*35*/ translate(X,X_translated). If you leave the wolf with the goat, it will eat the goat. The boat also can carry only two things (including the rower) at a time.