Giter Club home page Giter Club logo

tetrisai's Introduction

TetrisAi

This is designed for fun and to test genetic algorithm.

There are 2 versions of AI.

  1. Simple AI
  • Setting AI parameters manually, and just considering current tetris piece.
  • Only 2 files: TetrisAi.py and TetrisObject.py, < 400 lines totally.
  • Run: python3 TetrisAi.py
  1. Smart AI
  • Trainning AI parameters with genetic algorithm, and considering current and next tetris pieces.
  • Only 2 files: TetrisAiMultiBlock.py and TetrisObject.py, < 600 lines totally.
  • Run: python3 TetrisAiMultiBlock.py
  • You can switch to train mode by modified the do_train flag in TetrisAiMultiBlock.py

Output Example For Smart AI

The result of Ai output in console by the format as below, or see replay.txt for a full example ).

...
 Got Block: S	 Next Block: T
o o o o o o o o o o 
o o o o o o o o o o 
o o o o o o o o o o 
o o o o o o o o o o 
o o o o o o o o o o 
o o o o o o o o o o 
o o o o o o o o o o 
o o o o o o o o o o 
o o o o o o o o o o 
o o o o o o o o x x 
o o o o o o o x x x 
o o o o o o o x x x 
o o o o o x x x o x 
o x x o o x x x x x 
o x x x x x x x x x 
o x x x x x x x x x 
o x x x x x x x x o 
o x x x x x x x x x 
x x x x x o x x x x 
x x x x x x x x o x 
topfilledgrid = [18, 13, 13, 14, 14, 12, 12, 10, 9, 9]
revtopfilledgrid = [2, 7, 7, 6, 6, 8, 8, 10, 11, 11]
filledGridCount = 72
holeCount = 4
blockadeCount = 22
lastLineClearCount = 1
totalBlockCount = 893
combo = 1
...

Other Files

The other files are for enabling simple AI to play TetrisBattle in Facebook. It gets next block by looking at the RBG of a hard-coded position of the window of facebook tetrix battle, and move or rotate the block by sending keyboard signal with heuristic delay. It has some hard-coded part, so it needs to be tuned if you want to try it. I would like to recommend just to take it as a reference.

tetrisai's People

Contributors

arton0306 avatar

Stargazers

Aske Hippe Brun avatar Milker avatar  avatar

Watchers

 avatar Aske Hippe Brun avatar

tetrisai's Issues

FacebookTetrisBattle.py doesn't work

It simply doesn't work. It doesn't look like it's getting the blocks from any screenshots. It does set up the empty grid. After a while, Python crashes. Do you have to use a specific browser? Any other troubleshooting tips you recommend?

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.