All Projects → yanyongyu → python-tetris

yanyongyu / python-tetris

Licence: MIT license
Tetris game with AI made by pygame, inspired by react-tetris

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to python-tetris

Python-Games
A collection of small python games made by me using pygame and tkinter libraries
Stars: ✭ 121 (+536.84%)
Mutual labels:  tetris, pygame
PYTRIS
tetris made with pygame
Stars: ✭ 26 (+36.84%)
Mutual labels:  tetris, pygame
Snake-Game-with-Deep-learning
Developing a neural network to play a snake game
Stars: ✭ 43 (+126.32%)
Mutual labels:  pygame
raylib-py
A Python binding for the great C library raylib.
Stars: ✭ 147 (+673.68%)
Mutual labels:  pygame
DungeonGenerator
Procedural Dungeon Generation with Python and Pygame
Stars: ✭ 57 (+200%)
Mutual labels:  pygame
RealTime-DigitRecognition
RealTime DigitRecognition using Convolutional Neural Network(CNN) with keras.
Stars: ✭ 108 (+468.42%)
Mutual labels:  pygame
COVID-Resource-Allocation-Simulator
Agent-based modelling for resource allocation in viral crises to investigate resource allocation and policy interventions with respect to transmission rate.
Stars: ✭ 61 (+221.05%)
Mutual labels:  pygame
Python.io
Snake game inspired from Slither.io but features a python instead of a snake. Made in Python 3
Stars: ✭ 15 (-21.05%)
Mutual labels:  pygame
Tetromino
One of my favorite games implemented for iOS, macOS + CLI
Stars: ✭ 17 (-10.53%)
Mutual labels:  tetris
Pycraft
Pycraft is the OpenGL, open world, video game made entirely with Python. This project is a game to shed some light on OpenGL programming in Python as it is a seldom touched area of Python's vast amount of uses. Feel free to give this project a run, and message us if you have any feedback!
Stars: ✭ 39 (+105.26%)
Mutual labels:  pygame
mobx-react-tetris
No description or website provided.
Stars: ✭ 30 (+57.89%)
Mutual labels:  tetris
nelua-tetris
Tetris game clone made in Nelua with Raylib
Stars: ✭ 16 (-15.79%)
Mutual labels:  tetris
go-tetris
Golang Tetris for console window with optional AI
Stars: ✭ 67 (+252.63%)
Mutual labels:  tetris
PlaneWars
微信飞机大战 python pygame
Stars: ✭ 22 (+15.79%)
Mutual labels:  pygame
UnityTetris
Tetris clone written in C# and using Unity engine to render.
Stars: ✭ 131 (+589.47%)
Mutual labels:  tetris
pygameweb
🎮🕸️ pygame.org website. Python, PostgreSQL, Flask, sqlalchemy, JS.
Stars: ✭ 94 (+394.74%)
Mutual labels:  pygame
Wario-Land-3
A remake of the GBC-Game "Wario Land 3" using Pygame for Python
Stars: ✭ 48 (+152.63%)
Mutual labels:  pygame
sh-tetris
The pure shell script (sh) that implements the Tetris game following the Tetris Guideline (2009).
Stars: ✭ 31 (+63.16%)
Mutual labels:  tetris
RustTetris
Tetris Made in Rust and SDL2
Stars: ✭ 18 (-5.26%)
Mutual labels:  tetris
ConkyLuaMakerGUIv2
An interactive GUI to generate lua conky
Stars: ✭ 20 (+5.26%)
Mutual labels:  pygame

PyTetris

PyPI GitHub GitHub repo size PyPI - Downloads

Table of Contents

Overview

Simple tetris game made by pygame

Inspired by react-tetris

AI algorithm: Pierre Dellacherie (El-Tetris)

Screenshots

Overview

Overview

Overview

Overview

Play the Game

Install

pip3 install pytetris

Start

Run the following command in the environment which you installed the pytetris package or under the project folder:

python -m pytetris

or you can run the project in the project folder by

poetry run game

How to Play

In the home page, you can use ←→ or click the button to change to start level and use ↑↓ to change the start random line number.

  • : Rotate the piece
  • ←→ : Move the piece left or right
  • : Speed up the piece
  • SPACE : Drop down the piece
  • P : Pause the game
  • S : Mute control
  • R : Reset the game (will loss current score)
  • A : Make AI on or off

Pierre Dellacherie

Pierre Dellacherie is a one-piece algorithm.

Six main features:

Landing Height

The height where the piece is put. Top or center of the piece is both ok.

Example:

🟦
🟦🟦
🟦

Height: 4 or 3

Eroded Piece Cells Metric

The number of rows eliminated × The number of the squares the piece contributed

Example:

🟦
🟦🟦
🟦

Eliminated lines: 1

Contribute: 1

Eroded Piece Cells Metric: 1 × 1 = 1

Board Row Transitions

The total number of row transitions. A row transition occurs when an empty cell is adjacent to a filled cell on the same row and vice versa.

Tips: Both sides of the wall is concerned as filled.

Example:

Single Row Transitions: 6

Board Column Transitions

The total number of column transitions. A column transition occurs when an empty cell is adjacent to a filled cell on the same column and vice versa.

Tips: Both sides of the wall is concerned as filled.

Example:







Single Column Transitions: 4

Board Buried Holes

The total number of column holes. A hole is an empty cell that has at least one filled cell above it in the same column.

Example:





Single Column Holes: 1

Board Wells

The total number of column wells. A well is a succession of empty cells such that their left cells and right cells are both filled.

Tips: As long as there are filled cells on both sides, the empty cell is concerned as well.

Example:





Wells: (1) + (1+2) = 4

Total

The evaluation function is a linear sum of all the above features. Bigger value will be better.

Feature Weight
Landing Height -4.500158825082766
Eroded Piece Cells Metric 3.4181268101392694
Board Row Transitions -3.2178882868487753
Board Column Transitions -3.2178882868487753
Board Buried Holes -7.899265427351652
Board Wells -3.3855972247263626

Priority

priority = 100 * moving_steps + rotation_times

We choose the action which priority is lower if there are two or more same evaluation actions.

Result Preview

Project Development Setup

Clone the repository then install dependencies.

poetry install --no-root

or you can install the dependencies using pip:

pip3 install pygame numpy
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].