-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathengineer.py
More file actions
41 lines (34 loc) · 1.51 KB
/
engineer.py
File metadata and controls
41 lines (34 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import json
class RaceEngineerAI:
def __init__(self, driver_name="Driver"):
self.driver_name = driver_name
def generate_instruction(self, current_lap, tire_age, gap_ahead, gap_behind, deg_rate):
context = {
"driver": self.driver_name,
"lap": current_lap,
"tire_age": tire_age,
"gap_to_front": gap_ahead,
"gap_to_behind": gap_behind,
"deg_rate": round(deg_rate, 3)
}
if tire_age > 15:
priority = "tire management / box"
elif gap_ahead < 1.0:
priority = "aggressive overtake / DRS"
else:
priority = "pace management"
if priority == "tire management / box":
msg = f"BOX BOX. {self.driver_name}, tires are at {tire_age} laps. degradation is {deg_rate}s/lap. we're losing time to the cars behind"
elif priority == "aggressive overtake / DRS":
msg = f"gap to car ahead is {gap_ahead}s. mode push. use the overtake button on the exit of turn 12"
else:
msg = f"pace is good. keep doing what you're doing. gap behind is stable at {gap_behind}s"
return {
"priority": priority,
"radio_message": msg.upper(),
"telemetry_context": context
}
if __name__ == "__main__":
engineer = RaceEngineerAI("NOR")
advice = engineer.generate_instruction(current_lap=20, tire_age=18, gap_ahead=2.5, gap_behind=0.8, deg_rate=0.08)
print(f"ENGINEER: {advice['radio_message']}")