Random Race Generator for Forza Horizon 5

forza Horizon 5

Optimizing Race Nights!

Thursday nights is game night with my friends and me. We play Forza Horizon 5 and complete the weekly seasonal quests throughout the night. Sometimes we complete it all early and usually we move on to completing accolades, but recently we have run out of decent accolades to do. So, I was tasked with building a random race generator with Python.

Python Code

Introducing the Python program developed to streamline the race selection process, saving time and adding spontaneity to gaming sessions. It’s a very simple script, only thing that took time was gathering the data for each of the lists.

Here’s the basic Python script I wrote:

import random

#All Racing Variables
location = ['Mexico', 'Rally Adventure', 'Hot Wheels']

carClass = ["X","S2","S1","A","B","C","D"]

typeClass = ["Buggies","Classic Muscle","Classic Racers","Classic Rally","Classic Sports Cars","Cult Cars","Drift Cars","Extreme Track Toys","GT Cars","Hot Hatch","Hypercars","Modern Muscle","Modern Rally", "Modern Sports Cars","Offroad","Pick-Ups & 4X4's","Rally Monsters","Rare Classics","Retro Hot Hatch","Retro Muscle","Retro Rally","Retro Saloons","Retro Sports Cars","Retro Supercars","Rods and Customs","Sports Utility Heroes","Super GT","Super Hot Hatch","Super Saloons","Track Toys","Trucks","Unlimited Buggies","Unlimited Offroad","UTV's","Vans and Utility","Vintage Racers"]

typeClass_2 = ["Hypercars","Extreme Track Toys"]

driveType = ["FWD","RWD","AWD"]

festivalRace = ["Mexico","Apex","Wilds","Cross-Country","Street Racing"]

festivalRace_2 = ["Horizon Raptors","Grit Reapers","Apex Predators"]

festivalRace_3 = ["Speed","Hazard"]

#Roll the Dice
raceLocation = random.choice(location)
carPower = random.choice(carClass)

#Race class corrections
if carClass == "X":
  carType = random.choice(typeClass_2)
else:
  carType = random.choice(typeClass)

#Race type corrections
if raceLocation == "Rally Adventure":
  race = random.choice(festivalRace_2)
elif raceLocation == "Hot Wheels":
  race = random.choice(festivalRace_3)
else:
  race = random.choice(festivalRace)

driveTrain = random.choice(driveType)

#Print results
print("")
print("X"*50)
print("The location of the race is:",raceLocation)
print("The race shall be:",race)
print("The car class is:",carPower)
print("The type of car is:",carType)
print("With the drive train set to:",driveTrain)
print("X"*50)
print("")

Specified Parameters

  • Location: This decides the scene, whether you race in Mexico, Rally Adventure or Hot Wheels.
  • Car Class: This decides the cars power class, “X”, “S2”, “S1”, “A”, “B”, “C”, or “D”.
  • Type Class: This decides what kind of vehicle you will race with, from “Buggies” all the way down to “Vintage Racers”
  • Drive Type: This decides whether you are to race with “FWD”, “RWD”, or “AWD”.
  • Festival Race: This decides what type of race you are to run, I created three different lists for each location.

Necessary Corrections

I needed to create some conditional statements to handle any errors that needed correcting. All that’s left was to print the results to the terminal, so we know what race we have to run.

forza race generator results

Conclusion

The program worked very well, saving a lot of time with which race we should try next. As time goes by, I dare say there will be some more conditional statements needed to handle any more corrections I come across but for now this is pretty effective.

That’s All Folks!

You can explore more of our Python guides here: Python Guides

Luke Barber

Hello, fellow tech enthusiasts! I'm Luke, a passionate learner and explorer in the vast realms of technology. Welcome to my digital space where I share the insights and adventures gained from my journey into the fascinating worlds of Arduino, Python, Linux, Ethical Hacking, and beyond. Armed with qualifications including CompTIA A+, Sec+, Cisco CCNA, Unix/Linux and Bash Shell Scripting, JavaScript Application Programming, Python Programming and Ethical Hacking, I thrive in the ever-evolving landscape of coding, computers, and networks. As a tech enthusiast, I'm on a mission to simplify the complexities of technology through my blogs, offering a glimpse into the marvels of Arduino, Python, Linux, and Ethical Hacking techniques. Whether you're a fellow coder or a curious mind, I invite you to join me on this journey of continuous learning and discovery.

Leave a Reply

Your email address will not be published. Required fields are marked *

Verified by MonsterInsights