Back in 1989, Nintendo released Tetris for the NES. This detailed article first explains the mechanics of how Tetris works, then builds an AI to play the game.
To understand the mechanics of the game, the ROM source was explored. Since the NES was based of the MOS 6502 microprocessor, this involves looking at the 6502 assembly. The article details how the blocks (called Tetriminos) are created and how they move across the screen. The linear feedback shift register used for random number generation is examined. Even details of the legal screen and demo mode are explained.
After the tour through how Tetris works, an algorithm for the AI is presented. This AI is implemented in Lua inside of the FCEUX NES/Famicom emulator. It works by evaluating all of the possible places to put each new Tetrimino, and choosing the best based on a number of criteria. The weighting for each criterion was determined by using a particle swarm optimization.
The source for both the Lua version and a Java version of the code is available with the article. Everything you need to run the AI is available for free, except the Tetris ROM. If you’re interested in how 8 bit games were built, this dissection is a great read.
[Vince] teaches an Embedded Systems class at the University of Maine, and some of his students were working on video games for their finals. He decided to “test the hardware” that the students were using by putting two 8×8 displays, one 4×7 segment display, and a Wii Nunchuck on the I2C bus. He then wrote a version of Tetris that accepts trigger presses and accelerometer input for control. Judging by the video (embedded after the break), the Raspberry Pi runs the game without issue. The bus is, of course, more than capable of handling everything.
Unfortunately, [Vincent] had some trouble getting the controls just right. Sometimes dropping a piece can cause the next to drop too quickly, and the accelerometer control seems a bit too sensitive. We imagine using the joystick for rotation and adding some strategic pauses in the game could help. He graciously released the source code for the project, so maybe we’ll see some embracing and extending in the near future.
Continue reading “Wii Nunchuck-Controlled Tetris on a Raspberry Pi”
Look closely at the colored pixels on this pair of 8×8 RGB LED modules and you’ll be able to pick out some of the familiar shapes of Tetris pieces. It’s impressive that [Jianan Li] built his own color Tetris including the theme music, but look at this breadboard! The layout of his circuit is as equally impressive as the code he wrote to get the game up and running. It takes a fair amount of planning to get a circuit of this complexity to fit in the space he used, right?
There are two microcontrollers at work, each running the Arduino bootloader. The main chip is an ATmega328 which is responsible for monitoring the buttons and controlling game play. The other is an ATmega85. The eight pin chip listens to it’s bigger brother, playing the theme song when the game starts, and pausing or resuming to match the user input So is the next stop for this project playing Tetris on the side of a building?
Don’t miss the demo video after the break. We’ve also rolled in a video of his Arduino-based piano. It’s built on a breadboard that’s nearly as impressive as this. But what delights us is his skill at playing Pokemon themes on the two-octave tactile switch keyboard. Obviously those piano lessons his parents shelled out for really paid off!
Continue reading “Breadboard Tetris is Wire Artwork”
The kids (or maybe their parents) are going to be lined up at [Nathan’s] front porch to get their turn at playing pumpkin Tetris. That’s right, he built a game of Tetris into a real pumpkin. We thought this looked quite familiar when we first saw it and indeed he was inspired by our own LED Matrix Pumpkin from two Halloweens ago. We love seeing derivative works and [Nathan] definitely make few great improvements to the process.
The matrix itself was wired in very much the same way we used, but he added an additional 58 LEDs to nearly double the size of the display. He used a paper grid and power drill to make room for the holes, but improved the visibility of the lights by sculpting square pixels in the skin of the fruit. But how does one control the game? The stem of the pumpkin is actually a joystick. One of the most innovative parts of the physical build was to use drywall anchors on the inside to mount the joystick hardware.
Don’t miss a demo video after the jump.
Continue reading “Pumpkin Tetris inspired by our own LED Jack-o-lantern”
Hone your fundamental understanding of computer systems by completing this online course called NAND to Tetris. The idea is to develop each fundamental unit that goes into making computer programs a reality. This starts with logic gates, which are put together into modules that eventually become a functioning computer. From there you need an operating system, a compiler, and eventually you’ll be playing a game of Tetris which you programmed yourself.
It’s certainly not an easy journey, but if you have a computer at your disposal you should be able to make it all the way through the course. There’s a software suite which includes a hardware simulator so that the computer you’re building can be assembled using HDL instead physical components.
The concept is discussed in this TED talk given by [Shimon Schocken]. It is also embedded after the break and in addition to the NAND to Tetris project he shows off some self learning software on the iPad. To us it seems very much like the learning software [Neal Stephenson] envisions in the Young Lady’s Illustrated Primer from his Diamond Age novel.
Continue reading “Programming Tetris by first building a logic gate, then a computer, then…”
Tetris is unquestionably a game for the ages. Despite its simplicity, someone, somewhere will always find a way to port the game (Translation) to just about any electronic device that can handle it.
Earlier this year we showed you a slick MIDI sequencer project that was constructed using an Arduino Mega, which also happened to drive an incredibly detailed touch screen display. [Christian] must have gotten bored with his awesome creation one day, because he pulled the drum level display out of his Arduino Sequencer 808, and turned the LED array into a mini Tetris game.
As you can see in the video below, the game runs pretty well, though from what we can see it lacks any sort of score keeping. We dig it because we never really tire of Tetris clones, and we think it’s great that he kept his 808 sequencer design modular enough that he can pluck different components out for reuse in other projects.
Continue reading “Turning a MIDI sequencer display into a Tetris clone”
Careful, this hack might foster doubts about the level of fun you’re having at you own Computer Science department. Last weekend a group of students at MIT pulled off a hack of great scale by turning a building into a Tetris game board.
The structure in question is the Green Building on the Massachusetts Institute of Technology Campus. It houses the Earth, Atmospheric, and Planetary Sciences Departments, but was chose based on the size and regularity of the grid formed by the windows on one side. The group hasn’t provided much in the way of details yet, but the video after the break shows the game play and start-up screen. The middle portion of the building is used as a scrolling marquee to display the word “Tetris” before the game pieces start falling. We’re only guessing (and we hope you will add your conjecture in the comments section) but we’d bet they assembled a set of wireless RGB LED lamps and set one on the sill of each window. There does seem to be a number of ‘dead’ pixels, but it doesn’t diminish the fun of the overall effect.
If you don’t have your own building to play on, you should go small-scale and implement Tetris on a character display.
Continue reading “MIT Students take Tetris to a grand scale”