GithubHelp home page GithubHelp logo

baeeq / mupen64plus-input-bot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kevinhughes27/mupen64plus-input-bot

0.0 3.0 0.0 28 KB

An input driver for mupen64plus that consumes from a python web server

Makefile 34.06% C 59.40% C++ 1.50% Python 5.03%

mupen64plus-input-bot's Introduction

mupen64plus-input-bot

An input driver for mupen64plus that consumes a JSON response from a web server. Intended for use with my TensorKart project that trains an AI using TensorFlow to play the classic N64 title MarioKart 64.

Building

make all

The project uses essentially a copy and paste of the Makefile from the regular input plugin for mupen64plus with the dynamic config lib and SDL dependencies removed. It includes flags to link libjson-c, which it assumes has been installed into /usr/lib and /usr/include. You can get this library on Ubuntu by installing the following packages (or if you prefer, you can build the latest from source here):

libjson-c2
libjson-c-dev

Note that all builds expect the mupen64plus-core source code to be available in the same directory.

eg.

src \
  mupen64plus-core \
    ...
  mupen64plus-input-bot \
    ...

Installing

After building run sudo make install to copy the driver to the default location.

/usr/local/lib/mupen64plus/mupen64plus-input-bot.so

Installing the driver to a standard system location allows downstream applications to configure mupen64plus automatically (for example the mupen64plus OpenAI gym)

Usage

mupen64plus --input /usr/local/lib/mupen64plus/mupen64plus-input-bot.so MarioKart64.z64

Protocol

The server attempts to deserialize the web response as a JSON object. It expects the JSON object to contain properties that represent each of the controller button states (as integers). If any buttons are not included in the response, their values will default to 0.

Example JSON response:

{
  "START_BUTTON": 0,
  "U_CBUTTON": 0,
  "L_DPAD": 0,
  "A_BUTTON": 1,
  "B_BUTTON": 0,
  "X_AXIS": -80,
  "L_CBUTTON": 0,
  "R_CBUTTON": 0,
  "R_TRIG": 0,
  "R_DPAD": 0,
  "D_CBUTTON": 0,
  "Z_TRIG": 0,
  "Y_AXIS": 80,
  "L_TRIG": 0,
  "U_DPAD": 0,
  "D_DPAD": 0
}

Testing

An example server is included in /test/server.py. This file is a minimal example that allows you to hard code the joystick input. This example is intended to be extracted into a program that determines the appropriate input somehow.

Future Work / Ideas

  • controller.c could be refactored into smaller functions
  • I'm sure my c code can be optimized and improved
  • This plugin might be useful for implementing network play with mupen64plus

Contributing

Open a PR! I'm friendly I promise :)

mupen64plus-input-bot's People

Contributors

kevinhughes27 avatar bzier avatar

Watchers

James Cloos avatar baeeq avatar  avatar

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.