Giter Club home page Giter Club logo

gtav-rewardhook's Introduction

GTAV RewardHook

GTAV RewardHook is a plugin for ScriptHookDotNet that turns GTA V into a reinforcement learning environment.

The idea is to accumulate facts relevant to safe driving (such as average road alignment, collisions etc.) in each training episode. These stats can then be translated to a single reward using some configurable reward scheme, and can be stitched together with screenshots taken around the same time to create datasets for reinforcement learning agents.

Disclaimer

The publisher of GTA V allows non-commercial use of footage from the game. Please do not use any datasets generated using RewardHook for any commercial projects. This work is also not affiliated with any organization that I am a part of and is just a personal project :)

Events

RewardHook is currently able to record the following accurately in each episode:

  • Average speed
  • Average road alignment (Measured as the cosine of the angle between road and vehicle)
  • Collisions with vehicles
  • Collisions with pedestrians
  • Collisions with other objects / environment
  • Driving against traffic
  • Driving on sidewalks

Getting Started

Requirements

  1. GTA V (with ScriptHook and ScriptHookDotNet installed)
  2. ScriptHookDotNet (for compilation, from nuget, VS should get this automatically)
  3. Nancy (for the RESTful API, from nuget, VS should get this automatically)

Installation

  1. Download / clone the repository.
  2. Open the project, and build using Visual Studio (preferably using VS2017 or later).
  3. Drag the compiled dll to scripts in your GTAV root.
  4. Start the game. You should now see occasional notifications.

Pending Tasks

RewardHook is still a work in progress. While a lot of events can be extracted using the known list of native methods (from GTA's RAGE engine), there are still several events that we cannot reliably detect (like running red lights, or driving offroad, or even lane alignment), unless the corresponding native addresses are known (or exist).

For some of these events, alternative tracking mechanisms do exist. For example, it is currently possible to detect if an NPC is waiting at a red light, which can help us create datasets that penalize running red lights only when another NPC is waiting at a red light and has been travelling on the same road.

Fortunately, the list of natives is constantly growing as the modding community discovers more natives (I use this list as a reference).

Besides these limitations, any pending tasks are usually in TODO.md.

Contributing

Contributions are welcome. Feel free to send a pull request.

gtav-rewardhook's People

Contributors

f1recracker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gtav-rewardhook's Issues

nothing shows when I run the game

Hi, thanks for your contribution! I am trying to use DRL method to train an agent to navigate GTAV, your work is of great help.

But when i put GTAVRewardHook.dll in the scripts folder and run the game, there is nothing shows.
I checked the ScriptHookVDotNet2.log, it says:
[18:21:48] [DEBUG] Created script domain 'ScriptDomain_4591BC20' with v0.0.0.
[18:21:48] [DEBUG] Loading scripts from 'E:\Games\Grand Theft Auto V\scripts' into script domain 'ScriptDomain_4591BC20' ...
[18:21:48] [INFO] Loading assembly 'Examples.dll' ...
[18:21:48] [DEBUG] Found 0 script(s) in 'Examples.dll'.
[18:21:48] [INFO] Loading assembly 'GTAVRewardHook.dll' ...
[18:21:48] [DEBUG] Found 0 script(s) in 'GTAVRewardHook.dll'.
[18:21:48] [INFO] Loading assembly 'Nancy.dll' ...
[18:21:48] [DEBUG] Found 0 script(s) in 'Nancy.dll'.
[18:21:48] [INFO] Loading assembly 'Nancy.Hosting.Self.dll' ...
[18:21:48] [DEBUG] Found 0 script(s) in 'Nancy.Hosting.Self.dll'.

What do you think is the reason? I wanna get the reward, any suggestion is welcomed! Thx!

GTA V go in black screen and loading simbol (bottom right) of the page, too many requests?

I'm using RewardHook for some reinforcement learning in python, i noticed that after a while GTA V go in Black Screen with a loading simbol (not freeze) going in loop forever.
I noticed that putting some sleep between each request helped a bit, so i am trying to put some pause in between my training algorithm to see if the problem will be solved, if you are still looking at this repository let me know what you think and if you have any idea of what might cause this problem.|

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.