Game Agent Framework. Helping you create AIs / Bots that learn to play any game you own!

Overview

Serpent.AI - Game Agent Framework (Python)



Update: Revival (May 2020)

Development work has resumed on the framework with the aim of bringing it into 2020: Python 3.8+, Less Dependencies, Ease of Use (Installer, GUI) and much more! Still open-source with a permissive license and looking into a Steam distribution for non-technical users. 🐍

Warning: End of life (November 2018)

Serpent.AI is a simple yet powerful, novel framework to assist developers in the creation of game agents. Turn ANY video game you own into a sandbox environment ripe for experimentation, all with familiar Python code. The framework's raison d'être is first and foremost to provide a valuable tool for Machine Learning & AI research. It also turns out to be ridiculously fun to use as a hobbyist (and dangerously addictive; a fair warning)!

The framework features a large assortment of supporting modules that provide solutions to commonly encountered scenarios when using video games as environments as well as CLI tools to accelerate development. It provides some useful conventions but is absolutely NOT opiniated about what you put in your agents: Want to use the latest, cutting-edge deep reinforcement learning algorithm? ALLOWED. Want to use computer vision techniques, image processing and trigonometry? ALLOWED. Want to randomly press the Left or Right buttons? sigh ALLOWED. To top it all off, Serpent.AI was designed to be entirely plugin-based (for both game support and game agents) so your experiments are actually portable and distributable to your peers and random strangers on the Internet.

Serpent.AI supports Linux, Windows & macOS.

The next version of the framework will officially stop supporting macOS. Apple's aversion to Nvidia in their products means no recent macOS machine can run CUDA, an essential piece of technology for Serpent.AI's real-time training. Other decisions like preventing 32-bit applications from running in Catalina and deprecating OpenGL do not help make a case to support the OS.

Experiment: Game agent learning to defeat Monstro (The Binding of Isaac: Afterbirth+)

Background

The project was born out of admiration for / frustration with OpenAI Universe. The idea is perfect, let's be honest, but some implementation details leave a lot to be desired. From these, the core tennets of the framework were established:

  1. Thou shall run natively. Thou shalt not use Docker containers or VNC servers.
  2. Thou shall allow a user to bring their own games. Thou shalt not wait for licensing deals and special game APIs.
  3. Thou shall encourage diverse and creative approaches. Thou shalt not only enable AI flavors of the month.

Want to know more about how Serpent.AI came to be? Read The Story Behind Serpent.AI on the blog!

Documentation

Guides, tutorials and videos are being produced and added to the GitHub Wiki. It currently is the official source of documentation.

Experiment: Game agent learning to match tiles (You Must Build a Boat)

Business Contact: [email protected]

Comments
  • Invoke python3 and add config files to .gitignore

    Invoke python3 and add config files to .gitignore

    Even if SerpentAI was installed using python3, the tool invokes wrong python version when running serpent setup if environment pip points to python2 causing dependency problems.

    I changed shebang to point to python3 in case python and python3 invoke different python version so this would be in sync with correct python version when installing dependencies using serpent setup (which now uses python3 -m pip instead of pip to avoid chances of version mismatch).

    Also updated .gitignore to exclude config files.

    opened by ritiek 3
  • Darwin tuple id

    Darwin tuple id

    Hello! ,

    Thanks a lot for the work you've done so far.

    Preface:

    I've checked the contribute.md file and I fully understand your policy but I will definitely do some works to implements what I need for a personal project on top of your work. So I will probably send random pull request... As those pull requests might appear from nowhere, I'm not expecting you to merge them fast or even at all. BUT if my pull request annoys you, feel free to tell me to stop 👍🏻

    Back to the work done:

    I needed the capacity to have a little bit more control over the window_controller on OSX. Precisely, I wanted to select a precise window of an app (some emulator creates multiple windows).

    So I changed the locate function on OSX for a tuple (str:appName, int:windowNumber) which can be considered an identifier (windowNumber is 1-indexed). OSX keeps an array of created windows for every process, they are added in the order of their creations. As long as one doesn't delete a window, the indices can be considered static. In the different usecases of SerpentAI, this is probably fine.

    What do you think?

    PS: I'm not a OSX guru at all, so feel free to criticise.

    opened by morgangiraud 2
  • Initial Support for Darwin (macOS)

    Initial Support for Darwin (macOS)

    With Linux and Windows support out of the way, I thought I'd start on macOS support. Until now, I can confirm these features work:

    • Setting up serpent (serpent setup)
    • Grab frames (serpent grab_frames)
    • Generating a Game Plugin (serpent generate <game/game_agent>)
    • Activate/Deactivate Plugin (serpent activate/deactivate <plugin>)
    • List Plugins (serpent plugins)
    • Launching a Game (serpent launch <game>)
    • Capture frames (serpent capture frame <game>)
    • Capture Region (serpent capture region <game> <interval> <region>)
    • Capture context (serpent capture context <game> <interval> <name>)
    • Train Context (serpent train context <epochs>) with Tensorflow CPU
    • Launching Visual Debugger (serpent visual_debugger)
    • Play Game with Game Agent (serpent play <game> <game_agent>)

    I cannot test for GPU Accelerated Tensorflow since I do not have access to a dedicated graphics card in my laptop. I will continue to work on the macOS support by implementing a full working game agent.

    Retina Displays - The difficulty with macOS support is the need to support Retina displays. For now the frame_grabber assumes a user with macOS is always using a Retina display.

    if sys.platform == "darwin":
      # Half width / height of frame here
    

    Perhaps this is not the best way to handle it and as such there is an additional option to check for a Retina display.

    if sys.platform == "darwin":
      if subprocess.call("system_profiler SPDisplaysDataType | grep 'retina'", shell= True) == 1:
          # Half width / height of frame here
    

    I would love some input as to how to handle this.

    The installation process is similar to Linux, but requires some extra dependencies, which have been added via the setup process as well as requirements.darwin.txt. I have also created a macOS Installation Guide for those that want to try it out. I'm willing to maintain the macOS branch.

    Gif

    Screenshots

    bitmoji

    opened by d0p3t 2
  • cv2 based sprite finder

    cv2 based sprite finder

    needs pip install opencv-python fixes https://github.com/SerpentAI/SerpentAI/issues/200 good enough for me; today it doesn't do:

    • multi-frame sprites
    • regions of interest
    • ~~alpha channel/transparency~~

    Those first two should be trivial to add back in, ~~not 100% sure about transparency. Should be possible with the mask parameter~~

    opened by greyltc 1
  • Parameter to skip validation during Training

    Parameter to skip validation during Training

    Validation can take a significant amount of time. This may not be desired for all training.

    This introduces the ability to specify if you'd like to validate your model or not.

    opened by corbob 1
  • Fixed mouse events missing x_offset and y_offset

    Fixed mouse events missing x_offset and y_offset

    Fix for #46

    I've added the x_offset and y_offset to the click() method while removing all offsets from other methods using the click() method. Now the click() method also includes offsets.

    I've also added the offsets to the drag() and scroll() methods.

    opened by d0p3t 1
  • Makes it easier to capture context frames

    Makes it easier to capture context frames

    This is one small step to decoupling from config file and making it CLI friendly. It matches game classes from partial name. Those match functions are lingering in tasks.py and would be better to move somewhere appropriate :) invoke capture_context --game=youmust --context="level_test"

    One of the problem was once game.play function is called, it creates agent itself by name and goes into endless loop. Maybe make it take class instance instead of name? I solved this by adding a callback that called right after class is instantiated. Let me know if it doesn't fits taste of the framework :)

    opened by codetorex 1
  • Avoiding subprocess calls for clear. Use octal codes instead!

    Avoiding subprocess calls for clear. Use octal codes instead!

    Hello.

    It really dazzles my eyes when I see invoking "clear" shell command from programming languages. It creates a shell, then it is running the clear command and result. Spawning a shell is unnecessary. We can send a code to output, that clears the visible buffer - which is <ESC>c (in other words 033c).

    I also deleted unused imports.

    opened by dtusk 1
  • Block the window search until there are results

    Block the window search until there are results

    this prevents subprocess.CalledProcessError: Command '['xdotool', 'search', '--onlyvisible', '--name', '^WINDOW TITLE$']' returned non-zero exit status 1. errors on my system when launching games

    opened by greyltc 0
  • add multiprocessing worker class due to linux fork issue

    add multiprocessing worker class due to linux fork issue

    In old implementation I got crashes when more than half of memory was used by Serpent program. Fork duplicate calling process, so in that case it cannot allocate more memory. (https://stackoverflow.com/questions/1367373/python-subprocess-popen-oserror-errno-12-cannot-allocate-memory)

    I wrote CmdRunner class which runs commands with minimal memory usage (Process is started using spawn method instead of fork) and changed LinuxWindowController class, it now use CmdRunner.

    opened by Gotyk6 0
  • added base environment class; added concept of environments to game c…

    added base environment class; added concept of environments to game c…

    …lass; updated game class template; added the concept of game inputs to game APIs; added a way to combine game input axes to game APIs; added first unit tests

    opened by nbrochu 0
  • Small Update to Serpent

    Small Update to Serpent

    I got really excited to put some Reinforcement Learning in practice with my favorite games thanks to SerpentAI. However, I've ran into some problems while trying to make Serpent work (sorry for the emails, Nicholas Brochu).

    In order to prevent anyone else to have to deal with those problems, I've opened a fork and added some modified files, mixing the old Serpent codes with the new ones from 2020 version. I also modified some codes in keras that were generating compability errors(since the code was still for keras < 2.0 and tensorflow V1).

    I was also having some problems with window controller, since pywin32 wasn't extracting the correct size of my game's window. I added an import pyautogui to fix this problem.

    opened by Martyn0324 1
  • *Bugs*

    *Bugs*

    c:\users\micha\anaconda3\envs\serpent\lib\site-packages\offshoot\base.py:38: UserWarning: 'offshoot.yml' not found! Using default configuration. warnings.warn("'offshoot.yml' not found! Using default configuration.") Traceback (most recent call last): File "c:\users\micha\anaconda3\envs\serpent\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "c:\users\micha\anaconda3\envs\serpent\lib\runpy.py", line 85, in run_code exec(code, run_globals) File "C:\Users\micha\anaconda3\envs\serpent\Scripts\serpent.exe_main.py", line 7, in File "c:\users\micha\anaconda3\envs\serpent\lib\site-packages\serpent\serpent.py", line 52, in execute command_function_mappingcommand TypeError: launch() takes 1 positional argument but 3 were given

    How do i fix this? Also I can't seem to use the Visual Debugger...

    opened by ThatMichaelGuy2020 3
Releases(optional)
Owner
Serpent.AI
Machine Learning Software & Python Libraries
Serpent.AI
🛰️ Awesome Satellite Imagery Datasets

Awesome Satellite Imagery Datasets List of aerial and satellite imagery datasets with annotations for computer vision and deep learning. Newest datase

Christoph Rieke 3k Jan 03, 2023
TraND: Transferable Neighborhood Discovery for Unsupervised Cross-domain Gait Recognition.

TraND This is the code for the paper "Jinkai Zheng, Xinchen Liu, Chenggang Yan, Jiyong Zhang, Wu Liu, Xiaoping Zhang and Tao Mei: TraND: Transferable

Jinkai Zheng 32 Apr 04, 2022
Prefix-Tuning: Optimizing Continuous Prompts for Generation

Prefix Tuning Files: . ├── gpt2 # Code for GPT2 style autoregressive LM │ ├── train_e2e.py # high-level script

530 Jan 04, 2023
Reproducing-BowNet: Learning Representations by Predicting Bags of Visual Words

Reproducing-BowNet Our reproducibility effort based on the 2020 ML Reproducibility Challenge. We are reproducing the results of this CVPR 2020 paper:

6 Mar 16, 2022
This project implements "virtual speed" from heart rate monito

ANT+ Virtual Stride Based Speed and Distance Monitor Overview This project imple

2 May 20, 2022
一个多语言支持、易使用的 OCR 项目。An easy-to-use OCR project with multilingual support.

AgentOCR 简介 AgentOCR 是一个基于 PaddleOCR 和 ONNXRuntime 项目开发的一个使用简单、调用方便的 OCR 项目 本项目目前包含 Python Package 【AgentOCR】 和 OCR 标注软件 【AgentOCRLabeling】 使用指南 Pytho

AgentMaker 98 Nov 10, 2022
Train DeepLab for Semantic Image Segmentation

Train DeepLab for Semantic Image Segmentation Martin Kersner, [email protected]

Martin Kersner 172 Dec 14, 2022
A Simulation Environment to train Robots in Large Realistic Interactive Scenes

iGibson: A Simulation Environment to train Robots in Large Realistic Interactive Scenes iGibson is a simulation environment providing fast visual rend

Stanford Vision and Learning Lab 493 Jan 04, 2023
DC3: A Learning Method for Optimization with Hard Constraints

DC3: A learning method for optimization with hard constraints This repository is by Priya L. Donti, David Rolnick, and J. Zico Kolter and contains the

CMU Locus Lab 57 Dec 26, 2022
Pytorch Implementation of "Diagonal Attention and Style-based GAN for Content-Style disentanglement in image generation and translation" (ICCV 2021)

DiagonalGAN Official Pytorch Implementation of "Diagonal Attention and Style-based GAN for Content-Style Disentanglement in Image Generation and Trans

32 Dec 06, 2022
Sample Prior Guided Robust Model Learning to Suppress Noisy Labels

PGDF This repo is the official implementation of our paper "Sample Prior Guided Robust Model Learning to Suppress Noisy Labels ". Citation If you use

CVSM Group - email: <a href=[email protected]"> 22 Dec 23, 2022
Submission to Twitter's algorithmic bias bounty challenge

Twitter Ethics Challenge: Pixel Perfect Submission to Twitter's algorithmic bias bounty challenge, by Travis Hoppe (@metasemantic). Abstract We build

Travis Hoppe 4 Aug 19, 2022
LLVIP: A Visible-infrared Paired Dataset for Low-light Vision

LLVIP: A Visible-infrared Paired Dataset for Low-light Vision Project | Arxiv | Abstract It is very challenging for various visual tasks such as image

CVSM Group - email: <a href=[email protected]"> 377 Jan 07, 2023
Degree-Quant: Quantization-Aware Training for Graph Neural Networks.

Degree-Quant This repo provides a clean re-implementation of the code associated with the paper Degree-Quant: Quantization-Aware Training for Graph Ne

35 Oct 07, 2022
CZU-MHAD: A multimodal dataset for human action recognition utilizing a depth camera and 10 wearable inertial sensors

CZU-MHAD: A multimodal dataset for human action recognition utilizing a depth camera and 10 wearable inertial sensors   In order to facilitate the res

yujmo 11 Dec 12, 2022
A small library for doing fluid simulation with neural networks.

Neural Fluid Fields This is a small library for doing fluid simulation with neural fields. Check out our review paper, Neural Fields in Visual Computi

Towaki 23 Jun 23, 2022
A Pythonic library for Nvidia Codec.

A Pythonic library for Nvidia Codec. The project is still in active development; expect breaking changes. Why another Python library for Nvidia Codec?

Zesen Qian 12 Dec 27, 2022
Moer Grounded Image Captioning by Distilling Image-Text Matching Model

Moer Grounded Image Captioning by Distilling Image-Text Matching Model Requirements Python 3.7 Pytorch 1.2 Prepare data Please use git clone --recurse

YE Zhou 60 Dec 16, 2022
KIND: an Italian Multi-Domain Dataset for Named Entity Recognition

KIND (Kessler Italian Named-entities Dataset) KIND is an Italian dataset for Named-Entity Recognition. It contains more than one million tokens with t

Digital Humanities 5 Jun 21, 2022
Experiment about Deep Person Re-identification with EfficientNet-v2

We evaluated the baseline with Resnet50 and Efficienet-v2 without using pretrained models. Also Resnet50-IBN-A and Efficientnet-v2 using pretrained on ImageNet. We used two datasets: Market-1501 and

lan.nguyen2k 77 Jan 03, 2023