This is bad Tetris. It's hateful Tetris. It's Tetris according to the evil AI from "I Have No Mouth And I Must Scream".
I have to be honest, this is not an entirely original idea. However, RRRR's implementation of the concept of a game of Tetris which always gives you the worst possible pieces leaves much to be desired:
(UPDATE: there is also Bastet, which can be played online here, but is also far too forgiving.)
HATETRIS was an experiment to rectify those flaws. Also, every coder has to build Tetris at least once in their life. In addition, I also have a passionate hatred of JavaScript, but I felt that that hatred was borne out of ignorance, so this was an attempt to reconnect with that most derided and crippled of languages. The latter failed, but there you go.
Some things you'll spot:
Yes, the game is written entirely in JavaScript. You can find the source code here on GitHub. Very few real games are amenable to this, but Tetris, being played on a very wide grid, is one of them. If you want to save the game locally you'll find a few things that are easy to tweak, including the dimensions of the playing field and the height of the bar.
You can also put custom pieces in the list at the top, including pieces of more or fewer than 4 "bits" (components). Note that at the moment these pieces are sorted so that the least convenient ones are at the top. All things being equal, with no other major differences between possibilities, the AI will give you an S.
No, there is no gravity: on the one hand I simply never got around to implementing it and on the other hand I honestly think that gravity is the least of your problems with this particular Tetris clone.
The method by which the AI selects the worst possible piece is extremely simple to describe (test all possible locations of all possible pieces, see which of the pieces' best-case scenarios is the worst, then spawn that worst piece), but quite time-consuming to execute, so please forgive me if your browser chugs a little after locking each piece. If you can figure out a way to accelerate the algorithm without diminishing its hate-filled efficiency, do let me know. The algorithm for "weighing" possibilities is to simply maximise the highest point of the "tower" after the piece is landed.
More complex algorithms could be possible, but aren't strictly necessary. Also, now that replays have been added, I can't change the algorithm without screwing up or invalidating all the replays.
Yes, you will get a lot of S pieces. But it doesn't give you solely S pieces - if that were the case, then it would be possible to make lines forever, which is much too easy.
If you can't figure out how to turn a constant stream of S pieces to your advantage, that's your problem. Rest assured that once you do, other pieces will appear. If you get creative, it is possible to force all 7 different pieces to appear, including even those incredibly useful T pieces.
There is no randomness in the process - the AI is deterministic, so you are all playing the same game. It may be possible to create a strategy to get into a loop and continuously outplay the AI. If so, let me know. If not, my top score is 5 lines.
I've added some replay functionality. This will allow you to share particularly high-scoring games with other people just by passing a simple string of hexadecimal around, instead of having to laboriously capture video!
A small update regarding the possibility of HATETRIS II (i.e. the one where the algorithm looks more than 1 piece into the future). I successfully implemented this recursive search, which can theoretically look to unlimited depth. I also added a huge number of optimisations - such as treating the well as a list of binary numbers rather than an array - in order to make it so that new pieces were generated in 0.5 seconds under these conditions, rather than closer to 30 seconds without those optimisations. I also added functionality to add more variety to the pieces.
Unfortunately, this version of the game is still far too easy. I can routinely get 3 lines or more in this mode, without any real planning. It is frighteningly straightforward to devise a situation where even looking two moves ahead there is no way for the AI to prevent you from getting at least one line. Forcing more variety in the pieces, even if the piece chosen is always one of the "equal worst", makes the game a lot easier. And finally, looking three moves ahead is computationally impractical to achieve (in client-side JavaScript, at any rate). I think it should be possible to build a game which permits no lines whatsoever, and I hope to create this, and I'm not intending to release any kind of intermediate solution. More as it happens.
Contrary to what is stated here, HATETRIS is not related to Hatris.
Replays are now presented in Base65536, making them just about small enough to be shared via Twitter. Old replays will still work, of course.
Replays are now presented in Base2048. Thanks to a combination of this and the new increased character limit on Twitter, even the latest high score replay of 31 lines will now fit in a Tweet, which it previously did not. Old hex and Base65536 replays will continue to work.
Atypical's 11-point run is "ϥقໂɝƐඖДݹஶʈງƷ௨ೲໃܤѢقҾחࢲටฅڗ௨ΡІݪ௨ళȣݹࢴටງ໒௨ஶໃܥ௨റІݮ௨ఴІݥذඡଈݹƍق๓অஒॴแђञඖЅи௨sǶɔۑడПݷޠقԩݹࠉൿຟɓతණງஈশ੬෪অࠑථධٽଫ൝ଆࡨশ૫СܭߜయլݚɶऋഭܭرɤธӃస൯
".
An anonymous guest at the Speed Demos Archive achieved 17 points with this run: "ۑටժݹਐටดݹமsරݪƐජଈݲ௨ණໃφذගדݶಒටܨݹসටѧݹ൭ඤדݜ௧ซະਨதԀໃڻಜʈະसѻගІѠ௧ซະऄமϺเݹߤඨVܭѻඳІʅઅගتףயҔзݢऊටȝधѻೲܨݷಗචЄࡨଫඝܘɚமʈฅ๐ષ෦ฅ൩Ԥ๗ཚޡதԻѣݪॳ౾ແߢࡃశ༩ܣறඤÐњ௬ගƫঋ୦ԟȠॾಭ
".
Same person got 20 lines later in the thread: "ۑටलݹञටฅཧஶʈໃŦ௨ਮܘݶذಗไӔƐකІݶಒටࡍݹصටलݲ௭ඈຯঅஶʈໃഡ௨ੲժݢ௨ཙງ൫ৎටफಏ௧Δαཧऊටฦџ௨ೱܘקஶΟໄ๐ஒقฐݹࢲقܨݹऍ੬ဒھۑశະकஶइഥಏதԻѣݸಣҔଜݸ౻ණໄঅࠁඡܘѣஶsࡎח৭ؾ૭ঔதඞ୩ڽഡలѣݢষܯ໐џஹڏ૭חɢචÐלமΟիॾ౯مຯםமȺЉރ௮ൿങھࠐ7
".
Things Of Interest reader Ivenris is reporting 22: "ಳටܤݹஜƣແࡑ௨ఽໃݚޛඡܦݹরට๐ݹஜуເঅ௧ڈໃݹ௩Οເɕ௧ڠແऔ௨૮Іܢ௨කܘݓ௨౾Іݠ௨කƔݹகقฆݹϢඈՀݹభඨÐݚѻඍɑݚѻಬໃࡠɷళɑݢ௨ڈໃݷ౫ඡІމமҔธࡨஐට൧ۏଛقԟݱ௨മฆݠ௧ΑషݚɷٴฅՉதฃฅݶذڌฅٽࠑ൝ܘނஐؾʑɥࢶلܪݣ௫سଅݸԫצถܤஓඥ۵ݝ
".
The same anonymous guest at the Speed Demos Archive is now claiming an astounding 28: "ۑටݕݹযටະࠇ௧෪ໃܭИටܨݹસට๐ݹஜуໃݶԥڈໃݹ௩Οແऔ௧ฃໂɕ௧ڠແऄ௨ඥܘށ௨ౘЈཧதقഫݪޛೲໄ൫੫ගƬݶԊಋໃݒষܯໃץౚටࢩݹɷගVݪѻචȣݻޛඳଈף௧ڴໃݼѻദݏಏ௩Թໃڽௐقଭނ௩Ϻ༩ݶಈඝଈڍஶs༡ݸ൘Οະऔৡක૭ɒഩಬѣݲষܯະसѻಋଈजƐఽ໐ݪɷٴฅݸౚಀຯஇసضɱŦષට༣ܡஶضʑɠଢമ໘ܣறඡଢڝहథ༣ބஜҕऐ
".
Slashdot.jp user Deasuke has reached 30: "ౚටลݹமȺІݿ௨ගÐݸಳටɱݹশට๐ݹஜуເঅ௧ڈໃݹ௩Οເஜ௨ಗໃܭ௨൝ܘܭۑටຜݹౚඦͲஉݣටմݹԥ൝ໃѢ௨ɊІܥࡂܯໃρಛԀໃݪরටเݹਫටঋݹछقฐݹहටܨݹసقܨݺɷඩܘѧ௦قෆऄதටฅ൫ࠑඨɑݹமΟลຍஐق༱ݚذงໃͷશජХࢭಎටȻݢமҔСݐෂඞවౘஓӺХಏமԗVݏआඖໃϠஐΟවݶѻ౾ແࡑࢲඤÐɥઅඪຯஇಈ౾ຣݪذඪϽऔƐڠÐלஜҕɐזѻڐ༥މభ೯۱ࠇࢳ൯
".
Twitter user @chromeyhex edges out the previous record with 31: "௨ഖƌݯߜࠏІWƑsໃa௨೯ܘݷಳජଈیԪؼʥݺԥඞܘݲࠐڄໂঅமةໃݹ௧ړІٽ௨൞ໃZ௨ಘІܥࠐΣІZߜටȜখذජНݹߛeʛݹߤปເѧ௩ԚໂՉࢸටuа௨સȣݷłقෆঅਏeܘԔצقషݸɢڠຜঀಧҸມѧஐට༪൩ԊಅഫܡथsถԡԦԚໃɥஸقࡈɕɠɈไݸצقషݰਵϺФঅஓػݐɓԞуຯɕझࡈ๐ݞझࢶІݞमปദஈƉؿଭݪஸҩЂ൸ԛمϦGƁҨVھԥචЅշࡂ෮लݷƘණ໘ࠅƘಧНקࢻҨฆӘದԋϝପࠑ੧ͳݲடփරݞਵΚϼɢԒԺٳѦԤࠌξGಘسਯܥஶҋϮτथlϼʔ
".
Discussion (159)
2010-04-04 00:54:52 by frymaster:
2010-04-04 00:55:20 by Thrack:
2010-04-04 01:00:51 by qntm:
2010-04-04 02:00:44 by Bauglir:
2010-04-04 02:21:15 by JeremyBowers:
2010-04-04 05:15:42 by Aaron:
2010-04-04 06:40:38 by Kazanir:
2010-04-04 07:03:59 by cory:
2010-04-04 09:04:30 by Atypical:
2010-04-04 15:02:13 by Aegeus:
2010-04-04 15:48:38 by Michael:
2010-04-04 15:52:41 by Michael:
2010-04-04 16:06:58 by qntm:
2010-04-05 01:24:39 by Daedalus:
2010-04-05 02:48:26 by Atypical:
2010-04-05 03:01:34 by Atypical:
2010-04-05 03:21:39 by Atypical:
2010-04-05 03:26:59 by sunburstbasser:
2010-04-05 04:47:24 by Andrew:
2010-04-05 06:32:58 by slowbroTom:
2010-04-05 07:01:10 by Lar:
2010-04-05 07:13:07 by Tom:
2010-04-05 07:35:14 by Atypical:
2010-04-05 07:49:14 by Tom:
2010-04-05 15:12:55 by Adam:
2010-04-07 03:48:22 by Thrack:
2010-04-07 05:46:10 by Michael:
2010-04-07 09:18:39 by Tom:
2010-04-07 14:46:16 by Tom:
2010-04-07 16:31:06 by Val:
2010-04-07 16:31:37 by Val:
2010-04-07 18:08:01 by Thrack:
2010-04-07 18:58:41 by qntm:
2010-04-07 19:16:08 by Atypical:
2010-04-07 20:41:27 by qntm:
2010-04-07 22:39:53 by Atypical:
2010-04-07 22:40:09 by Atypical:
2010-04-08 05:29:10 by Daniel:
2010-04-08 12:57:50 by Thrack:
2010-04-09 07:53:41 by Tom:
2010-04-09 21:13:37 by Atypical:
2010-04-09 21:40:22 by qntm:
2010-04-09 22:42:46 by John:
2010-04-10 01:28:43 by anonymous:
2010-04-10 03:35:21 by Tom:
2010-04-10 05:04:41 by Kazanir:
2010-04-10 18:18:52 by Guest:
2010-04-12 21:01:23 by Atypical:
2010-04-13 15:57:04 by Jiaying:
2010-04-14 00:56:52 by ejl:
2010-04-14 03:48:20 by my:
2010-04-14 06:32:38 by EternalDensity:
2010-04-14 16:33:12 by neil:
2010-04-15 17:05:11 by RetroBLM:
2010-04-16 21:59:46 by Ivenris:
2010-04-18 16:46:32 by neil:
2010-04-21 00:04:54 by Power:
2010-04-22 19:02:45 by ReverseEngineer:
2010-04-22 19:13:31 by T:
2010-04-22 19:47:50 by TheGZeus:
2010-04-23 05:12:53 by neil:
2010-04-23 10:54:26 by me:
2010-04-23 11:49:04 by gumboot:
2010-04-23 23:03:09 by Chuck:
2010-04-24 20:28:16 by Kamineko:
2010-04-24 22:48:53 by qntm:
2010-04-25 02:20:09 by dwineman:
2010-04-25 20:04:13 by digarb:
2010-04-25 20:32:10 by Kamineko:
2010-04-25 21:21:52 by qntm:
2010-04-27 22:39:42 by webmaren:
2010-04-28 12:15:24 by Dimatra:
2010-04-29 04:43:22 by Dimatra:
2010-04-29 16:58:24 by Tom:
2010-04-30 15:57:22 by CS:
2010-04-30 16:16:13 by Yan:
2010-04-30 17:32:34 by Guest:
2010-04-30 23:10:10 by qntm:
2010-05-01 06:56:28 by CS:
2010-05-01 13:31:39 by Guest:
2010-05-03 19:31:03 by sone:
2010-05-03 21:13:13 by qntm:
2010-05-03 21:32:05 by qntm:
2010-05-03 22:23:03 by qntm:
2010-05-03 22:42:13 by hasi:
2010-05-03 23:25:03 by qntm:
2010-05-04 01:36:24 by sone:
2010-05-04 04:20:17 by masuidrive:
2010-05-04 09:52:49 by qntm:
2010-05-04 10:33:55 by masuidrive:
2010-05-04 17:02:47 by SlashdotJP:
2010-05-05 11:50:48 by archmond:
2010-05-05 22:51:13 by T:
2010-05-06 00:54:22 by CS:
2010-05-06 02:48:21 by T:
2010-05-06 10:06:03 by qntm:
2010-05-06 12:52:12 by T:
2010-05-06 21:35:06 by qntm:
2010-05-06 21:59:16 by qntm:
2010-05-07 06:54:00 by T:
2010-05-07 18:19:30 by Luke:
2010-05-07 18:46:44 by qntm:
2010-05-10 13:29:18 by bshnet:
2010-05-10 14:14:44 by qntm:
2010-05-19 03:23:13 by Steve:
2010-05-19 08:08:40 by qntm:
2010-06-01 00:19:48 by Hobbes:
2010-10-12 10:12:52 by bottleHeD:
2010-10-12 10:18:52 by bottleHeD:
2010-10-20 23:26:48 by dtanders:
2010-11-15 23:56:34 by trophymursky:
2011-02-04 09:55:21 by Rick:
2011-02-04 11:06:20 by qntm:
2011-02-07 10:11:55 by Rick:
2011-02-07 16:04:23 by qntm:
2011-02-09 11:06:43 by Rick:
2011-03-29 20:25:44 by HydraBurrito:
2011-03-29 21:25:19 by qntm:
2011-04-20 02:21:32 by FinalOne:
2011-04-20 09:23:43 by qntm:
2011-04-22 04:43:19 by wallawalla:
2012-04-22 10:25:04 by Robert:
2012-04-22 10:31:32 by qntm:
2012-04-22 12:26:50 by Robert:
2012-06-10 17:37:59 by Muzozavr:
2012-06-19 18:41:42 by Muzozavr:
2012-08-14 11:20:15 by Robin:
2012-11-05 14:38:09 by Muzozavr:
2013-01-16 03:57:24 by MK:
2013-12-01 04:58:32 by QuillMcGee:
2014-02-04 05:08:12 by Quelthias:
2014-12-02 17:20:54 by Piotr:
2015-09-18 05:31:04 by Ben Goldberg:
2015-09-18 06:00:31 by Ben Goldberg:
2016-03-07 17:01:25 by vaiyt:
2016-04-26 15:17:11 by saladin_the_great:
2016-06-17 14:26:30 by Dwscdv3:
2016-08-01 07:36:20 by Jared:
2017-02-25 07:11:20 by Piotr Grochowski:
2017-06-06 23:46:30 by @chromeyhex:
2017-06-07 00:20:52 by qntm:
2017-06-07 01:13:20 by qntm:
2017-07-23 14:43:03 by mina:
2018-08-14 10:42:49 by tigerninjaman:
2018-08-14 11:00:03 by qntm:
2019-01-03 07:16:30 by Noumenon72:
2019-01-08 07:58:58 by Spain_programer_player:
2019-01-08 08:24:20 by spain_programer_player:
2019-01-08 08:25:09 by spain_programer_player:
2019-06-20 08:34:42 by PiotrGrochowski:
2019-06-20 08:40:45 by PiotrGrochowski:
2019-06-20 08:43:25 by PiotrGrochowski:
2019-09-19 21:26:11 by Phat_Doinks:
2020-01-28 18:04:44 by '"><svg/onload=alert(/hate/)>:
2020-05-08 09:57:39 by dfd:
2021-01-14 21:57:17 by thecodesareallamongus:
2021-05-06 22:49:10 by Captainbob:
2021-05-07 11:17:27 by FU:
2021-05-08 03:16:34 by Wowfunhappy: