Coder Social home page Coder Social logo

kb1900 / cultris-tetris-ai Goto Github PK

View Code? Open in Web Editor NEW
2.0 6.0 0.0 5.67 MB

tetris AI for Cultris 2

License: GNU General Public License v3.0

Python 100.00%
tetris machine-learning particle-swarm-optimization genetic-algorithm tetris-machine-learning tetris-engine cultris

cultris-tetris-ai's Introduction

Cultris-Tetris-AI

Build Status

This repo contains a preliminary attempt at creating a tetris AI to play the block-based puzzle game, Cultris 2 (available at http://gewaltig.net/cultris2.aspx). It uses a combination of internal game heuristics, particle swarm optimization and genetic algorithms to generate weight based and neural network based models to iterate through possible moves and play those that yield the best gamestates. Currently the AI has been well-trained to upstack, downstack, combo/attack and survive as long as possible in multiplayer and singleplayer modes.

Long Term To do:

  • Remove dependencies requrired for interfacing with Cultris
  • Make interfacing with Cultris cross-platform
  • Create evaluation functions/additional heuristics to train upstacking + comboing
  • Continue refactoring heuristic generation
  • Explore novel training methods and better NN structures

Short Term To do:

  • Integrate a simulated combo system that mimics Cultris (Complete!)
  • Reduce board scoring iterations for redundant boards (Complete!)
  • Create an autoencoder environment to generate training data for CNN training (in progress)
  • Integrate keras + tensorflow backend for CNN model creation
  • Create a self-play one vs one environment for the agents to train with
  • Fix matrix desync with Cultris due to sliding garbage detection issues (Complete!)

Installation

Create a virtualenv (recommended) and install the dependencies

$ cd cultris-tetris-ai
$ python3 -m venv . # recommended
$ source bin/activate
$ pip3 install -e . # setup.py contains a list of currently required dependencies

To run a test game:

$ python3 c2ai deap.pso.downstack 
# runs a simulated game in console using the weights in /deap/pso/downstack/tetris.py

Running the bot on Cultris 2 currently requires a specific environment (mac os, template matching, resolution and window sizing etc.) that is not transferable between PCs. This is on the to do list, however instructions are below for Mac OS on a 15 inch MBP:

# Set C2 dimensions to 1552 x 996. Use default piece orientations and colors.
# Controls: 
# C for Harddrop, Q for CCW rotation, W for Cw rotation, TAB for 180 rotation
# Arrow keys for L/R/Downwards Movement
$ cd c2ai
$ python3 main.py -x 

Videos

Early videos of the AI's progress can be found below and will be updated infrequently. The AI is far more efficient now with the introduction of new heuristics, more training iterations, and bugfixes.

Date Link
January 19 https://youtu.be/hsjIWPmh-a4
December 14 https://youtu.be/VbvWcnWdpLQ
October 8 https://youtu.be/16yfSYFDXKQ
October 2 https://youtu.be/0DMhihKoAgo
August 11 https://youtu.be/VLiaSU1tr74
August 10 https://youtu.be/Jz3FvLdF1VU

cultris-tetris-ai's People

Contributors

g-wen avatar kb1900 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cultris-tetris-ai's Issues

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.