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

  What languages seem to be used to create mobile os

What languages seem to be used to create mobile operating systems? Why? What languages are used most often for Web applications? Why?

  Design application to allow user to input a price

Design an application that allows a user to input a price until an appropriate sentinel value is entered.Output is the price of each item on each day,one through seven.

  Plot the dendrogram of your hierarchical clustering model

Plot the dendrogram of your hierarchical clustering model. Using the dendrogram and thinking about this particular appli¬cation, which number of clusters would

  Find out a web site which describes the use of a selection

find a web site that explains the use of a selection structure or an iteration structure in programming. provide the

  Design an employee class

Design an Employee class that has fields for the following pieces of information: Employee Name and Employee Number

  Write a program to add 10 bytes of data and store the result

Write a program to add 10 bytes of BCD data and store the result in R2 and R3. The bytes are stored in ROM space starting at 300H.

  How to change sas system options

How to change SAS system options

  Picbasic program

Comment the function associated with every line of the following PICBASIC program

  Explain the interaction framework

Explain the Interaction Framework discussed by Steven Heim (2008). Choose a computing device (like an ATM machine or the self-check-out at a grocery store

  Why do we have both debug and release builds

When two or more functions have the same name, how does the compiler determine which one to use for a particular function call?

  Write a prolog relation that returns a list

Write another relation (anything you want) that does something not performed above. Explain what your relation does.

  Design electronic submission of assignments from students

This system must manage electronic submission of assignments from students to instructors. It must keep track of which students have submitted assignments and must allow instructors to manage the grading.

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