Advertisement
3_2004-2005 Classes/ Frameworks/ OOP #145769

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

AI Summary: 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.

Source Code
original-source
Upload
<?php
	/*
	Title:
	 dEncryption
	Version:
	 v3
 
	Description:
	 An encryption algorithm with a few twists that I have added.
 
	Author:
	 Jonathan Anders
	 geminii@citcom.net
	 http://www.unixcon.net/~datalogik/scripts/
 
	Usage:
	 function CryptAlg($dString,$dKey,$dType,$dIntense,$dCalcNum)
	 * Where:
	   $dString is the string you wish to encrypt
	   $dKey is your encryption key
	   $dType is to encrypt or decrypt the string ($dType values are 0 or 1,
		0 is encrypt and 1 is decrypt)
	   $dIntense is how many times you wish to encrypt the
		string (makes for a more secure and harder to break string)
		Since the highest ascii value for a text character is 255, if
		you set the $dIntense value to 255, it will just loop back to
		where it was, and intern decrypt what you encrypted.
	   $dCalcNum is the number that will be added or subtracted with when
		ever encryption begins. The math will take place and will affect
		the first ascii number in the two statements.
	Notes:
	 When crypting a string, remember that you MUST have the exact
	 same $dKey, $dIntense, and $dCalcNum variables as the encrypted
	 or decrypted string for it to accurately do it's job.
	*/
	function CryptAlg($dString,$dKey,$dType,$dIntense,$dCalcNum)
	{
		if ($dIntense > 254)
			$dIntense = 254;
		$dNewString = $dString;
		for ($y = 0; $y <= $dIntense; $y++)
		{
			$strOutput = "";
			$x = 0;
			for ($i = 0; $i < strlen($dNewString); $i++)
			{
				if ($x >= strlen($dKey))
					$x = 0;
				if ($dType == 0)
					$strOutput .= Chr((Ord($dNewString[$i]) + $dCalcNum) - Ord($dKey[$x]));
				if ($dType == 1)
					$strOutput .= Chr((Ord($dNewString[$i]) - $dCalcNum) + Ord($dKey[$x]));
				$x++;
			}
			$dNewString = $strOutput;
		}
		return $dNewString;
	}
	$test = CryptAlg("Crypt Algorithm", "testkey1234567890", 0, 110, 1234567890);
	echo "Encrypted text: $test<br>";
	$test = CryptAlg($test, "testkey1234567890", 1, 110, 1234567890);
	echo "Decrypted text: $test<br>";
?>
Original Comments (3)
Recovered from Wayback Machine