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

  Write a program that lets the user enter the total rainfall

Write a program that lets the user enter the total rainfall for each of 12 months into an array of doubles. The program should use two 12-element arrays. One array will hold strings, the names of the 12 months. This array will be initialized when ..

  Create a customer billing service in c

Create a Customer Billing Service in C using the concepts of functions, structures, pointers and file handling. The program must be able to add new customer accounts and search the existing accounts as well.

  Find all the prime numbers between 90,000 and 100,000

Print out the nonzero values in the array and that will be the prime numbers. Print out the numbers 7 per line and make sure they line up on the last digit. (setw(8)???)

  Problem 1greatest common divisor write code for a recursive

problem 1greatest common divisor write code for a recursive implementation of euclids algorithm for searching the

  Multiple heaps

Create an application that has two heaps. Place a linked list into each heap. Select one hundred random numbers. Place each of the random numbers into each heap - CSI 345 - Spring 2014 S2

  Display a list of items and the location in the store

The program should display a list of items and the location in the store. The user must be able to enter the items and location in the store. You will use a class for the items. For this assignment you will implement creating the list, adding eleme..

  8-bit or 16-bit mode, and the prescaling ratio

8-bit or 16-bit mode, and the prescaling ratio. You can assume XTAL = 10M Hz or at the frequency you specify.

  Creating class perform computation and display results

Create a class named Numbers whose Main() method holds two integer variables. Assign values to the variables. Within the class, create two methods, Sum () and Difference (), that compute the sum of and difference between the values of the two vari..

  Write a c function for reversing circular single linked list

Let A and B be two structures of type linked list. Write a function for creating new linked list C that contains elements alternately from A and B beginning with first element of A. If you run out of the elements in one of the lists then append the r..

  Features with the real life scenarios

Explain any three features that must be implemented by the application that will be created by WebSoft Solutions Pvt. Ltd. Support your answer with suitable examples. Relate the features with the real life scenarios.

  Discuss the different c++ loops and their characteristics

Discuss the different C++ loops, their characteristics

  The first will be a structure called point

Create two structures. The first will be a structure called Point and will have as its data members an x and y coordinate. The second will be called Line and will have two Point structures as its data members.

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