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
A framework that allows people to write their own Rocket League bots.

YOU PROBABLY SHOULDN'T PULL THIS REPO Bot Makers Read This! If you just want to make a bot, you don't need to be here. Instead, start with one of thes

null 543 Dec 20, 2022
An experiment on the performance of homemade Q-learning AIs in Agar.io depending on their state representation and available actions

Agar.io_Q-Learning_AI An experiment on the performance of homemade Q-learning AIs in Agar.io depending on their state representation and available act

null 1 Jun 9, 2022
Using this codebase as a tool for my own research. Making some modifications to the original repo for my own purposes.

For SwapNet Create a list.txt file containing all the images to process. This can be done with the GNU find command: find path/to/input/folder -name '

Andrew Jong 2 Nov 10, 2021
RL agent to play μRTS with Stable-Baselines3

Gym-μRTS with Stable-Baselines3/PyTorch This repo contains an attempt to reproduce Gridnet PPO with invalid action masking algorithm to play μRTS usin

Oleksii Kachaiev 24 Nov 11, 2022
This is the official pytorch implementation of Student Helping Teacher: Teacher Evolution via Self-Knowledge Distillation(TESKD)

Student Helping Teacher: Teacher Evolution via Self-Knowledge Distillation (TESKD) By Zheng Li[1,4], Xiang Li[2], Lingfeng Yang[2,4], Jian Yang[2], Zh

Zheng Li 9 Sep 26, 2022
Here is the implementation of our paper S2VC: A Framework for Any-to-Any Voice Conversion with Self-Supervised Pretrained Representations.

S2VC Here is the implementation of our paper S2VC: A Framework for Any-to-Any Voice Conversion with Self-Supervised Pretrained Representations. In thi

null 81 Dec 15, 2022
Create Own QR code with Python

Create-Own-QR-code Create Own QR code with Python SO guys in here, you have to install pyqrcode 2. open CMD and type python -m pip install pyqrcode

JehanKandy 10 Jul 13, 2022
Gesture-controlled Video Game. Just swing your finger and play the game without touching your PC

Gesture Controlled Video Game Detailed Blog : https://www.analyticsvidhya.com/blog/2021/06/gesture-controlled-video-game/ Introduction This project is

Devbrat Anuragi 35 Jan 6, 2023
Make your own game in a font!

Project structure. Included is a suite of tools to create font games. Tutorial: For a quick tutorial about how to make your own game go here For devel

Michael Mulet 125 Dec 4, 2022
Offline Multi-Agent Reinforcement Learning Implementations: Solving Overcooked Game with Data-Driven Method

Overcooked-AI We suppose to apply traditional offline reinforcement learning technique to multi-agent algorithm. In this repository, we implemented be

Baek In-Chang 14 Sep 16, 2022
A platform for intelligent agent learning based on a 3D open-world FPS game developed by Inspir.AI.

Wilderness Scavenger: 3D Open-World FPS Game AI Challenge This is a platform for intelligent agent learning based on a 3D open-world FPS game develope

null 46 Nov 24, 2022
A PyTorch-based open-source framework that provides methods for improving the weakly annotated data and allows researchers to efficiently develop and compare their own methods.

Knodle (Knowledge-supervised Deep Learning Framework) - a new framework for weak supervision with neural networks. It provides a modularization for se

null 93 Nov 6, 2022
A parallel framework for population-based multi-agent reinforcement learning.

MALib: A parallel framework for population-based multi-agent reinforcement learning MALib is a parallel framework of population-based learning nested

MARL @ SJTU 348 Jan 8, 2023
COVINS -- A Framework for Collaborative Visual-Inertial SLAM and Multi-Agent 3D Mapping

COVINS -- A Framework for Collaborative Visual-Inertial SLAM and Multi-Agent 3D Mapping Version 1.0 COVINS is an accurate, scalable, and versatile vis

ETHZ V4RL 183 Dec 27, 2022
An architecture that makes any doodle realistic, in any specified style, using VQGAN, CLIP and some basic embedding arithmetics.

Sketch Simulator An architecture that makes any doodle realistic, in any specified style, using VQGAN, CLIP and some basic embedding arithmetics. See

null 12 Dec 18, 2022
A python interface for training Reinforcement Learning bots to battle on pokemon showdown

The pokemon showdown Python environment A Python interface to create battling pokemon agents. poke-env offers an easy-to-use interface for creating ru

Haris Sahovic 184 Dec 30, 2022
Have you ever wondered how cool it would be to have your own A.I

Have you ever wondered how cool it would be to have your own A.I. assistant Imagine how easier it would be to send emails without typing a single word, doing Wikipedia searches without opening web browsers, and performing many other daily tasks like playing music with the help of a single voice command.

Harsh Gupta 1 Nov 9, 2021