Coder Social home page Coder Social logo

flashrl's Introduction

FlashRL - Flash Platform for Reinforcement Learning

For the updated version of FlashRL, go to this link.

TODO List

  • Fix pyVNC issue. Currently pyVNC fails to start a VNC server for the game to run on. We need to solve this issue in order to run our games in headless mode.
  • Begin developing custom environments.
  • Begin developing Docker containers for our code to run in. Preferably, create a Dockerfile that can be used to run custom environments without the need for the local machine to have all the dependencies installed.

Prerequisites

  • Ubuntu 18.04 (Our most recent testing of 20.04 proves that it does not work.)
  • Python 3.x.x (Python 3.6.8 is tested)
  • gnash
  • xvfb

Installation

For our testing, we have been working in a python virtual environment.

sudo apt-get install xvfb
sudo apt-get install gnash
sudo apt-get install vnc4server
# I would reccomend doing the next steps inside a virtual environment.
pip install git+https://github.com/cair/pyVNC
pip install git+https://github.com/JDaniel41/FlashRL

Deploy new environment

Developers are able to import custom environments through project/contrib/environments/

A typical custom implementation looks like this:

- project
    - __init__.py
    - main.py
    - contrib
        - environments
            - env_name
                - __init__.py
                - dataset.p
                - model.h5
                - env.swf

in the following section, we demonstrate how to implement the flash game Mujaffa as an environment for FlashRL.

Mujaffa-1.6

Prerequisites

  • SWF Game File
  • Python 3x
  • Keras

  • Create directory structure mkdir -p contrib/environments/mujaffa-v1.6
  • Create Configuration file:
echo "define = {
    "swf": "mujaffa.swf",
    "model": "model.h5",
    "dataset": "dataset.p",
    "scenes": [],
    "state_space": (84, 84, 3)
}" > contrib/environments/mujaffa-v1.6/__init__.py
  • Add swf "mujaffa.swf" to contrib/environments/mujaffa-v1.6/
  • Create file main.py in project root with following template
from FlashRL import Game

def on_frame(state, type, vnc):
    # vnc.send_key("a") # Sends the key "a"
    # vnc.send_mouse("Left", (200, 200)) # Left Clicks at x=200, y=200
    # vnc.send_mouse("Right", (200, 200)) # Right Clicks at x=200, y=200
    pass

g = Game("mujaffa-v1.6", fps=10, frame_callback=on_frame, grayscale=True, normalized=True)

Licence

Copyright 2017/2018 Per-Arne Andersen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

flashrl's People

Contributors

filipeabperes avatar jdaniel41 avatar perara avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

flashrl's Issues

Documentation

Hi, I was looking into possibly using this for a personal project involving building an agent to play a Flash game. So I was wondering, is this project functional already? If so, is there any documentation or tutorial to guide usage?

Thanks

Questions about RL Flash algorithm

Hi ! Thanks for the article ! I'm looking into building an agent for a flash games (like filipeabperes), but this is my very first code with RL algorithm.

First i need to get the .swf file from the game.

Then i need to change your algorithm for the game. That's where i don't understand, does the IA directly put his inputs in the flash game ? Will the bot be able to detect the environment from the .swf file ?

I don't know how to code in Java, but i can follow a tutorial if needed. Hope i'm clear enough for you.
Thanks for helping me.

Cannot Import Game from FlashRL

Hello, I am looking at using FlashRL for a reinforcement learning project and I am currently trying to run the mujaffa example environment. However, when I run it, the program crashes when it tries to run from FlashRL import Game:

>>> from FlashRL import Game
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'Game' from 'FlashRL' (unknown location)

Meanwhile, I can run import FlashRL just fine without any errors. Running modules in the python terminal does not list FlashRL, even though I was able to use pip to install FlashRL from this GitHub repository. Is there something I am missing? If I try running the commands as FlashRL.Game I still face the same issue with the following output:

Traceback (most recent call last):
  File "main.py", line 7, in <module>
    FlashRL.Game("mujaffa-v1.6", fps=1, frame_callback=on_frame, grayscale=True, normalized=True)
AttributeError: module 'FlashRL' has no attribute 'Game'

I am pretty certain that the FlashRL module is installed, but for some reason I cannot install any of the additional files in the lib directory of this repository.

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.