Construct and animate a solution to frogs and toads puzzle

Assignment Help Programming Languages
Reference no: EM132360785

Programming Languages Assignment -  Solving the Frogs and Toads problem in Scala

Introduction - This project provides (a minimal skeleton for) a Scala application to solve the [frogs and toads puzzle] and to generate an animation of the solution found. This puzzle was originally discussed in the book ["Winning Ways for your Mathematical Plays"] by E.R. Berlekamp, J.H. Conway, R.K. Guy.

Solving this problem - The purpose of this project is to construct and animate a solution to the frogs and toads puzzle for given numbers of frogs and toads. It is the case that this puzzle can always be solved for any starting numbers of frogs and toads.

Note: There is a subtle difference between writing an application to find a solution to a puzzle, if one exists, and constructing a mathematical proof that there must always exist a solution to that puzzle. These are certainly related activities but luckily for us, as programmers, the former is usually a little easier than the latter. We don't need to prove that the frogs and toads puzzle always has a solution, we just need to search for a solution to a specific instance of the puzzle.

Dom's solution to this problem works as follows:

A 'PuzzleState' object describes the positions of the frogs and toads (and the empty cell) at a specific point in time. The 'PuzzleState' object with all the frogs on the left and all the toads on the right is called the *initial state*. The 'PuzzleState' object with all the toads on the left and all the frogs on the right is called the *terminal state.

Define a recursive function with prototype.

We strongly encourage most people to implement a solution based upon the algorithm outlined in their submission for assignment. But if you are really confident, or you would just like to think more about how you might prove that this puzzle always has a solution, then you might want to ponder the following points.

Take a look at the animated images above and observe that they reveal a clear strategy for jumping frogs and toads past each other. Notice in particular that:

  • As the solution unfolds the empty cell shuttles backwards and forwards, moving as far as possible in one direction before it doubles back in the other direction.
  • Most of the moves are jumps, which propagate the empty cell from one side to the other.
  • The only place that a slide occurs is once at the end of each shuttle, as a preparation for the shuttle back in the other direction.

Does this suggest a different strategy for constructing a solution to the frogs and toads problem to you? Can you implement that strategy in Scala?

One advantage of the algorithm we discussed above is that it is relatively easy to see that if there *is* a solution to the puzzle then that algorithm will find it. Why is that the case?

Can you show that an algorithm based on the shuttling observations above will also construct a solution if there is one? Can you use it to show that a solution always exists?

Attachment:- Programming Languages Assignment Files.rar

Reference no: EM132360785

Questions Cloud

Hospitality industry to avoid risk to the business : Why is it important to maintain and monitor occupational licenses in the Hospitality Industry to avoid risk to the business?
How can an organizations reduce unethical behavior : How can an organizations reduce unethical behavior? Does organizational culture impact employee behavior?
Design a business plan based on new innovative venture : BUSS1011 - Entrepreneurship and New Venture Creation - Middle East College - Oman - Business Plan - Design a business plan based on new innovative venture
Write a program that obtains two integer numbers from user : Pseudo code is basically a shorthand way of describing a computer program functions; it creates the logical structure describing the actions to execute.
Construct and animate a solution to frogs and toads puzzle : COMP332 Programming Languages Assignment - Solving the Frogs and Toads problem in Scala, Macquarie University, Australia
Write a program that for any census year input the program : Write a program that for any census year input (e.g., 1970) the program will print the state and its total population with the minimum and maximum.
Compute numbers and create a list that contains the numbers : Write a program that generates all odd numbers from 1 to n. Ask the user for n and set n in the beginning of the program. Use a while loop to compute.
Create the pseudo code from the following request : The program must have some sort of menu that allows users to make selections to do a particular calculation. It must provide five menu items that allow the user
Calculate the syndrome : what is the loss in terms of mean SNR compared with full MRC and Derive the pdf of the SNR at the output of the combiner for the given cases.

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd