Questions tagged [river-crossing-puzzle]

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

See also .

41 questions
0
votes
1 answer

cannibals and missionaries

I am a newbie to prolog and started learning prolog. I found the missionaries and cannibals puzzle interesting to solve in prolog. I have researched a lot of forums and found the link which I think is a very good solution. But some how I am not…
user525146
  • 3,918
  • 14
  • 60
  • 103
0
votes
1 answer

General DFS on River Crossers

I'm trying to write a DFS to solve multiple river crossing problems (Fox Goat Cabbage, Jealous Husbands, Mercenaries and Cannibals, etc.). I've written the puzzle classes, but I'm having trouble structuring my solver. I understand how DFS works, but…
0
votes
1 answer

The Farmer's puzzle - recursive rules and accumulators break my approach

I started learning Prolog a few hours ago, and I'm quite stuck trying to implement a solver for the Farmer problem. I know that there are many examples in the net, but for the purposes of learning I'd like to understand why my code doesn't work,…
Haplo
  • 1,368
  • 9
  • 18
0
votes
1 answer

Issues with Prolog's write function

The code below should output: A solution is: The farmer takes the Goat from west of the river to east The farmer crosses the river from east to west The farmer takes the cabbage from west of the river to east The farmer takes the Goat from east…
am3decoy
  • 73
  • 5
0
votes
1 answer

Prolog Expert System for the Farmer Goat Wolf Cabbage Puzzle

I have been tasked with creating a General Expert System in Prolog which you can plug in different knowledge bases to, so it has to be general. The knowledge base that I have to provide with the Expert System is the Farmer Goat Wolf and Cabbage…
0
votes
1 answer

Why doesn't Prolog find a solution for 'Fox, goose and bag of beans puzzle' and shows 'true' instead?

I wanted to solve the "Fox, goose and bag of beans puzzle" with Prolog as an exercise. So I wrote p(left). p(right). valid((Man, Goose, Fox, Beans)) :- p(Man),p(Goose),p(Fox),p(Beans), Man == Goose. valid((Man, Goose, Fox, Beans)) :-…
Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
0
votes
0 answers

Prolog Fox, Goose & Grain riddle, not showing output

I'm trying to solve the fox, goose, and grain riddle (where the farmer can only transport himself and one of the three across the river), and am following the code given here: http://hilltop.bradley.edu/~chris/prolog.html (about 4/5 of the way into…
janvdl
  • 300
  • 1
  • 10
0
votes
1 answer

Cannibals and Missionaries with Strength

i need some help with a math task our professor gave us. Any suggestions would help. The problem is: There are N cannibals and M missinaries. All missionaries have a strenght attribute, which can be 1 or any positive whole number. Strenght…
Mátray Márk
  • 455
  • 5
  • 17
0
votes
1 answer

error:singleton variable[x] in pro-log.how to solve it?

it is missionary -cannibal program and found error at line legal(3,x).legal(0,x). % : mandc(state(3,3,left), [state(3,3,left)], Path)? mandc(state(0, 0, right), _, []). mandc(CurrentState, Visited, [Move | RestOfMoves])…
prjndhi
  • 1,915
  • 4
  • 17
  • 26
-2
votes
1 answer

Develop an algorithm for a transport puzzle

I am challenged by a co-worker to develop an algorithm for the following puzzle. There is a bridge that can only hold two trucks at a time. One end of the bridge, there are heavy granite blocks that need to be transported to the other end of the…
Thracian
  • 651
  • 4
  • 8
  • 24
-2
votes
1 answer

Getting started with basic transportation problems like Wolf, Cabbage, Goat with either C# or F#

OK. this might be a very basic question to please don't flame me but I have been googling I want to learn how to write solutions to transportation problems like Wolf, Cabbage, and Goat or traveling salesman using F# so far my research has taken me…
Knows Not Much
  • 30,395
  • 60
  • 197
  • 373
1 2
3