HALtris - A.I. Tetris Offshoot
Posted: Tue Dec 31, 2013 11:01 am
Hello.
I had to learn löve in the space of a weekend for a job application, and I ended up programming this tetris game where you are pitted against an AI who "chooses" which pieces are being handed to you in each turn. I liked the end result so much I've decided to post it here.
Turning the AI off will choose pieces randomly (regular tetris), while setting it to "1" (evil) will give you the worst possible piece for the current board configuration, and setting it to "-1" will give you the best possible piece.
The code is fully commented and although it can be made better, consider this just an alpha build (if I get feedback I may update it) and the code can be tidied up plenty. Included are playing music and having a rudimentary menu, and I've also displayed an "AI thinking process" board on the right that gives insight on how each piece was chosen. You can turn this off if you want to play without waiting.
The algorithm takes in several factors which are weighted and added up. You can easily edit these in the code. So far, there is only ONE case which enables you to "beat" the evil AI (try to figure it out). After fixing that I think it would really be impossible to get but one single line off of it. I've seen some similar games online but they aren't very robust and their AI can be easily beaten.
To make things entertaining, there is the option of switching difficulty in real time, which means you can pit the good AI versus the evil AI (by alternating between the two), or use the good AI to help you when you're in a tight spot.
Please check it out and give me feedback. Thanks!
Google Drive Link: https://docs.google.com/file/d/0B0etIhI ... R3Mkk/edit
EDIT:
Link for löve 0.9.0: https://docs.google.com/file/d/0B0etIhI ... =drive_web
I had to learn löve in the space of a weekend for a job application, and I ended up programming this tetris game where you are pitted against an AI who "chooses" which pieces are being handed to you in each turn. I liked the end result so much I've decided to post it here.
Turning the AI off will choose pieces randomly (regular tetris), while setting it to "1" (evil) will give you the worst possible piece for the current board configuration, and setting it to "-1" will give you the best possible piece.
The code is fully commented and although it can be made better, consider this just an alpha build (if I get feedback I may update it) and the code can be tidied up plenty. Included are playing music and having a rudimentary menu, and I've also displayed an "AI thinking process" board on the right that gives insight on how each piece was chosen. You can turn this off if you want to play without waiting.
The algorithm takes in several factors which are weighted and added up. You can easily edit these in the code. So far, there is only ONE case which enables you to "beat" the evil AI (try to figure it out). After fixing that I think it would really be impossible to get but one single line off of it. I've seen some similar games online but they aren't very robust and their AI can be easily beaten.
To make things entertaining, there is the option of switching difficulty in real time, which means you can pit the good AI versus the evil AI (by alternating between the two), or use the good AI to help you when you're in a tight spot.
Please check it out and give me feedback. Thanks!
Google Drive Link: https://docs.google.com/file/d/0B0etIhI ... R3Mkk/edit
EDIT:
Link for löve 0.9.0: https://docs.google.com/file/d/0B0etIhI ... =drive_web