As can be seen from the above table, this puzzle can be solved in 7 steps.
But is this the only solution there is?
To answer the above question we must build a graph of all possible valid moves. Thus we represent (model) the problem in terms of graph theory .
Then we can apply a graph search algorithm to find all possible paths from the start node to the goal node, the shortest path (smallest number of moves needed), etc. See the following video in order to apreciate the usefulness of this graph theoretic approach.
And talking of graphs, the R language has some great packages for solving graph related problems and performing graph analytics. One such package that I have used a lot is igraph . And I will be using this package in this blog to provide a solution to the river-crossing problems.
But before we start working on the solution, it is worthwhile remembering that River-Crossing puzzles come in many flavours and varieties.
This website lists many of these. For example, there is the Farmer-Fox-Chicken-Spider-Caterpillar-Lettuce puzzle where the farmer has to transfer 5 objects, but luckily for the farmer the boat is a bit larger (can carry 3 pieces). There are variants where a particular piece is repeated. For example, in the Farmer-2 Wolves-Dog-Goat-Bag of Grain puzzle we have 2 Wolves and they can eat both the Dog and the Goat.
Then there is the Japanese Family River-Crossing puzzle with its extremely complex rules. Also worth noting is the popular Missionaries-and-Cannibals problem , found in many AI text books.
Actually river-crossing puzzles are in themselves just a subset of the class of wider puzzles called the Transport Puzzles . But this is beyond the scope here - we will just concentrate solely on river-crossing puzzles.
Keeping the above in mind, I opted to try and write as generic a solution as much as possible. After all, the ‘game’ mechanics are nearly the same for all puzzles. It’s only the rules and conditions that change. We will codify the rules separately from the rest of the code.
The rules and conditions that define the incompatibilites (conflicts) between the pieces can themselves be represented using a graph structure. For example in the Farmer-Wolf-Goat-Cabbage, the following graph encodes the rules:
The following R code builds this conflict graph gr . Note that in order to simplify the puzzle solving code, we add all the pieces, even if they do not conflict with any other piece (F for the Farmer in this case.)
Also note that the conflict graph is a directed graph . Wolf eats Goat, but Goat does not eat Wolf - thus we define this as a directed edge (or directed arc in graph theory-speak).
We now move on to the creation of the state space. This is the graph that will contain all valid states (states where no piece ends up as food and all rules of the game are observed).
We start with some configuration for this particular puzzle, and then create the empty graph gss that will store the state space. Note that we created gss as a directed graph - actually using an undirected graph is also valid for a state space graph.
We have to define which of the pieces is the Farmer. Reason is that the code that generates the state space needs to know who will be rowing (handling) the boat. Only the Farmer can operate the boat.
We now create the graph node representing the start state as shown below and add it to the state space graph gss :
We adopt the following node structure for representing a state: each node consists of a list with 3 elements, bank.l , bank.r , and boat.pos . bank.l is a vector containing the pieces that are on the left-hand side of the river, bank.r is contains those pieces that are on the right-hand side, and boat.pos indicates where the boat is (1 for left-hand side, 2 for right-hand side). In the case of the starting state, all pieces are on the left bank ( bank.l ) and the right bank is empty ( bank.r is an empty vector).
We must make a call to the function make.state.name for each state we create. This function constructs a string that serves as a label to uniquely identify that state. For the start state, the string label is: CFGWb| . The pipe symbol ( | ) represents the river and the symbols are placed on the left-hand side or the right-hand side of the pipe symbol according to where they are located. The lower-case character b indicates where the boat is. To ensure consistent labelling of nodes, the symbols for the pieces are sorted in alphabetical order.
Once we have the initial state defined, generating the full state space can be done via a simple call:
Function solve is defined in an R source file called solve_river_crossing_puzzles.R that can be downloaded from here . I won’t go over the code contained in this source file - I think that one can use it as it is without changes for the majority of river-crossing puzzles. Also, there are inline comments for those brave enough to venture in.
After generating the state space graph, we make a call to igraph ’s simplify() function. This removes any duplicate links that might be created by the state space generation code. We also change the colour of the exit node and display the graph.
And here is the state space graph for the Farmer-Wolf-Goat-Cabbage puzzle:
Note that a cursory glance at the above graph shows that there are 2 different solutions for this puzzle, both of length 7. But let’s use igraph ’s pathfinding functions in order to get these programmatically.
igraph has a function get.all.shortest.paths() that, given some node A and another node B, it finds all the shortest paths that connect node A to B. In our case, we apply it to the start node and the goal node as shown below:
The output gives the required two paths:
If you find it a hassle to type in the labels of the start node and the goal node, you can use the following code instead. Although longer, this works for all puzzles, regardless of the symbols used and number of symbols.
As one can notice, the hardest part in R is creating the state space. Finding the solutions leverages the power of the igraph package. Let’s apply our code to some other more complex river-crossing puzzles.
This puzzle is similar to the previous one except that we now have 6 pieces and the boat can carry 3 pieces (the Farmer and any two other pieces).
The conflict graph for this puzzle is given below. Note that we are using the following symbols: M = farmer, F = fox, C = chicken, S = spider, K = caterpillar, and L = lettuce.
We then create the state space graph as follows:
Note how complex (connected) the state space graph is! If we find all shortest paths, we get a total of 40 possible solutions, all of length 7. Only the first few are reproduced below:
This puzzle has a slightly more complex conflict graph as shown below. The symbols used are: F for Farmer, W for Wolf, D for Dog, G for Goat, and B for the Bag of Beans (Note that lower-case b represents the boat).
This puzzle has a total of 4 possible solutions, again all of length 7.
Now we come to a famous river-crossing puzzle that has different style of rules than the ones we have seen so far. Because of this we need to override some of the logic contained in the source file solve_river_crossing_puzzles.R .
This puzzle is made up of 3 cannibals and 3 missionaries. A boat can carry at most 2 persons (anyone can operate the boat). If the number of cannibals on either side of the river outnumber the missionaries, then they will make a meal of the missionaries.
For this puzzle we need to consider counts of objects rather than conflicts between object types. Thus we will override the function is.bank.valid() that is called to check whether the pieces on a bank’s river are according to the rules or not. We do the following:
table() computes a histogram of the number of cannibals and missionaries on this side of the river. We have to handle NA ’s for the cases where there are no missionaries or cannibals on this particular river bank.
We also override the state transition checking in order to relax its strictness - anyone can operate the boat; the only rule is that the boat can not be empty.
The code for creating the state space is similar to that of the previous puzzles:
The resulting state space graph is below:
Note that here we have 4 possible paths, all of length 11. Compare the above state space graph with the one shown on this page .
The final puzzle we will look at is the Japanese Family River-Crossing puzzle , which has some complex conflict rules. We have the Mom (M), Dad (D), 2 Daughters (D), 2 Sons (S), a Policeman (P), and a Thief (T). The rules of this puzzle are:
It’s difficult to represent the above conflicts with a single graph (at least I could not think of a way). Instead we will override the state generation logic as we did for the Missionaries and Cannibals problem. We end up with the following:
We also need to override the state transition checks, since multiple persons can operate the boat:
The state space generation code is similar to that used in solving previous problems:
And the state space graph is shown below:
In this puzzle we have 2 possible shortest paths, both of lenth 17. Note also the number of side branches that terminate with a dead-end. A graph searching algorithm will have to use backtracking a number of times here.
The code snippets used on this page can be found on github . There is also an R notebook that shows code usage, very similar to what has been done here.
I think that the given code provides a somewhat generalised solution to the river-crossing type of puzzles. It can be improved much further and also can benefit from improved packaging - something on my To-do list.
If you use the code, please acknowledgeb the source. Any improvements to the code are most welcome.
And for those that think that these puzzles are not really useful, there is a good book by Dr. Dave Moursund, titled Introduction to Using Games in Education: A Guide for Teachers and Parents . Also came across the following PhD on Games, Puzzles, and Computation , which shows the deep link between puzzles and mathematics and computing.
But perhaps the most important aspect is that they are fun to solve!
Merchandise, store exclusives, sales & deals.
New releases.
Multiplayer accessories.
Happy birthday tom nook.
Explore collections.
Shop by character, super mario.
IMAGES
VIDEO
COMMENTS
Choose a river crossing puzzle above. Each puzzle requires you to get all of the characters across a river in a small boat. The boat can cross the river many times to get everyone across. Can you solve the puzzle in the smallest number of moves? You can earn a Transum trophy for each puzzle you complete.
The classroom teachers enjoy watching the kids use teamwork and attempt to be the first group to "cross the river". If you want specifics and a more detailed list of ideas, strategies and variations - you can download my lesson plan for free below: Free - Cross the River Lesson Plan. It's so fun watching kids complete a challenge for ...
The Benefits of Playing "Cross the River". The key aspect that makes this game ideal for team building activities is the fact that it breaks down barriers between individuals. Victory can be achieved only through solidarity and cohesiveness. It makes people share, not only their personal space but also their thoughts and ideas in hopes of ...
Cross the River Game During the game, members are required to safely move across a Cross the River. Everybody who is on the team, is not allowed to touch the water or river and must utilize platforms in order to cross the river safely.Required Resources:Either a small piece of wood, tire, milk crate, carpet square or rubber baseball base per person or even a piece of paperTo mark off the ...
Can you get all four across the river safely? Only the man and at most one other item are allowed in the boat for each crossing. Only the man is able to operate the boat. Do not leave the goat alone with the carrots or the wolf unsupervised with the goat.
Here are the conditions for this puzzle (also listed in the video): 1. The raft needs at least one animal to paddle it across the river, and it can hold at most two animals. 2. If the lions ever ...
Try your best, work as quickly as you can, and keep your number of moves low to earn more stars. Your total number of stars will help you access more advanced levels. If you like playing chess and solving logic puzzles, then you are all set for new challenges. But unlike chess, you can play this game alone and have a lot of fun.
Step-by-Step Instructions. Form small teams of 2 to 5 people. Challenge each team to solve an imaginary puzzle: Using a small rowboat, how can they transport a chicken, a fox and a bag of corn to the other side of the river in as few moves as possible. To govern fair-play, the solution must acknowledge three critical parameters:
River crossings is a low-floor problem, in that any student can get started by the simple act of trying something and seeing what happens. And then trying something else. This allows the student to focus on the mathematical process and helps develop the problem-solving skill of looking ahead, which is the ability to anticipate the results of ...
River Crossing is an easy to learn, minimal equipment phys ed game that can be played with upper elementary aged students to adults. With plenty of modificat...
River Crossing Riddles are online problem logic challenges to solve. Use arrow up/down to read the instructions of each challenge. INSTRUCTIONS: A farmer wants to cross river and take with him a tiger, a sheep and a carrot. Rules: The farmer is the only one who can steer the raft. He can only take one.
Create a river by marking two river banks with the rope. Make the river wide enough to be a challenge for the group to get from one side to the other (look at about 15 - 25 ft.). Distribute the cardboard squares - 1 piece for every 2 people. Directions. The object of the activity is to get all members of the group safely across the river.
Crossing The River is a river-crossing challenge with one correct answer. Your team gets five essential elements — a chicken, a fox, a rowboat, a woman, and a bag of corn. You see, the woman has a bit of a problem, you tell them. ... Some fun free problem solving games for groups are kinesthetic puzzles like the human knot game, which you can ...
Cross the River is an all-time favourite with children, and they are sure to be excited to play this game in your class. You can use Cross the River for a lesson plan for your PE classes. This game is a brilliant challenge for team building in the classroom as well. Children are required to work in teams to make decisions and develop a strategy ...
Level 1 Level 3 Level 4. The solutions to this and other Transum puzzles, exercises and activities are available here when you are signed in to your Transum subscription account. If you do not yet have an account and you are a teacher, tutor or parent you can apply for one by completing the form on the Sign Up page. A Transum subscription also ...
River crossing activities are a popular team building exercise used in cross selling workshops and retreats. The purpose of a river crossing activity is to foster collaboration, problem-solving, communication and leadership skills - especially within a cross functional group. Participants must work together to "cross a river" using ...
Can you get all six creatures across the river safely? A maximum of two creatures are allowed in the boat for each crossing. The munchkins must never be outnumbered by the monsters. The boat will not move if there is no creature in it.
Cat and Mouse. Cat and Mouse is a fast-paced, exciting team bonding game that will bring your participants closer together through lots of laughter, screams and protests as the 'Cat' chases the 'Mouse'! River Crossing. River Crossing is a competitive fast-paced game of cooperation that requires teamwork, coordination and speed.
Crossing The River With Dogs. 'Crossing the River With Dogs' is a logic-based river-crossing puzzle based on the textbook of the same title. The idea of any river-crossing problem is simple: get all of the people or items from Side A to Side B. The problem-solving aspect comes into play when there is limited room on the 'boat', and the actors ...
Solve The River Crossing Puzzle and Improve Lateral Thinking. Give children the tools to improve lateral thinking by getting them to solve this river crossing puzzle. This activity gives your child a scenario and some cut-outs of characters and items in the scenario. They will need to read the clues carefully and work out how to solve the problem.
The river crossing game is one of many simple games that gives your group the chance to sharpen their problem-solving skills while having a bit of fun. Participants need to cross an imaginary river as a team and they need to get all members of the group safely there.
Rules will be needed to keep the humans safe. The boat can only carry two people (humans or zombies) across at a time. At least one human or zombie has to be in the boat for it to sail. Keep all hands and legs in the boat. The river is too dangerous to swim. If the zombies on one side of the river ever outnumber the humans, even for a moment ...
River-crossing puzzles are a type of puzzle where the objective is to move a set of pieces (objects, animals or people) across a river, from one bank of the river to the opposite bank, using a boat or a bridge. What makes these puzzles interesting are the set of rules and conditions that apply. Typically the boat is only able to carry a limited ...
Shop at the My Nintendo Store for exclusive Nintendo merchandise, video games in digital and physical formats, Nintendo Switch™ systems, and much more.