Atomic

LD25

Way over my head

Thought making a basic tetris game on the Arduino would be way simpler… right now all it does is draw a 10×20 board (each block is 2×2 filled pixels with 1 empty pixel around) and draw the next piece on the top.

All pieces are made of 4 blocks so I ended up storing 8 bytes per piece with the relative x and y coordinates of each block. I’m pretty sure I went the wrong way about this.. actually this consumed pretty much all of my afternoon ’cause I kept trying to think of a better way to avoid using up those 8KB of RAM..

IMG_1635

First playable version

After I solved the whole how-to-store-those-damn-pieces thing my progress got much faster :)

I ended up implementing commands to move/rotate the pieces like regular tetris to help debugging before making the AI (hardest part by far). Those are via USB to the Arduino so I don’t have to mess with hardware buttons again. You also have the physical button to change the next piece (I do it a couple times on the video below).

Tetris is somewhat playable but with some of the twists of Sirtet (the name of my game!): you gain negative score when a line is filled and positive score when the top of the board gets filled. As of now it has no restart option (on the final version you’ll just gain points from making the AI fail and speed will increase).

Here’s a video (forgive me for the shaky camera, poor lighting and the damn LCD glitches):

http://www.youtube.com/watch?v=suzIKdtGXvI

AI

Spent a lot of time thinking about the AI. Here’s what I think is my best shot:

(do this every time a new piece is chosen)

Repeat for each column and rotation possible:

-Apply r rotatiosn and move piece to x column as fast as possible

-Compute the resulting board

-Store the sequence of moves and the amount of points (inversely proportional to average column height and directly proportional to number of lines cleared)

Choose the sequence of moves that gives higher points.

 

This will miss all scenarios where the best move involves going to one side and then back below another piece. It will also require one move per y drop or it’s gonna look very ugly.

Wish I could’ve come up with something better but I’m not even sure I’ll be able to get this working under a 16MHz processor in the few hours I have left.

AI working but really dumb

Implementing the AI of my last post wasn’t nearly as hard as I figured it’d be.. and not very slow either. It’s likely that a more complete AI is possible!

Here’s what it does:

(do this every time a new piece is chosen)

Repeat for each column and rotation possible:

-Apply r rotations and move piece to x column as fast as possible

-Compute the resulting board

-Store the sequence of moves and the amount of points (inversely proportional to average column height and directly proportional to number of lines cleared)

Choose the sequence of moves that gives higher points.

 

Minimizing average column height is a bad idea after all. It ends up chosing to stack high towers to keep some columns really low and loses the game very quickly. I’ll try throwing in more criteria and see what happens.

Done!

Sirtet is done!

The AI could be a lot better if I had a couple more hours but it’s definitely not random and the game is playable.

I’ve decided to submit to the jam for 3 reasons:

-It requires an Arduino Mega (haven’t tested but probably won’t run correctly on the Uno because it uses slightly more than 2KB of RAM) which means (almost) no one will be able to play it.

-I might have broken a rule, not sure. I used a self-made library (a very simple one) without declaring before starting. I did share it on one of my posts.

-Since people won’t be able to play it I *need* to upload a gameplay video. Its uploading to YouTube right now but it’s 400MB and will take over an hour, which means I’ll only officially submit the game tomorrow.

That said the game *is* done before midnight and I even took care of showing my clock on the video for the sake of honor 😉

I’ll zip the source right now and upload tomorrow.

.NET

I’m surprised with the sheer amount of .NET entries. Me likey :)