Why we Build Algorithms w/Tetris
What do we mean by algorithms?
Tetris Rules:
Ok so obviously I’m not gonna spell out every rule but there is some general game strategy:
Lines cleared | Points |
1 line clear | 100 points x level |
2 line clear | 300 points x level |
3 line clear | 500 points x level |
Tetris | 800 points x level |
Let’s Watch some Pros…
So, watching this, we have some things to think about for any given piece dropping
Keep the build relatively flat
Don’t leave gaps
Leave a column open for Tetris
Don’t build completely flat for S and Z
If you’re not holding an I and you get one, hold it and build more
Stack columns opposite the open column
Only soft drop if necessary (try to build w/o)
And obviously these guys are thinking of all of these things but who can keep all that in their head at one time?
This is clearly wildly inefficient
We should come up with a list of precedence in which we can continuously build well given any piece
We should also have a mental list of the best situation for any piece
Build an algorithm such that you can be presented with any piece and have a spot that is ideal for it and allows for continuation of the algorithm.
Purpose:
We could even think of this as if/else
If:
And:
Then: fill these spots
Else: Wait for these and build higher
One more if/else
If: hold has something other than an I piece
and there is an I piece currently dropping
Then: move I piece to hold
and build with current hold piece
So let’s write our precedence list:
We’ve gone over what individual pieces do, so let’s consider the choices we can make for any piece…
What do we learn about algorithms as a whole from this?