41667,First,Please,take,minute,Rate,CodeIt,us
Quick Search for:  in language:    
41667,First,Please,take,minute,Rate,CodeIt,us
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
C/ C++ Stats

 Code: 451,578 lines
 Jobs: 558 postings

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for C/ C++.
Url Test
By Richard Creary on 8/27


Nice Console Calc
By Andrew Carter on 8/26


Visual Pi Hex 2
By jo122321323 on 8/26


Cascade Clone v1.0
By Paulo Jorente - aka JungleBoy on 8/26


Bubble Sort Algo
By d1rtyw0rm on 8/26


Copy File I/O
By Olivier Bastien on 8/25


Visual Pi Hex
By jo122321323 on 8/25


Click here to see a screenshot of this code!ShortCutSample
By Massimiliano Tomassetti on 8/25

(Screen Shot)

AnPMoneyManager beta
By Anthony Tristan on 8/24


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

NARSCAR RACE Simulation

Print
Email
 
winzip icon
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++

Users have accessed this code 4626 times.
 
(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 Simula
//     tion
//**************************************
//     
#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 Winzipto 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 notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
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 PM:Will
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
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/13/2000 7:34:10 PM:Brian G.
Very cool for a consule mode program, 
too good, learn to make them in GUI 
(windows). Use DirectX or GDI(slow!).
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/13/2000 9:56:32 PM:Will
Thanks Brian G. and i am trying to 
learn directX at the moment. Thanks for 
the comment
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/16/2000 7:15:02 PM:duane
Good Job, This code uses OOP really 
well. 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | C/ C++ Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.