TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: 2048-as-a-service, an API to build complex 2048 based apps

4 点作者 vinothgopi大约 11 年前

1 comment

vinothgopi大约 11 年前
tl;dr paste this in your console for demo<p>perl -e &#x27;my $host = &quot;<a href="http://2048.semantics3.com/hi/&quot;;my" rel="nofollow">http:&#x2F;&#x2F;2048.semantics3.com&#x2F;hi&#x2F;&quot;;my</a> $cmd = &quot;curl --silent -L $host&quot;.&quot;start&quot;;my $output = `$cmd`;my $session_id = $output;$session_id=~s&#x2F;.<i>?ID:\s(\w+).</i>&#x2F;$1&#x2F;si;my %keyMap = ( &#x27;w&#x27; =&gt; 0, &#x27;d&#x27; =&gt; 1, &#x27;s&#x27; =&gt; 2, &#x27;a&#x27; =&gt; 3);print STDERR $output,&quot;\n&quot;;while(1) { print STDERR &quot;Input (w - up, a - left, d - right, s - down):\n&quot;; my $userInput =&lt;stdin&gt; ; chomp ($userInput); if(defined($keyMap{$userInput})) { $userInput = $keyMap{$userInput}; } else { print STDERR &quot;Invalid move.. w - up, a - left, d - right, s - down\n&quot;; next; } my $cmd = &quot;curl --silent $host&quot;.&quot;state&#x2F;$session_id&#x2F;move&#x2F;$userInput&quot;; my $output = `$cmd`; print STDERR &quot;\n$output\n&quot;; if($output=~&#x2F;Message:&#x2F;si) { exit(0); }}&#x27;