Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hey there, I need help with this, it must be done in javascript 1 2 4 is one of very few dice games not built

Hey there, I need help with this, it must be done in javascript

1 2 4 is one of very few dice games not built for gambling. It's a game for any number of players. Two to four is probably best. It's a friendly way to pass some time (2 seconds to maybe 10 minutes per game), since it mostly requires you to keep track of your own progress, and trust others to do the same. It moves quickly, so the more players, the harder to keep track of others' play.

So the assignment is

1.Use arrays to help you build a game of 1 2 4 for one person.

An array named roll can hold the three numbers of each roll. (For 1 extra point, use a two-dimensional array to keep track of all numbers rolled throughout the game.)

Feel free to use other arrays if you can find a place for them.

2.Follow the rules of the game.

A. Use Math.floor(Math.random) to simulate each roll of the dice (three times for three dice). Store the results in an array.

B.Did you roll 1 2 4? You win! (Congratulations. Play again?) Otherwise:

C. Did you roll 3 of a kind? Time to start over. Otherwise:

D.Compare all the dice and all the combinations to the required point. (Did you get the point you were looking for?)

If you got the point, check to see if you got the next. Repeat.

If you did not get the point, pass play to the next player. (Note that when there's only 1 player, you just pass to yourself.)

E. When you get all the points through 1 2 3 4 5 6 7 6 5 4 3 2 1, you win. Play again?

F. Display every roll, along with results. You can use a table such as the one above, or use your own layout, but for every roll, show

the point,

the numbers revealed on the dice, and

the result.

NOTE that the instructions you to display an entire game, all at once.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions