Lövetris - another impossible tetris
Posted: Thu Jan 16, 2014 12:51 pm
Hello everyone. Just like Numandina, I came to Löve by way of a job interview. I was chocked at first by the lack of types and brackets, but I soon learned to love it! I call my solution (to what has to be the same challenge) Lövetris:
https://www.dropbox.com/s/40cfq3yf3ryl4 ... 0Life.love
My algorithm uses three different factor to score each potential piece, and ranks them accordingly. It will then give you a piece whose rank corresponds to your level (1-7), so in level 4 you will always get the 4th best piece.
You can get a good idea about how my algorithm works by toggling debug mode within the game, by pressing d. You can then press m to move the piece around manually, or f to see how the search algorithm that checks (almost) all possible placements works. In debug mode you can also press S, Z, O, L, T, I or J to get the piece with that shape. These letters are also used in the scoring list at the to of the screen in debug mode.
In the game over screen there is a kind of game-in-the-game. You can draw with the mouse and change colors with the szoltij keys, and erase with x. Get rid of the menu text with m. Stop time with d and speed up with the down key.
CHALLENGE: Can you figure out what is actually going on in the in-game game, without checking the code?
The code is not overly commented, but I use long, descriptive objective c-style names of functions and variables, so it should be pretty easy to follow along and to modify. Please don't post it online without attribution, though.
/Güstäf
https://www.dropbox.com/s/40cfq3yf3ryl4 ... 0Life.love
My algorithm uses three different factor to score each potential piece, and ranks them accordingly. It will then give you a piece whose rank corresponds to your level (1-7), so in level 4 you will always get the 4th best piece.
You can get a good idea about how my algorithm works by toggling debug mode within the game, by pressing d. You can then press m to move the piece around manually, or f to see how the search algorithm that checks (almost) all possible placements works. In debug mode you can also press S, Z, O, L, T, I or J to get the piece with that shape. These letters are also used in the scoring list at the to of the screen in debug mode.
In the game over screen there is a kind of game-in-the-game. You can draw with the mouse and change colors with the szoltij keys, and erase with x. Get rid of the menu text with m. Stop time with d and speed up with the down key.
CHALLENGE: Can you figure out what is actually going on in the in-game game, without checking the code?
The code is not overly commented, but I use long, descriptive objective c-style names of functions and variables, so it should be pretty easy to follow along and to modify. Please don't post it online without attribution, though.
/Güstäf