How to Implement Self-Driving Cars in Video Games Using T.E.D.D. 1104

Dec 11, 2023 | Data Science

The world of AI and gaming has taken a leap toward innovation with projects like T.E.D.D. 1104. This supervised deep neural network aims to teach cars how to drive in popular video games, notably Grand Theft Auto V. If you’re fascinated by autonomous vehicle technology and want to learn how to implement it in video games, you’re in the right place!

Project Overview

T.E.D.D. 1104 is designed to drive vehicles autonomously by learning from human gameplay data. The model navigates through waypoints while avoiding obstacles like cars and pedestrians. Its adaptability makes it suitable for various game environments, harnessing valuable insights from human inputs.

Demo of self-driving car in GTA V Another demo of self-driving car in GTA V

Setting Up Your Environment

Requirements

  • Operating Systems: You can train and evaluate models on any Operating System (Linux is used for training), but run real-time inference in Windows 10/11.
  • Python: Version 3.7 or newer (3.9.7 tested).
  • Libraries: Pytorch, torchvision, PyTorch Lightning, and others as listed in the README.

Installation Steps

  • Install required libraries via pip (e.g., pip install torch torchvision pytorch-lightning).
  • Download the T.E.D.D. 1104 repository from GitHub.
  • Follow the specific instructions in the Software and HOW-TO Section of the repository.

Executing Real-Time Inference

Configuring the Game

To set up your game for real-time inference, you can use either windowed or full-screen mode:
  • For windowed mode:
    • Run GTAV and set it to windowed mode.
    • Adjust the game resolution (e.g., 1600×900).
    • Run the script with the command: python run_TEDD1104.py --width 1600 --height 900.
  • For full-screen mode:
    • Run GTAV on your main screen and set it to full-screen mode.
    • Configure the game’s resolution according to your screen.
    • Run the command: python run_TEDD1104.py --width 2560 --height 1440 --full_screen.

Running the Model

Use the following command to run the model:
python run_TEDD1104.py --checkpoint_path models/TEDD1107_model.ckpt --width 1920 --height 1080 --num_parallel_sequences 5 --control_mode keyboard

Ensure you set the camera view to first-person and choose a waypoint on the minimap.

Training Your Own Model

If you wish to train a model from scratch, you can do so using:
python train.py --train_new --train_dir dataset/train --val_dir dataset/dev --output_dir runs/TEDD1104-base --encoder_type transformer --batch_size 16

This command sets the necessary parameters to initiate the training process.

Troubleshooting

If your model isn’t performing as expected—like not responding or selecting the same action—you can check the input images by pressing L while the script runs. For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai. If you encounter any other issues or need further assistance, consider the following troubleshooting tips:
  • Double-check your library versions to ensure compatibility.
  • Verify that you’ve followed the game configuration steps correctly.
  • Make sure your GPU has adequate processing speed for real-time inference.

Final Thoughts

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations. In conclusion, implementing a self-driving car in video games can be straightforward with the right tools and understanding. Dive in, experiment, and enjoy the remarkable journey into AI-powered gaming!

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox