supertuxkart / stk-code

The code base of supertuxkart
Other
4.54k stars 1.06k forks source link

Programmatic game control for integration with OpenAI Gym #4431

Closed muety closed 4 years ago

muety commented 4 years ago

Hi all!

This is not particularly a feature request, but rather a discussion starter. If you consider it inappropriate, feel free to close this issue again.

Background

I have a project in mind to train a reinforcement learning-based AI agent to play Supertuxkart.

With reinforcement learning (RL), there usually is a programmtic agent, which (1) first observes its environment and then (2) acts by choosing the most promising one from a set of potential actions.

An environment observation could be a set of explicit parameters describing the current game state (e.g. player's world position, speed, selected powerup item, etc.) or, more generally, a game screenshot from which an implicit state is derived using machine learning / computer vision methods. An action could to press a certain button (e.g. "A" to steer to the left).

Creating a RL environment

A commonly used "framework" to implement reinforcement learning for games is the OpenAI Gym, for which you can write custom, game-specific so called environments, which wrap the game's inputs and outputs with a uniform API. There is a number of community-built environments for a variety of different 2D- and 3D games, including Obstacle Tower and the CARLA autonomous driving simulator.

One key requirement for each of these environment is the ability to programatically interact with the game environment through an API. To my understanding, the minimum required interactions between the Gym environment and the game are:

Given these API methods, the RL agent is able to run a loop of observing the environment, performing an action and observing the environment again one (or few) frames later to see the consequences - until no more progress is made or the game is considered "lost".


My questions to the STK community are:

I'm neither very familiar with game development and C++, nor with the STK code base in particular, sorry!

Benau commented 4 years ago

https://pypi.org/project/PySuperTuxKart/

Benau commented 4 years ago

assume you solved the problem