Questions tagged [river-crossing-puzzle]

See also [tag:water-jug-problem].

See also .

41 questions
1
vote
1 answer

compilation failed in GNU Prolog

other_bank(e,w). other_bank(w,e). % farmer,wolf,goat,cabbage move([X,X,Goat,Cabbage],wolf,[Y,Y,Goat,Cabbage]) :- other_bank(X,Y). move([X,Wolf,X,Cabbage],goat,[Y,wolf,Y,Cabbage]) :- other_bank(X,Y). move([X,Wolf,Goat,X],cabbage,[Y,Wolf,Goat,Y]) :-…
1
vote
1 answer

Optimization for the solution of farmer goat wolf and cabbage problem in Prolog

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…
vaslyb
  • 11
  • 3
1
vote
1 answer

Bridge-Flashlight Puzzle in Prolog

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…
user9404193
1
vote
0 answers

Three thieves with different bags of money

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]):- ( …
helena
  • 39
  • 1
  • 6
1
vote
1 answer

Solving river crossing puzzle using Jess

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…
Odai Mohammed
  • 279
  • 1
  • 5
  • 18
1
vote
1 answer

Predicate Calculus in Prolog-Farmer Wolf Goat Cabbage

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…
techno
  • 6,100
  • 16
  • 86
  • 192
1
vote
1 answer

PDDL - The Goat, Wolf and the Cabbage

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…
1
vote
1 answer

Prolog 'Out of Local Stack'

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…
draxias
  • 11
  • 1
1
vote
1 answer

Farmer goat wolf and cabbage in Prolog via Breadth First Search

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…
1
vote
1 answer

F# Wolf Goat Cabbage

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…
Knows Not Much
  • 30,395
  • 60
  • 197
  • 373
0
votes
1 answer

Choosing all possible options from List in Prolog

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…
Sorin Cioban
  • 2,237
  • 6
  • 30
  • 36
0
votes
2 answers

How do I translate one of my functions into an Iterable function?

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…
0
votes
1 answer

Homework Help, Abstract/Interface Classes

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?…
0
votes
0 answers

Prolog Crossing Puzzle: Double crossing problem

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,…
MOT29
  • 3
  • 1
0
votes
1 answer

How to append multiple items to a nested-list? How do you successfully approach a variation of a river-crossing problem?

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…