Hacker News new | past | comments | ask | show | jobs | submit login
2048 As A Service (github.com)
179 points by netvarun on Apr 1, 2014 | hide | past | web | favorite | 52 comments



    This API follows ZEST principles.

    All requests must begin with a /hi.

    Failure to do so will result in a 800 'Please say hi...' error.
Priceless!


2048-as-a-service author here.

Do also checkout our demo showcase app built using the 2048-as-a-service API:

2048 - Startup Growth Edition (MVP) - http://2048.semantics3.com/2048.html


It seems to flash the tiles upon movement instead of sliding them. Which is kind of annoying when I try to play it fast.


Doesn't work for me. I'm using Safari on iOS 7.1.


Doesn't work for me either. Latest version of Chrome on Android.


This feels like HN satire but someone has actually gone and written the code so it's fairly elaborate...


IMO, the best April 1st jokes are both good satire and well thought out enough to actually be implemented. Consider that RFC 1149 was intended as a joke, only to actually be successfully implemented years later.


I get that this is a joke, but I do think a really cool concept for a game would be one where there is just an API for the "state" and that is responsible for the mechanics and rules of the game, but that you would build your own custom client for the UI. For example, some kind of spaceship battle game where you create your own interface for controlling the ship... it would be kind of a meta-game where creating the interface a certain way might give you advantages in terms of efficiency versus others.


Schemaverse[1] could be considered something similar, I think, down to the "space-based strategy game", although it is controlled by raw SQL queries instead of an API.

[1] https://schemaverse.com/


Wow, that's really cool -- thanks!


That's exactly how FreeCiv (a clone of Sid Meier's Civilization II) is structured.


Back when I was working on my own MUD, this was one of my intents. I'd set up the system and then define an API off it for anyone to build their own client.

This was mostly because I was pretty strongly principled against forcing a particular display on the player. I wanted them to be able to explore via a text-based interface or a graphical one.

...and as it turns out, this was not the most ridiculously ambitious part of that project. :P


Building your own mudlib is always the most ridiculously amibitious part of any project of which it is a part :P

But don’t most MUD clients follow these principles? Playing with tf5 does give you quite a few advantages over playing with plain telnet.


I'm just worried in reality it would just mean a flood of a thousand clones in the appstore.


Sure, but maybe that could be a good thing. For example, you could provide an API for Chess that ranks players across apps. You could use a Facebook ID or similar to merge identities across applications. Then players could choose the chess app they prefer and still be engaged with the larger community.


You actually have something here.


In hindsight, this seems... inevitable ;-)

(I can't help but wonder where and how 2048 will show up next.)


10/10 would trust a ginormous 1-line Perl script again


Finally, 2048 is now enterprise-ready.


I see no Java in this repo?


And where are the unit tests?!?!


Unit tests? You mean functional api level load testing?


Are there seriously people running obfuscated Perl scripts from third parties in a terminal with root access?

You might as well open up a SSH daemon on the default port without root password.


Yes, you see Perl is hip now. And since the hipsters barely learned how to make an alert in JS before calling themselves a "full stack dev" they really don't know any better.

Perl one liner bro - check it out.


This is hilarious. This probably won't be, but should be the final entry in the series of 2048 clones.

I guess that you could de-servicify it and create own2048, not that I know how it would differ from the original version...


A desktop application that is distributed exclusively on floppies?


We are still missing the C64 version.


Bookmarklet. Play 2048 on any website, because.


Not sure if I'm doing it right, but http://2048.semantics3.com/2048/ (their mvp) just returns {"message":"Please say hi..."}


2048-as-a-service author here.

Type curl -L http://2048.semantics3.com/hi/start to get started. Here is a full example on how to play it:

https://github.com/Semantics3/2048-as-a-service#full-example...

If you want a full game on the console:

    perl -e 'my $host = "http://2048.semantics3.com/hi/";my $cmd = "curl --silent -L $host"."start";my $output = `$cmd`;my $session_id = $output;$session_id=~s/.*?ID:\s(\w+).*/$1/si;my %keyMap = ( 'w' => 0, 'd' => 1, 's' => 2, 'a' => 3);print STDERR $output,"\n";while(1) { print STDERR "Input (w - up, a - left, d - right, s - down):\n"; my $userInput = <STDIN>; chomp ($userInput); if(defined($keyMap{$userInput})) { $userInput = $keyMap{$userInput}; } else { print STDERR "Invalid move.. w - up, a - left, d - right, s - down\n"; next; } my $cmd = "curl --silent $host"."state/$session_id/move/$userInput"; my $output = `$cmd`; print STDERR "\n$output\n"; if($output=~/Message:/si) { exit(0); }}'


This is actually documented in the API. Turns out the API just wants your program to be polite and say hi when calling it.

https://github.com/Semantics3/2048-as-a-service#zest-princip...


It is nice to see the INTERCAL way of doing things making a comeback.


I think when they say MVP they might really mean AFJ, which would make the behavior you observed more understandable. Some AFJ purists would even claim it's the right way to do it under the methodology, which is arguably one of its major differences from the MVP credo.


What does AFJ mean?


April Fools Joke, I would assume.


Drop the /2048 from the end of the url and replace it with /hi/start/json It really does appear to respond as advertised!

Is this the most elaborate April fool of the day?


https://github.com/Semantics3/2048-as-a-service#zest-princip...

Which seems to suggest April 1 protocol.


Edit: It's missing a snarky game over message. Something like "you pivoted too late" would be perfect for a game like this, don't you think?

"Unstoppable! You are the next Rap Genius!"

"Growth Hacker Extraordinaire! You are the next Optimizely!"

I like it more than the other offers that April Fools has provided thus far. Somewhat reminiscent of this thread: http://chan.installgentoo.com/g/thread/38087806


And Threes!'s creators becomes more bitter and sour...


I would like to see an Excel extension with boss-mode key.


Slightly off-topic, but even this month's Ponder This challenge

http://domino.research.ibm.com/Comm/wwwr_ponder.nsf/Challeng...

is devoted to 2048...


I remember I used to play hangman by texting letters to a phone number and it would reply with how much of the word I had figured out. It would be awesome to be able to play 2048 over SMS (but painstakingly slow to complete).


COuld be formatted on 1 line. Like this: x-x-x-x-x-x-2-4-4

Requires some 1D to 2D though.


SMS seems to support newlines on my phone. Not sure how widely supported that is, though.


With MMS you could get pictures back :)


That "Sexy Perl one-liner" is hilarious.


For reference: perl -e 'my $host = "http://2048.semantics3.com/hi/";my $cmd = "curl --silent -L $host"."start";my $output = `$cmd`;my $session_id = $output;$session_id=~s/.?ID:\s(\w+)./$1/si;my %keyMap = ( 'w' => 0, 'd' => 1, 's' => 2, 'a' => 3);print STDERR $output,"\n";while(1) { print STDERR "Input (w - up, a - left, d - right, s - down):\n"; my $userInput = <STDIN>; chomp ($userInput); if(defined($keyMap{$userInput})) { $userInput = $keyMap{$userInput}; } else { print STDERR "Invalid move.. w - up, a - left, d - right, s - down\n"; next; } my $cmd = "curl --silent $host"."state/$session_id/move/$userInput"; my $output = `$cmd`; print STDERR "\n$output\n"; if($output=~/Message:/si) { exit(0); }}'


HN formatting screws up the code :(

This will work:

    perl -e 'my $host = "http://2048.semantics3.com/hi/";my $cmd = "curl --silent -L $host"."start";my $output = `$cmd`;my $session_id = $output;$session_id=~s/.*?ID:\s(\w+).*/$1/si;my %keyMap = ( 'w' => 0, 'd' => 1, 's' => 2, 'a' => 3);print STDERR $output,"\n";while(1) { print STDERR "Input (w - up, a - left, d - right, s - down):\n"; my $userInput = <STDIN>; chomp ($userInput); if(defined($keyMap{$userInput})) { $userInput = $keyMap{$userInput}; } else { print STDERR "Invalid move.. w - up, a - left, d - right, s - down\n"; next; } my $cmd = "curl --silent $host"."state/$session_id/move/$userInput"; my $output = `$cmd`; print STDERR "\n$output\n"; if($output=~/Message:/si) { exit(0); }}'


More readable:

    my $host = "http://2048.semantics3.com/hi/";
    my $cmd = "curl --silent -L $host"."start";
    my $output = `$cmd`;
    my $session_id = $output;

    $session_id =~ s/.*?ID:\s(\w+).*/$1/si;
    my %keyMap = ( 'w' => 0, 'd' => 1, 's' => 2, 'a' => 3);
    print STDERR $output, "\n";

    while(1) {
        print STDERR "Input (w - up, a - left, d - right, s - down):\n";
        my $userInput = <STDIN>;
        chomp ($userInput);

        if(defined($keyMap{$userInput})) {
            $userInput = $keyMap{$userInput};
    	}
    	else {
            print STDERR "Invalid move.. w - up, a - left, d - right, s - down\n";
            next;
    	}

    	my $cmd = "curl --silent $host"."state/$session_id/move/$userInput";
    	my $output = `$cmd`;
    	print STDERR "\n$output\n";

    	if($output=~/Message:/si) {
            exit(0);
    	}
    }


I was just thinking about trying to write a command line 2048 and then I see this.



This seems like a lot of work for a joke.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: