Advertisement
2002ASP Classes/ Frameworks/ OOP #7353

NARSCAR RACE Simulation

First of All Please take a minute and Rate my Code.=) It uses Object Orinted Programming to Make a Nascar Racing simulation. The race is formed of 33 Cars if random aspects effecting it. We start with 33 cars, all of which are identical The race is 500 miles. We're going to do the simulation using clock ticks of .5 seconds. All cars start at zero velocity, and when the race starts they all gain speed at a uniform rate of 0.0020833 miles per second (about 7.5 miles per second) plus a random amount of 5% added or subtracted from the added speed until it reaches a cruising speed of .41667 miles per second (150 miles per hour). It then maintains this speed plus or minus 3%.each car has 20 gallons of fuel. The fuel consumption of the car is normally 30 miles per gallon, divided by the car's current speed divided by 10, e.g. if the car is going 150 miles per hour, its fuel consumption is 30/(150/10)=2 miles per gallon. However, if the car is less than .01 miles (52.8 feet) behind another car, its fuel economy improves by 10% because it's in the draft. However, it cannot stay in the draft more than 100 clock ticks (50 seconds) before the car starts to overheat, in which case the car pulls out of the draft and gets normal fuel mileage. It cannot draft again for 100 clock ticks because the engine has to cool down. A lap in the race is 2 miles, so each time the car has traveled a multiple of two miles we check its fuel. If it doesn't have enough to complete two more laps (4 miles) at the current rate of consumption, it must pull into the pits at the end of the next lap. In this case, when the car comes to the next multiple of two miles (end of lap), it decelerates at the same uniform rate as acceleration (only with no random amount added or subtracted) until it has zero velocity. It then sits for 20 clock ticks (10 seconds) and then accelerates back up to cruising speed.

AI

Podsumowanie AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Kod źródłowy
original-source
Upload
Oryginalne komentarze (3)
Odzyskane z Wayback Machine