TE
TechEcho
Home
24h Top
Newest
Best
Ask
Show
Jobs
English
GitHub
Twitter
Home
Show HN: 2048-as-a-service, an API to build complex 2048 based apps
4 points
by
vinothgopi
about 11 years ago
1 comment
vinothgopi
about 11 years ago
tl;dr paste this in your console for demo<p>perl -e 'my $host = "<a href="http://2048.semantics3.com/hi/";my" rel="nofollow">http://2048.semantics3.com/hi/";my</a> $cmd = "curl --silent -L $host"."start";my $output = `$cmd`;my $session_id = $output;$session_id=~s/.<i>?ID:\s(\w+).</i>/$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); }}'