Code Monkey home page Code Monkey logo

tetris-auto-play's Introduction

Source code for the Tetris game.

To run: python3 tetris.py

Your task

Write a better AutoPlayer than the one included with this source.

Rules

  • THIS IS AN ASSESSED COURSEWORK. THE CODE YOU SUBMIT MUST BE ENTIRELY YOUR OWN. If in doubt, ask.
  • The TAs can help you. They won't give you the answer, but if you're stuck, they may give you some hints. They will not debug your code for you, but they can help you debug your code if they think it's appropriate and will help you learn.
  • You will only hand in your version of te_autoplayer.py, so don't depend on any changes you make to any other files.
  • You can only call functions in te_gamestate.py
  • Your code will be automatically marked by submitting to gitlab. Instructions for this will follow in due course. We will run your code for five games with five different random seeds. We will take the median mark of the five runs as being representative of what your code can achieve.
  • To pass (earn 40%), you have to beat the score achieved by the random autoplayer supplied.
  • To get higher marks, you need to beat the score achieved by successively smarter implementations I have written. These scores will be published in due course.
  • Don't try to cheat, such as by directly changing the score, or affecting the random sequence of pieces. Our marking code will check for this, and anyone found cheating will receive zero marks for the coursework.

Controls

See the source code in te_controller.py

  • a - move left
  • s - move right
  • k - rotate left
  • l - rotate right
  • space - drop
  • y - toggle autoplay
  • q - quit
  • r - restart

Hints

You can enable autoplay by default by editing te_settings.py

You can beat the included random strategy with some pretty dumb solutions. You only have to beat random to achieve a pass mark.

Exhaustive search won't work for this problem. Searching all the positions and rotations for the only current tetronimo can do quite well, if you can come up with a good way to score the position. Searching all the positions and rotations for the current and next tetronimo can do a bit better, but only if you've a good way to score the final position.

tetris-auto-play's People

Contributors

henryzt avatar

Stargazers

 avatar

Watchers

 avatar

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.