I am searching for a better algorithm , more computational efficient, for the classical "wolf, goat and cabbage" problem, in Prolog. The algorithm below is based on BFS search for possible situations.
The Problem:
"Once upon a time a farmer went to…
Before I state this, I logically understand the solution to this question, am just having a hard time coding it. A family of 4 is trying to cross a bridge at night. One needs a flashlight to cross the bridge,and only two persons can cross the bridge…
I already made this code, but when I consult it in GNU Prolog, it shows like this.
here is my code
initial(left,3,3,0,0).
final(right,0,0,3,3).
P1=3000.
P2=5000.
P3=8000.
A is P1.
B is P2.
C is P3.
bad([_,A1,B1,C1,A2,B2,C2]):-
( …
At first I solved a problem where I'd have an infinite loop, I fixed that by adding a rule to my CONSTRAIN module.
I've taken all constrains into consideration, but it seems like all the facts are being deleted for some reason...
This my code so…
I have this implication from the classic farmer wolf goat cabbage problem in Artificial Intelligence
The text book says that this rule operates when the farmer and wolf are on the opposite sides of the river.I'm unable to understand the 'if part of…
I've been asked to write a solution to the famous "Goat, Wolf and the Cabbage" scernario. The scenario goes as follows:
The farmer wants to transport all three across the river. However, if:
The goat and the cabbage are left alone, the goat will…
I am developing a program that solves a more complicated version of the infamous puzzle 'The farmer, the fox, the goose, and the grain', which has eight components instead of four. I've already determined the solution; additionally, I've written out…
I am trying to solve the The Farmer, Goat, Wolf, Cabbage riddle in Prolog using the Breadth First technique and I am running into some issues. When I try to gather all the valid combinations for the second level of the tree it fails. Here is the…
So first of all I am sorry for asking this question. But the "Escape from Zurg" article helped me a lot and I could write my own solution to the Wolf Goat Cabbage Problem. I am positing my code below. I want you to tell me
If my code is written in…
So I have to write different procedures that will help me solve the farmer-wolf-goat-cabbage-fertilizer puzzle. For those of you that don't know it, it involves a farmer having to cross from the North bank of a river to the South bank with all the…
Im working on a code to implement different search functions to solve the Farmer Wolf Goat Cabbage problem. We were given several classes that our main and FarmerWolfGoatCabbage class implemented. One of the classes, AbstractSolver includes the…
I am new to dealing with Java and the course I'm taking is showing me some code, but when I am trying to run it. It returns a null pointer exception due to the fact that the parent was never set.
So in an abstract class how do I pass in the Parent?…
I want to write aprolog program that moves family members from one side to another, which would require the parents for example to go back and forth and move the family. I wrote the code below, but it is only moving the members from right to left,…
I am attempting to solve this riddle similar to the Wolf, goat and cabbage problem, and trying to represent it in a graph format (with nodes and edges representing all potential paths).
This is the problem:
2 circus families have got an act where…