The game ends after a fixed period of time

Assignment Help C/C++ Programming
Reference no: EM131121633

C++ help

The game starts out with n leprechauns. Each leprechaun starts out with a million dollars of gold (i.e., gi = 1,000,000). The player wants to trap as many of these leprechauns in a pit and steal their gold! The leprechauns are all in a row, with each leprechaun at location xi, a double precision floating point number. Initially, the first leprechaun is at x=0, the second at x=1,000,000, ...; i.e., xi = i*gii=0,1,2,....
At every iteration of the simulation, the leprechauns are processed in strict order from i=0,1,2,... The processing of a leprechaun involves these steps:

The leprechaun jumps to a new location xi + r * gi, where r is a random number between -1 and 1.

There is a pit located between -1,000 and 1,000. If -1000 < xi < 1000, then that leprechaun is trapped forever (does not participate in the game anymore) and all his gold is added to the player's score (the player starts with score=0).

If a leprechaun lands right on top of another (k), then the newly arrived leprechaun steals all the gold from k, and the bankrupt leprechaun k exits the game.

The leprechaun then steals half the gold from the nearest leprechauns to his right and left, if he indeed has both neighbours. (If the position moved to is either the largest or smallest value of all xi, then there is only one neighbour that is nearest. In this case he steals half the gold from this nearest neighbour).

The game ends after a fixed period of time (e.g., 20 seconds), at which point the final score is displayed.

Reference no: EM131121633

Questions Cloud

The required changes from the current suppliers : Surplus Styles is a manufacturer of hair care products, including shampoos, conditioners, and hair gels. The company, located in Southern California, bottles the shampoos and other various hair products in their manufacturing plant, but sources th..
In what way do these two isotopes differ from one another : In what way do these two isotopes differ from one another? In what respects are they the same?
What are your immediate thoughts : In consideration of Dalton's (1997) article, "Are Competency Models a Waste," what are your immediate thoughts? For example, if you were a training and development specialist for your own organization, how might you go about solving issues and/or ..
The game ends after a fixed period of time : The game starts out with n leprechauns. Each leprechaun starts out with a million dollars of gold (i.e., gi = 1,000,000). The player wants to trap as many of these leprechauns in a pit and steal their gold! The leprechauns are all in a row, with each..
Briefly explain the characters of commodity : Briefly explain the characters of commodity - What is use value? Exchange value? What about money? Relations between use-value and exchange-value
Can hunt maintain an action against shaft : Hunt , an employee of the Marie Reading School, was injured when the elevator he was operating fell. The school had a contract with Shaft Elevator, Inc., whereby Shaft was to inspect and service the elevator on a regular basis. Hunt contended that Sh..
Write the explicit form of the hybrid orbital : Use hydrogenic atomic orbitals to write the explicit form of the hybrid orbital. Show that it has its maximum amplitude in the direction specified.
Should a single measurement method be used : Should a single measurement method such as historical cost be used? Should the common framework lead to standards that are principles-based or rules-based?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Implement a single-arg constructor

Implement a single-arg constructor that sets the initial capacity of the array, with a default of 10, which also serves as the default (no-arg) constructor. The size of the array, unless it is created from an existing array, is initialized to 0.

  Loops in what ways are the initialization repetition test

in what ways are the initialization repetition test and update steps alike for a sentinel-controlled loop and an

  What is the approximate value of square root 41

What is the approximate value of square root 41?

  Inserts a node with info value x

Complete the code for a function that inserts a node with info      value x before, and a node with info value zafter,each node with      info value y in a linked list with first node pointer p.

  Calculate the total as well as the average payment

Create a C++ application which will read a file of daily payments, calculate the total as well as the average payment, display the results to the screen and write the results to a file

  Create a friend class bestfriend to the class frac

Create a friend class BestFriend to the class frac. Inside the class BestFriend, and implement a function outputfrac() to print the content of the frac instance

  Briefly review programming concepts and discrete mathematics

Discuss the aims and goals of this text and briefly review programming concepts and discrete mathematics -

  Correct code so that it finds the sum of 20 numbers

Correct the following code so that it finds the sum of 20 numbers.

  Write two short c programs and solve four exam-style

write two short c programs and solve four exam-style problems. details on the programs are as follows.program

  Write c program to find the distance travel

Write C program to find the distance travelled at regular intervals of time given the values of 'u' and 'a'. The program should provide the flexibility to the user to select his own time intervals and repeat the calculations for different values of '..

  Create class has three pieces of information as data members

Create a class called Date in C++ that includes three pieces of information as data members: month (type int), day (type int) and yaer (type int).

  Area of information security awareness

For this research exercise, write a 4-5 page APA style paper summarizing research in the area of Information security awareness. You may address and focus on any topics that fall within information security awareness theories and programs.

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