Create a version of the game of nim that you can play

Assignment Help JAVA Programming
Reference no: EM131113968

JavaScript assignment

In the game of Nim, you have three piles of five stones. During each turn, each player can remove any number of stones from a single pile (a player cannot take stones from more than one pile). The player who removes the last stone from all of the heaps wins.

Here is a sample game:

Pile A

Pile B

Pile C

Action

5

5

5

Game starts

2

5

5

Alice removes 3 stones from Pile A

2

5

0

Bob removes 5 stones from Pile C

2

1

0

Alice removes 4 stones from Pile B

2

0

0

Bob removes 1 stone from Pile B

2

0

0

Alice removes 2 stones from Pile A and wins!

Create a version of the game of Nim that you can play against the computer. Use a JavaScript prompt() to prompt the user to select a pile and number of stones to remove from the pile. For example, if the user enters a3 then you should remove 3 stones from Pile A. If the user enters c5 then 5 stones should be removed from Pile C.

The computer should make smart decisions. For example, if the computer can win in a turn then the computer should make the winning move.

Draw the current state of the piles after each turn. Use console.log() to draw the piles:

Pile A: ooooo
Pile B: ooo
Pile C: ooooo

Reference no: EM131113968

Questions Cloud

Addition to retained earnings : What is the net income for the firm? Suppose the company paid out $41,000 in cash dividends. What is the addition to retained earnings?
Explain and compare forward versus backward internalization : Explain and compare forward versus backward internalization.
Issue of african american overrepresentation in prison : Discuss the issue of African American overrepresentation in prison. Has prison become a "normal" part of growing up for black males in this country? Please use statistics to support position
Value of the shareholders equity account : What is the value of the shareholders' equity account for this firm? How much is net working capital
Create a version of the game of nim that you can play : Create a version of the game of Nim that you can play against the computer. Use a JavaScript prompt() to prompt the user to select a pile and number of stones to remove from the pile.
Method of inquiry - theory or finding : Both Plato and Aristotle have been credited with developing methods of inquiry (empiricism and rationalism), theories - The method of inquiry, theory or finding that is relevant and why it is still relevant today?
How would you incorporate political risk into the capital : How would you incorporate political risk into the capital budgeting process of foreign investment projects?
Explain the difference between a felony and misdemeanor : Research and explain the difference between a felony and misdemeanor, including the difference between a misdemeanor and felony conviction and the consequences
Evaluate the quotations : Compare - contrast, and evaluate -  Mankind is the measure of all things, of all things that they are, and of all things that they are not.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a method that will perform the a division operation

Write a method that will perform the a division operation (divide by) on the numbers passed to it in two variables (numerator, denominator) and outputs the results. Use a try-catch pair to output an error message if the illegal operation of divide..

  Create an application that keeps tracks of the information

Create an application that keeps tracks of the information in such a simple social network. More specifically, your application will allow for user profiles to be added to, deleted from, or looked-up in the social network.

  Implements both the quicksort and mergesort algorithms

Write a program that correctly implements both the Quicksort and Mergesort algorithms. The program should generate an array of 500 random numbers in the 1-100 range. The program should sort the same set of numbers and keep time stamps of how long it ..

  Write a bluej project- birthday paradox

The birthday paradox states that if there are 23 people in a room then there is a slightly more than 50:50 chance that at least two of them will have the same birthday.

  Analyze a current event

Analyze a current event ( you may use an article from the Wall Street Journal, Financial Times, or New York Times, published this week) using any of the principles that you've learned in this class. 2 pages, double spaced, cite article.

  Write an interface for an abstract method

Write an interface, PointingDevice, containing:  an abstract method, getXCoord that returns an int and an abstract method, getYCoord that returns an int.

  Write a java program to practice the use of java file i/o.

Write a Java program to practice the use of Java file I/O. Class methods are needed to break up solution in smaller parts.Program will read several series of heart rates from a file, compute min, max, & fitness quotient for each series, and output ..

  Design and implement a java program that will gather info

Design and implement a Java program that will gather a user's first name, middle initial, lastname, age in years, and 3 lucky numbers. The program should output the following based on the user's input

  Trying to write it java first and then pseudo code

A popular diversion in the United States, "word find" (or "word search") puzzles ask the player to find each of a given set of words in a square table filled with single letters. Trying to write it java first and then pseudo code

  Returns the object with the largest measure

public static Measurable maximum(Measurable[] objects)that returns the object with the largest measure. Use that method to determine the country with the largest area from an array of

  Create a new class called dwelling

1 Create a new class called Dwelling that includes the functionality below 2.    The new class has the attributes of: category - dwelling's category (i.e.:"House", "Condo", "Apartment","shach",etc.), type String numberOfBedrooms - the number of bedro..

  Write the complete code for a public java class

Write the complete code for a public Java class called Change Machine that can hold nickels, dimes and quarters. Include a private instance variable to hold each type of coin that the machine hols.

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