Cyborg Earthworm»Blog

The general plan

I am planning to build a higher quality desktop version with a better UI and more advanced testing features. The idea is to use C and Windows API for UI. Another alternative is to keep doing it in javascript and just improve the current version. The current plan is to go with C, because I think that it will be easier to optimize the matching code (which is currently the only bottleneck) in C than in js. Also, I think that a Windows UI will be better than a browser UI. Also, I think that handling saves will be easier and the result will be better. I'm not completely sure about any of that, though.

When I was making the prototype I couldn't answer two questions:
1. Is the game interesting? Will other people enjoy playing it? I'm still not completely convinced that making a higher quality version is something worth doing. If I will be the only person playing the game, I can play the lousy browser version and be happy. Thus, if you like playing the prototype, please let me know. If you have read the tutorial and still don't understand how to play, please let me know as well.
2. What is the best way to implement it? I'm neither a professional nor an experienced programmer, so any advice is very appreciated. Most of my decisions about implementation are not permanent and will be tested against alternatives.

Here are some ideas that I intend to implement, but first I'm going to introduce some terms.
1. Game length is the number of rows deleted in one game.
2. Stats run is a run that doesn't display the game, but only runs it for many times (currently it's 50 000 tetrominoes) to get data about how the program works. Usually there are many games in one stats run, and currently a stats run measures the average game length, as well as the smallest and the largest. (This is a goofy term, but the best I could come up with)

Gameplay ideas:
1. Exclusions. Sometimes a pattern is generally beneficial, but harmful in some special situations. The player will be able to describe those situations and tell the computer to drop the match in that case.
2. A polyomino editor to let the player introduce their own polyominoes.
3. A default position of a tetromino that is used when no patterns fit.
4. Allow assigning the same priority to several patterns. Currently if a pattern is matched, no patterns below it are looked at. We can allow two or more patterns to be at the same level.
5. To make the game more difficult, generate semi-random sequences of tetrominoes that don't fit into the landscape.
6. Make the playfield of variable size.
7. Let the player create test cases that consist of a starting position and a sequence of polyominoes. Maybe even create some default tests.

UI ideas:
1. Allow to make groups of patterns for conciseness.
2. Allow to mute (comment out) a pattern.
3. Generate symmetric patterns automatically.
4. The patterns should be draganddroppable. I'm tired of pressing ^ and v buttons.
5. Add keyboard controls.
6. Nice pictures instead of labels for polyominoes.
7. Make a better tutorial to give people a painless start. Maybe I will make a temporary video tutorial for the prototype, if this will be helpful.
8. Make quests like "Achieve an average game length of 100 with T, L and Gamma tetrominoes".
9. Maybe integrate the tutorial into quests.

Technical ideas:
1. In the matching code, replace loops over arrays with binary operations. Hopefully, this will speed it up. To do that, store both patterns and the playing field as an array of int32 instead of a 2d array of ints.
2. Try to run computations on a video card. I've heard that it's sometimes faster than using CPU.
3. A rudimentary VCS so that the player doesn't have to navigate in numerous "program(87).txt" files. Maybe draw the tree of versions.

Ideas for getting insight into how the program works:
1. Count how many times each pattern was invoked during the most recent stats run. This will supposedly show useless patterns.
2. Display a graph of how average length of a game converges during a stats run.
3. Display a graph of Distribution of lengths of games over a stats run.
4. Make deterministic or quasirandom testing.
5. Save sequences that fill the stack fast.
6. Automatically generate positions that aren't matched by any pattern.

Unresolved questions:
1. Open source or closed source?
2. How to assess efficiency of a program? This is a big mathematical question. I will write a separate blog post about it.
3. Should I use a UI library? Is there a good UI library for Windows?
4. Currently the programs are being saved in JSON. Is it better to use some other format? If not, same question about using a library.

Edit (2019, May 20):
I'm evicting old screenshots from the front page, so here is how the game looked when this post was written.


Simon Anciaux,
I tried it for a few minutes and I think it could be interesting.
The whole "solve a complete game of tetris" is a bit overwhelming at first I think. I would suggest to have some sort of levels, where you provide the user with a known sequence of tetrominoes and he has to make a program that would "solve" the sequence (and with simple ones you could do tutorials without much text). I think of something like TIS-100 (in concept, I'm not saying you need to make this a programing game) where you would have constraints and objectives like limit the number of pattern, or the number of times a pattern could be used, different types of pattern (move only, rotate only, both) and you could time things (e.g. moving a tetrominos to the left is 1 unit of time, rotating once is 1 unit of time...) so you could have different scores, and count a "game" score like in tetris, where 4 rows deleted at once is more points than 4 * 1 row...

A small note, at first I didn't understood that the buttons on the right were there to change the tetrominos. I though they were only labels for the checkbox. And if I put enough patterns, they are out of the canvas and I can't modify them.

Good luck with this project.
Anton Swifton,
Thank you for the feedback. Yes, solving the whole game is a big task, which I myself haven't done. I'm planning to make small tasks like "solve it for line tetromino only". For constraints, there are very natural constraints like "don't use this or that feature" (for instance, the "walls" button). But an upper bound for the number of patterns can also be a good constraint, I agree.

As for patterns going out of canvas, you can use the wheel to scroll through the list. I guess, either I haven't made it clear, or it doesn't work in your browser.