https://github.com/neomat-prog/f1-simulator
A Formula 1 simulator with real data
https://github.com/neomat-prog/f1-simulator
f1 javascript nodejs npm
Last synced: 6 months ago
JSON representation
A Formula 1 simulator with real data
- Host: GitHub
- URL: https://github.com/neomat-prog/f1-simulator
- Owner: neomat-prog
- Created: 2025-04-08T18:35:47.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-04-08T20:44:21.000Z (6 months ago)
- Last Synced: 2025-04-08T20:46:55.613Z (6 months ago)
- Topics: f1, javascript, nodejs, npm
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/f1-sim
- Size: 495 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
ποΈ F1 Simulator Package
A complete Formula 1 racing simulation package with real-world data integration, dynamic race features, and realistic race results.π¦ Installation
bash
Copy
Edit
npm install f1-simulator
π Quick Start
import { F1Client, Race, Track } from 'f1-simulator';
```
async function runSimulation() {
try {
const sessionKey = await F1Client.getSessionKey('Monza', 2023, 'Qualifying');
const driversData = await F1Client.getDrivers(sessionKey);const track = new Track('Monza', 75, 95, 3); // name, minLapTime, maxLapTime, DRS zones
const race = new Race({
track,
drivers: driversData,
sessionKey,
laps: 53,
weather: 'dry' // Options: 'dry', 'wet', or 'dynamic'
});await race.initialize();
const results = race.simulate();console.log('\nRace Results:');
results.forEach((driver, index) => {
const status = driver.retired ? 'DNF' : `${driver.time.toFixed(3)}s`;
console.log(`${index + 1}. ${driver.driver.padEnd(15)} ${status}`);
});
} catch (error) {
console.error('Simulation error:', error.message);
}
}runSimulation();
```
π§° Features
β Real F1 data integrationπ Tire degradation modeling
π¨ Safety car deployment probabilities
π DRS system simulation
π₯ Crash and mechanical failure mechanics
β±οΈ Realistic lap time performance calculations
π¦οΈ Dynamic weather changes
π§ Pit strategy planning
π οΈ Custom Simulation
Custom Drivers and Teams
```javascript
const redBull = new Team('Red Bull', 97);
const mercedes = new Team('Mercedes', 95);const customDrivers = [
new Driver('Max Verstappen', redBull, 95, 1),
new Driver('Lewis Hamilton', mercedes, 93, 44)
];
```
Custom Track
```
const customTrack = new Track('Custom Circuit', 80, 110, 2);
Run a Custom Raceconst customRace = new Race({
track: customTrack,
drivers: customDrivers,
laps: 30,
weather: 'wet'
});customRace.initialize().then(() => {
const results = customRace.simulate();
console.log('\nCustom Race Results:');
results.forEach(r => console.log(r));
});
```
βοΈ Advanced Configuration
π¦οΈ Weather Simulation
```
const race = new Race({
// ... other config
weather: 'dynamic',
weatherChanges: [
{ lap: 10, newWeather: 'wet' },
{ lap: 20, newWeather: 'dry' }
]
});
```
π οΈ Pit Strategy
```
const strategies = {
'Max Verstappen': {
15: 'hard',
30: 'medium'
},
'Lewis Hamilton': {
10: 'soft',
25: 'medium'
}
};
```
```
const race = new Race({
// ... other config
pitStrategies: strategies
});
```
π Safety Car Configuration
```
import { SafetyCarSystem } from 'f1-simulator';SafetyCarSystem.probabilities = {
normal: 0.03,
wet: 0.20,
crash: 0.35
};
```
π§Ύ Output Example
```
Race Results:
1. Max Verstappen 3089.452s
2. Lewis Hamilton 3092.781s
3. Charles Leclerc 3095.112s
4. Sergio PΓ©rez DNF
5. Carlos Sainz 3101.334s
```Contributing:
I am very open for people to request commits, to my project. If you have any ideas that could be implemented or bugs squashed just send a pull request and I will be on my way to check it out!π API Documentation
For full API reference and advanced usage, see the API Docs.
https://openf1.org/?javascript#introduction