Important alert: (current site time 7/15/2013 6:36:36 PM EDT)
 

winzip icon

NARSCAR RACE Simulation

Email
Submitted on: 12/12/2000 3:56:14 PM
By: Wilton Marranzini 
Level: Advanced
User Rating: By 9 Users
Compatibility: C++ (general), Microsoft Visual C++, Borland C++
Views: 18047
(About the author)
 
     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.

 

INCLUDE files:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
//**************************************
//INCLUDE files for :NARSCAR RACE Simulation
//**************************************
#include <math.h>
#include <stdlib.h>
#include <iostream.h>
#include <iomanip.h>
#include <time.h>
#include <vector.h>
#include <algorithm>
#include <windows.h>
#include <conio.h>
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 12 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

12/12/2000 4:06:55 PMWill

Please, Leave questions, comment(good or Bad) i can learn from my mistakes. just say something. lol
i play around to much.
buh bye
Wilton Marranzini
(If this comment was disrespectful, please report it.)

 
12/13/2000 7:34:10 PMBrian G.

Very cool for a consule mode program, too good, learn to make them in GUI (windows). Use DirectX or GDI(slow!).
(If this comment was disrespectful, please report it.)

 
12/13/2000 9:56:32 PMWill

Thanks Brian G. and i am trying to learn directX at the moment. Thanks for the comment
(If this comment was disrespectful, please report it.)

 
12/16/2000 7:15:02 PMduane

Good Job, This code uses OOP really well.
(If this comment was disrespectful, please report it.)

 
4/18/2004 6:23:58 PMdeadbyte

Good code
<---xmp
pl>
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.