代码拉取完成,页面将自动刷新
<?xml version="1.0" encoding="utf-8"?>
<search>
<entry>
<title>Live</title>
<url>/Live/f33d8391.html</url>
<content><![CDATA[<p>Welcome to <a href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo new <span class="string">"My New Post"</span></span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-1"><a href="#Run-server-1" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-1"><a href="#Generate-static-files-1" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-1"><a href="#Deploy-to-remote-sites-1" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-2"><a href="#Run-server-2" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-2"><a href="#Generate-static-files-2" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-2"><a href="#Deploy-to-remote-sites-2" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-3"><a href="#Run-server-3" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-3"><a href="#Generate-static-files-3" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-3"><a href="#Deploy-to-remote-sites-3" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-4"><a href="#Run-server-4" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-4"><a href="#Generate-static-files-4" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-4"><a href="#Deploy-to-remote-sites-4" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-5"><a href="#Run-server-5" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-5"><a href="#Generate-static-files-5" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-5"><a href="#Deploy-to-remote-sites-5" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-6"><a href="#Run-server-6" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-6"><a href="#Generate-static-files-6" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-6"><a href="#Deploy-to-remote-sites-6" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
]]></content>
<categories>
<category>Live</category>
</categories>
</entry>
<entry>
<title>C&C++</title>
<url>/Software/C-C/f43812d6.html</url>
<content><![CDATA[<p>Welcome to <a href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-1"><a href="#Deploy-to-remote-sites-1" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-1"><a href="#Run-server-1" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-1"><a href="#Generate-static-files-1" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-2"><a href="#Deploy-to-remote-sites-2" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-2"><a href="#Run-server-2" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-2"><a href="#Generate-static-files-2" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-3"><a href="#Deploy-to-remote-sites-3" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
]]></content>
<categories>
<category>Software</category>
<category>C&C++</category>
</categories>
</entry>
<entry>
<title>Flutter</title>
<url>/Software/Flutter/e5974716.html</url>
<content><![CDATA[<p>Welcome to <a href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo new <span class="string">"My New Post"</span></span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-1"><a href="#Run-server-1" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-1"><a href="#Generate-static-files-1" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-1"><a href="#Deploy-to-remote-sites-1" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-2"><a href="#Run-server-2" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-2"><a href="#Generate-static-files-2" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-2"><a href="#Deploy-to-remote-sites-2" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-3"><a href="#Run-server-3" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-3"><a href="#Generate-static-files-3" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-3"><a href="#Deploy-to-remote-sites-3" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-4"><a href="#Run-server-4" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-4"><a href="#Generate-static-files-4" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-4"><a href="#Deploy-to-remote-sites-4" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-5"><a href="#Run-server-5" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-5"><a href="#Generate-static-files-5" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-5"><a href="#Deploy-to-remote-sites-5" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-6"><a href="#Run-server-6" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-6"><a href="#Generate-static-files-6" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-6"><a href="#Deploy-to-remote-sites-6" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
]]></content>
<categories>
<category>Software</category>
<category>Flutter</category>
</categories>
</entry>
<entry>
<title>SVG switch tag</title>
<url>/Software/HTML-CSS/c43ef17d.html</url>
<content><![CDATA[<h1 id="SVG-switch-tag"><a href="#SVG-switch-tag" class="headerlink" title="SVG switch tag"></a>SVG switch tag</h1><figure class="highlight xml"><table><tr><td class="code"><pre><span class="line"><span class="tag"><<span class="name">svg</span> <span class="attr">xmlns</span>=<span class="string">"http://www.w3.org/2000/svg"</span> <span class="attr">width</span>=<span class="string">"100%"</span> <span class="attr">viewBox</span>=<span class="string">"0 -20 100 50"</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">switch</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">systemLanguage</span>=<span class="string">"ar"</span>></span>مرحبا<span class="tag"></<span class="name">text</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">systemLanguage</span>=<span class="string">"zh-cn"</span>></span>你好!<span class="tag"></<span class="name">text</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">systemLanguage</span>=<span class="string">"zh-tw"</span>></span>您好!<span class="tag"></<span class="name">text</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">systemLanguage</span>=<span class="string">"de,nl"</span>></span>Hallo!<span class="tag"></<span class="name">text</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">systemLanguage</span>=<span class="string">"en"</span>></span>Hello!<span class="tag"></<span class="name">text</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">systemLanguage</span>=<span class="string">"en-us"</span>></span>Howdy!<span class="tag"></<span class="name">text</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">systemLanguage</span>=<span class="string">"en-gb"</span>></span>Wotcha!<span class="tag"></<span class="name">text</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">systemLanguage</span>=<span class="string">"en-au"</span>></span>G'day!<span class="tag"></<span class="name">text</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">systemLanguage</span>=<span class="string">"es"</span>></span>Hola!<span class="tag"></<span class="name">text</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">systemLanguage</span>=<span class="string">"fr"</span>></span>Bonjour!<span class="tag"></<span class="name">text</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">text</span> <span class="attr">systemLanguage</span>=<span class="string">"ja"</span>></span>こんにちは<span class="tag"></<span class="name">text</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">text</span>></span>☺<span class="tag"></<span class="name">text</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">switch</span>></span></span><br><span class="line"><span class="tag"></<span class="name">svg</span>></span></span><br></pre></td></tr></table></figure>
]]></content>
<categories>
<category>Software</category>
<category>HTML&CSS</category>
</categories>
</entry>
<entry>
<title>Java</title>
<url>/Software/Java/df2849ec.html</url>
<content><![CDATA[<p>Welcome to <a href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo new <span class="string">"My New Post"</span></span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-1"><a href="#Run-server-1" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-1"><a href="#Generate-static-files-1" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-1"><a href="#Deploy-to-remote-sites-1" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-2"><a href="#Run-server-2" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-2"><a href="#Generate-static-files-2" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-2"><a href="#Deploy-to-remote-sites-2" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-3"><a href="#Run-server-3" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-3"><a href="#Generate-static-files-3" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-3"><a href="#Deploy-to-remote-sites-3" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-4"><a href="#Run-server-4" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-4"><a href="#Generate-static-files-4" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-4"><a href="#Deploy-to-remote-sites-4" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-5"><a href="#Run-server-5" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-5"><a href="#Generate-static-files-5" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-5"><a href="#Deploy-to-remote-sites-5" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-6"><a href="#Run-server-6" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-6"><a href="#Generate-static-files-6" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-6"><a href="#Deploy-to-remote-sites-6" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
]]></content>
<categories>
<category>Software</category>
<category>Java</category>
</categories>
</entry>
<entry>
<title>JavaScript</title>
<url>/Software/JavaScript/cc1b9611.html</url>
<content><![CDATA[<p>Welcome to <a href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p>
]]></content>
<categories>
<category>Software</category>
<category>JavaScript</category>
</categories>
</entry>
<entry>
<title>Spring MVC 重定向跳转空白</title>
<url>/Software/Java/Spring-boot/4c76964e.html</url>
<content><![CDATA[<h1 id="Spring-MVC-重定向跳转空白"><a href="#Spring-MVC-重定向跳转空白" class="headerlink" title="Spring MVC 重定向跳转空白"></a>Spring MVC 重定向跳转空白</h1><figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">public</span> ModelAndView <span class="title function_">del</span><span class="params">(<span class="meta">@PathVariable</span> Long id)</span> {</span><br><span class="line"> <span class="type">ModelAndView</span> <span class="variable">modelAndView</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">ModelAndView</span>(<span class="string">"redirect:/t/index?sort=sort"</span>);</span><br><span class="line"> modelAndView.setStatus(HttpStatus.MOVED_PERMANENTLY);</span><br><span class="line"> <span class="keyword">if</span> (id == <span class="number">0L</span>) {</span><br><span class="line"> <span class="keyword">return</span> modelAndView;</span><br><span class="line"> }</span><br><span class="line"> templateRepository.deleteById(id);</span><br><span class="line"> <span class="keyword">return</span> modelAndView;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>注意返回码:301,返回200就空白</p>
]]></content>
<categories>
<category>Software</category>
<category>Java</category>
<category>Spring boot</category>
</categories>
</entry>
<entry>
<title>Spring boot static 静态文件不能访问</title>
<url>/Software/Java/Spring-boot/8f126aab.html</url>
<content><![CDATA[<h1 id="static-静态文件不能访问"><a href="#static-静态文件不能访问" class="headerlink" title="static 静态文件不能访问"></a>static 静态文件不能访问</h1><h2 id="Spring-boot-static-静态文件不能访问原因记录"><a href="#Spring-boot-static-静态文件不能访问原因记录" class="headerlink" title="Spring boot static 静态文件不能访问原因记录"></a>Spring boot static 静态文件不能访问原因记录</h2><p>1、Spring boot 2.7+ 配置文件 继承 extends WebMvcConfigurationSupport 后不能访问</p>
<p>When developing a Spring Boot application, it’s important to be able to serve static content such as images, HTML, CSS, and JavaScript files. However, sometimes these static files may not be accessible even if they are placed in the correct directory.</p>
<p>One common reason for this issue is that Spring Boot serves static content from the <code>/static</code> or <code>/public</code> directory by default. If the static files are located in a different directory, they may not be accessible.</p>
<p>To solve this issue, you can configure the location of the static files by adding the following code to your <code>application.properties</code> file:</p>
<figure class="highlight yaml"><table><tr><td class="code"><pre><span class="line"><span class="attr">spring:</span></span><br><span class="line"> <span class="attr">mvc:</span></span><br><span class="line"> <span class="attr">static-path-pattern:</span> <span class="string">"/static/**"</span></span><br><span class="line"> <span class="attr">web:</span></span><br><span class="line"> <span class="attr">resources:</span></span><br><span class="line"> <span class="attr">static-locations:</span> <span class="string">classpath:/static/,</span> <span class="string">classpath:/public/,</span> <span class="string">file:/home/static/</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>This code tells Spring Boot to look for static files in the <code>/static</code> directory within the classpath.</p>
<p>Another reason why static files may not be accessible is if they are not included in the build process. Make sure that the static files are included in the <code>src/main/resources/static</code> directory and that they are added to the build process.</p>
<p>In conclusion, if you’re having trouble accessing static files in your Spring Boot application, make sure that they are located in the correct directory and that they are included in the build process. Additionally, you can configure the location of the static files in the <code>application.properties</code> file to ensure that they are accessible.</p>
<p>在Spring cloud 环境下 要访问单个服务的静态资源需要 在静态资源路径加路径标识 如: resources/static/cms/assets/***</p>
]]></content>
<categories>
<category>Software</category>
<category>Java</category>
<category>Spring boot</category>
</categories>
</entry>
<entry>
<title>Game</title>
<url>/Game/83199eb2.html</url>
<content><![CDATA[<h1 id="Tetris"><a href="#Tetris" class="headerlink" title="Tetris"></a>Tetris</h1><p><a href="https://hexo.io/">The history of Tetris randomizers</a></p>
<p><a href="https://simon.lc/">Simon Laroche - Developer</a></p>
<p><a href="https://github.com/simonlc/tetr.js">simonlc/tetr.js</a></p>
]]></content>
<categories>
<category>Game</category>
</categories>
</entry>
<entry>
<title>Life game</title>
<url>/Game/Life/62fa798f.html</url>
<content><![CDATA[<h1 id="Life-game"><a href="#Life-game" class="headerlink" title="Life game"></a>Life game</h1><figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="comment">// Conway's Game of Life for HTML5 Canvas</span></span><br><span class="line"><span class="comment">// By Simon Laroche</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">var</span> <span class="variable constant_">FPS</span> = <span class="number">5</span>;</span><br><span class="line"><span class="keyword">var</span> paused = <span class="literal">true</span>;</span><br><span class="line"><span class="keyword">var</span> gameStarted = <span class="literal">false</span>;</span><br><span class="line"><span class="keyword">var</span> gLoop;</span><br><span class="line"><span class="keyword">var</span> generations = <span class="number">0</span>;</span><br><span class="line"><span class="keyword">var</span> population = <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">var</span> lifeForms = [</span><br><span class="line"> [</span><br><span class="line"> [<span class="number">28</span>, <span class="number">28</span>],</span><br><span class="line"> [<span class="number">29</span>, <span class="number">28</span>],</span><br><span class="line"> [<span class="number">30</span>, <span class="number">28</span>],</span><br><span class="line"> [<span class="number">28</span>, <span class="number">29</span>],</span><br><span class="line"> [<span class="number">28</span>, <span class="number">30</span>],</span><br><span class="line"> [<span class="number">30</span>, <span class="number">29</span>],</span><br><span class="line"> [<span class="number">30</span>, <span class="number">30</span>]</span><br><span class="line"> ], <span class="comment">//Arch</span></span><br><span class="line"> [</span><br><span class="line"> [<span class="number">29</span>, <span class="number">28</span>],</span><br><span class="line"> [<span class="number">30</span>, <span class="number">29</span>],</span><br><span class="line"> [<span class="number">30</span>, <span class="number">30</span>],</span><br><span class="line"> [<span class="number">29</span>, <span class="number">30</span>],</span><br><span class="line"> [<span class="number">28</span>, <span class="number">30</span>]</span><br><span class="line"> ], <span class="comment">//Glider</span></span><br><span class="line"> [</span><br><span class="line"> [<span class="number">29</span>, <span class="number">28</span>],</span><br><span class="line"> [<span class="number">30</span>, <span class="number">28</span>],</span><br><span class="line"> [<span class="number">28</span>, <span class="number">29</span>],</span><br><span class="line"> [<span class="number">29</span>, <span class="number">29</span>],</span><br><span class="line"> [<span class="number">29</span>, <span class="number">30</span>]</span><br><span class="line"> ], <span class="comment">//R-pentomino</span></span><br><span class="line"> [</span><br><span class="line"> [<span class="number">32</span>, <span class="number">27</span>],</span><br><span class="line"> [<span class="number">26</span>, <span class="number">28</span>],</span><br><span class="line"> [<span class="number">27</span>, <span class="number">28</span>],</span><br><span class="line"> [<span class="number">27</span>, <span class="number">29</span>],</span><br><span class="line"> [<span class="number">31</span>, <span class="number">29</span>],</span><br><span class="line"> [<span class="number">32</span>, <span class="number">29</span>],</span><br><span class="line"> [<span class="number">33</span>, <span class="number">29</span>]</span><br><span class="line"> ] <span class="comment">//Diehard</span></span><br><span class="line">];</span><br><span class="line"></span><br><span class="line"><span class="keyword">var</span> start = <span class="variable language_">document</span>.<span class="title function_">getElementById</span>(<span class="string">'start'</span>);</span><br><span class="line"><span class="keyword">var</span> reset = <span class="variable language_">document</span>.<span class="title function_">getElementById</span>(<span class="string">'reset'</span>);</span><br><span class="line"><span class="keyword">var</span> random = <span class="variable language_">document</span>.<span class="title function_">getElementById</span>(<span class="string">'random'</span>);</span><br><span class="line"><span class="keyword">var</span> stats = <span class="variable language_">document</span>.<span class="title function_">getElementById</span>(<span class="string">'s'</span>);</span><br><span class="line"><span class="keyword">var</span> wrapper = <span class="variable language_">document</span>.<span class="title function_">getElementById</span>(<span class="string">'w'</span>);</span><br><span class="line"><span class="keyword">var</span> canvas = <span class="variable language_">document</span>.<span class="title function_">getElementById</span>(<span class="string">'c'</span>);</span><br><span class="line"><span class="keyword">var</span> ctx = canvas.<span class="title function_">getContext</span>(<span class="string">'2d'</span>);</span><br><span class="line"></span><br><span class="line">canvas.<span class="property">width</span> = <span class="number">600</span>;</span><br><span class="line">canvas.<span class="property">height</span> = <span class="number">600</span>;</span><br><span class="line">wrapper.<span class="property">style</span>.<span class="property">width</span> = canvas.<span class="property">width</span> + <span class="string">'px'</span>;</span><br><span class="line">stats.<span class="property">style</span>.<span class="property">width</span> = canvas.<span class="property">width</span> - <span class="number">20</span> + <span class="string">'px'</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> <span class="title function_">newGrid</span>(<span class="params"></span>) {</span><br><span class="line"> <span class="keyword">var</span> cells = <span class="keyword">new</span> <span class="title class_">Array</span>(canvas.<span class="property">width</span> / <span class="number">10</span>);</span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i < canvas.<span class="property">width</span> / <span class="number">10</span>; i++) {</span><br><span class="line"> cells[i] = <span class="keyword">new</span> <span class="title class_">Array</span>(canvas.<span class="property">height</span> / <span class="number">10</span>);</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">return</span> cells;</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="comment">//fix</span></span><br><span class="line"><span class="keyword">function</span> <span class="title function_">neighbours</span>(<span class="params">x, y</span>) {</span><br><span class="line"> <span class="keyword">var</span> count = <span class="number">0</span>;</span><br><span class="line"> <span class="keyword">var</span> width = canvas.<span class="property">width</span> / <span class="number">10</span>;</span><br><span class="line"> <span class="keyword">var</span> height = canvas.<span class="property">height</span> / <span class="number">10</span>;</span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">var</span> i = -<span class="number">1</span>; i <= <span class="number">1</span>; i++) {</span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">var</span> j = -<span class="number">1</span>; j <= <span class="number">1</span>; j++) {</span><br><span class="line"> <span class="comment">// skip checking the same cell.</span></span><br><span class="line"> <span class="keyword">if</span> (i == <span class="number">0</span> && j == <span class="number">0</span>) {</span><br><span class="line"> <span class="keyword">continue</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="comment">// get the xy of a neighbor with grid wrap around.</span></span><br><span class="line"> <span class="keyword">var</span> nx = x + i;</span><br><span class="line"> <span class="keyword">if</span> (nx < <span class="number">0</span>) {</span><br><span class="line"> nx += width;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span> (nx >= width) {</span><br><span class="line"> nx -= width;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="keyword">var</span> ny = y + j;</span><br><span class="line"> <span class="keyword">if</span> (ny < <span class="number">0</span>) {</span><br><span class="line"> ny += height;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span> (ny >= height) {</span><br><span class="line"> ny -= height;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="comment">// Check if neighbor is alive.</span></span><br><span class="line"> <span class="keyword">if</span> (cells[nx][ny]) {</span><br><span class="line"> count++;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="comment">// function neighbours(x, y) {</span></span><br><span class="line"><span class="comment">// var count = 0;</span></span><br><span class="line"><span class="comment">// // TODO Test for out of bounds properly.</span></span><br><span class="line"><span class="comment">// if (x > 0 && y > 0 && x < canvas.width / 10 - 1 && y < canvas.width / 10 - 1) {</span></span><br><span class="line"><span class="comment">// if (cells[x - 1][y - 1]) {</span></span><br><span class="line"><span class="comment">// count++;</span></span><br><span class="line"><span class="comment">// }</span></span><br><span class="line"><span class="comment">// if (cells[x - 1][y + 1]) {</span></span><br><span class="line"><span class="comment">// count++;</span></span><br><span class="line"><span class="comment">// }</span></span><br><span class="line"><span class="comment">// if (cells[x + 1][y + 1]) {</span></span><br><span class="line"><span class="comment">// count++;</span></span><br><span class="line"><span class="comment">// }</span></span><br><span class="line"><span class="comment">// if (cells[x + 1][y - 1]) {</span></span><br><span class="line"><span class="comment">// count++;</span></span><br><span class="line"><span class="comment">// }</span></span><br><span class="line"><span class="comment">// if (cells[x][y + 1]) {</span></span><br><span class="line"><span class="comment">// count++;</span></span><br><span class="line"><span class="comment">// }</span></span><br><span class="line"><span class="comment">// if (cells[x][y - 1]) {</span></span><br><span class="line"><span class="comment">// count++;</span></span><br><span class="line"><span class="comment">// }</span></span><br><span class="line"><span class="comment">// if (cells[x - 1][y]) {</span></span><br><span class="line"><span class="comment">// count++;</span></span><br><span class="line"><span class="comment">// }</span></span><br><span class="line"><span class="comment">// if (cells[x + 1][y]) {</span></span><br><span class="line"><span class="comment">// count++;</span></span><br><span class="line"><span class="comment">// }</span></span><br><span class="line"><span class="comment">// }</span></span><br><span class="line"><span class="comment">// return count;</span></span><br><span class="line"><span class="comment">// }</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> <span class="title function_">clear</span>(<span class="params"></span>) {</span><br><span class="line"> ctx.<span class="property">fillStyle</span> = <span class="string">'#eee'</span>;</span><br><span class="line"> ctx.<span class="title function_">beginPath</span>();</span><br><span class="line"> ctx.<span class="title function_">rect</span>(<span class="number">0</span>, <span class="number">0</span>, canvas.<span class="property">width</span>, canvas.<span class="property">height</span>);</span><br><span class="line"> ctx.<span class="title function_">closePath</span>();</span><br><span class="line"> ctx.<span class="title function_">fill</span>();</span><br><span class="line"></span><br><span class="line"> <span class="keyword">function</span> <span class="title function_">grid</span>(<span class="params">increment, color</span>) {</span><br><span class="line"> ctx.<span class="property">fillStyle</span> = color;</span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i < canvas.<span class="property">width</span> + <span class="number">1</span>; i += increment) {</span><br><span class="line"> ctx.<span class="title function_">fillRect</span>(i - <span class="number">1</span>, <span class="number">0</span>, <span class="number">2</span>, canvas.<span class="property">height</span>);</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i < canvas.<span class="property">height</span> + <span class="number">1</span>; i += increment) {</span><br><span class="line"> ctx.<span class="title function_">fillRect</span>(<span class="number">0</span>, i - <span class="number">1</span>, canvas.<span class="property">width</span>, <span class="number">2</span>);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="title function_">grid</span>(<span class="number">10</span>, <span class="string">'#ddd'</span>);</span><br><span class="line"> <span class="title function_">grid</span>(<span class="number">100</span>, <span class="string">'#ccc'</span>);</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> <span class="title function_">draw</span>(<span class="params"></span>) {</span><br><span class="line"> ctx.<span class="property">fillStyle</span> = <span class="string">'#585858'</span>;</span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i < cells.<span class="property">length</span>; i++) {</span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">var</span> j = <span class="number">0</span>; j < cells[i].<span class="property">length</span>; j++) {</span><br><span class="line"> <span class="keyword">if</span> (cells[i][j]) {</span><br><span class="line"> <span class="comment">//ctx.fillRect(i * 10 + 1, j * 10 + 1, 8, 8); // square cells</span></span><br><span class="line"> ctx.<span class="title function_">beginPath</span>();</span><br><span class="line"> ctx.<span class="title function_">arc</span>(i * <span class="number">10</span> + <span class="number">5</span>, j * <span class="number">10</span> + <span class="number">5</span>, <span class="number">4</span>, <span class="number">0</span>, <span class="title class_">Math</span>.<span class="property">PI</span> * <span class="number">2</span>, <span class="literal">true</span>);</span><br><span class="line"> ctx.<span class="title function_">fill</span>();</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> <span class="title function_">update</span>(<span class="params"></span>) {</span><br><span class="line"> population = <span class="number">0</span>;</span><br><span class="line"> cellsCopy = <span class="keyword">new</span> <span class="title class_">Array</span>();</span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">var</span> x = <span class="number">0</span>; x < cells.<span class="property">length</span>; x++) {</span><br><span class="line"> cellsCopy.<span class="title function_">push</span>(cells[x].<span class="title function_">slice</span>());</span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">var</span> y = <span class="number">0</span>; y < cells[x].<span class="property">length</span>; y++) {</span><br><span class="line"> <span class="keyword">if</span> (<span class="title function_">neighbours</span>(x, y) < <span class="number">2</span> || <span class="title function_">neighbours</span>(x, y) > <span class="number">3</span>) {</span><br><span class="line"> cellsCopy[x][y] = <span class="literal">false</span>;</span><br><span class="line"> } <span class="keyword">else</span> <span class="keyword">if</span> (<span class="title function_">neighbours</span>(x, y) == <span class="number">3</span>) {</span><br><span class="line"> cellsCopy[x][y] = <span class="literal">true</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span> (cellsCopy[x][y]) {</span><br><span class="line"> population++;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> cells = cellsCopy;</span><br><span class="line"> generations++</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> <span class="title function_">play</span>(<span class="params"></span>) {</span><br><span class="line"> gameStarted = <span class="literal">true</span>;</span><br><span class="line"> <span class="keyword">if</span> (paused) {</span><br><span class="line"> gLoop = <span class="built_in">setInterval</span>(gameLoop, <span class="number">1000</span> / <span class="variable constant_">FPS</span>);</span><br><span class="line"> paused = <span class="literal">false</span>;</span><br><span class="line"> start.<span class="property">innerHTML</span> = <span class="string">'Pause'</span>;</span><br><span class="line"> } <span class="keyword">else</span> {</span><br><span class="line"> <span class="built_in">clearInterval</span>(gLoop);</span><br><span class="line"> paused = <span class="literal">true</span>;</span><br><span class="line"> start.<span class="property">innerHTML</span> = <span class="string">'Play'</span>;</span><br><span class="line"> }</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> <span class="title function_">resetGame</span>(<span class="params"></span>) {</span><br><span class="line"> paused = <span class="literal">false</span>;</span><br><span class="line"> <span class="title function_">play</span>();</span><br><span class="line"> cells = <span class="title function_">newGrid</span>();</span><br><span class="line"> generations = <span class="number">0</span>;</span><br><span class="line"> population = <span class="number">0</span>;</span><br><span class="line"> <span class="title function_">refresh</span>();</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> <span class="title function_">getLife</span>(<span class="params">index</span>) {</span><br><span class="line"> <span class="keyword">var</span> life = lifeForms[index] || lifeForms[~~(<span class="title class_">Math</span>.<span class="title function_">random</span>() * lifeForms.<span class="property">length</span>)];</span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">var</span> x = <span class="number">0</span>; x < life.<span class="property">length</span>; x++) {</span><br><span class="line"> cells[life[x][<span class="number">0</span>]][life[x][<span class="number">1</span>]] = <span class="literal">true</span>;</span><br><span class="line"> }</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">canvas.<span class="title function_">addEventListener</span>(<span class="string">'click'</span>, <span class="keyword">function</span>(<span class="params">e</span>) {</span><br><span class="line"> <span class="keyword">if</span> (paused) {</span><br><span class="line"> <span class="keyword">var</span> mx = ~~((e.<span class="property">pageX</span> - canvas.<span class="property">offsetLeft</span>) / <span class="number">10</span>);</span><br><span class="line"> <span class="keyword">var</span> my = ~~((e.<span class="property">pageY</span> - canvas.<span class="property">offsetTop</span>) / <span class="number">10</span>);</span><br><span class="line"> <span class="keyword">if</span> (cells[mx][my]) {</span><br><span class="line"> cells[mx][my] = <span class="literal">false</span>;</span><br><span class="line"> } <span class="keyword">else</span> {</span><br><span class="line"> cells[mx][my] = <span class="literal">true</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="title function_">refresh</span>();</span><br><span class="line"> }</span><br><span class="line">}, <span class="literal">false</span>);</span><br><span class="line"></span><br><span class="line">start.<span class="title function_">addEventListener</span>(<span class="string">'click'</span>, play, <span class="literal">false</span>);</span><br><span class="line"></span><br><span class="line">random.<span class="title function_">addEventListener</span>(<span class="string">'click'</span>, <span class="keyword">function</span>(<span class="params"></span>) {</span><br><span class="line"> <span class="title function_">resetGame</span>();</span><br><span class="line"> <span class="title function_">getLife</span>();</span><br><span class="line"> <span class="title function_">refresh</span>();</span><br><span class="line">}, <span class="literal">false</span>);</span><br><span class="line"></span><br><span class="line">reset.<span class="title function_">addEventListener</span>(<span class="string">'click'</span>, resetGame, <span class="literal">false</span>);</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> <span class="title function_">refresh</span>(<span class="params"></span>) {</span><br><span class="line"> <span class="title function_">clear</span>();</span><br><span class="line"> <span class="title function_">draw</span>();</span><br><span class="line"> stats.<span class="property">innerHTML</span> = <span class="string">'Generations: '</span> + generations +</span><br><span class="line"> <span class="string">' Population: '</span> + population;</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> <span class="title function_">gameLoop</span>(<span class="params"></span>) {</span><br><span class="line"> <span class="title function_">refresh</span>();</span><br><span class="line"> <span class="title function_">update</span>();</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">cells = <span class="title function_">newGrid</span>();</span><br><span class="line"><span class="title function_">getLife</span>(<span class="number">0</span>);</span><br><span class="line"><span class="title function_">refresh</span>();</span><br></pre></td></tr></table></figure>
]]></content>
<categories>
<category>Game</category>
<category>Life</category>
</categories>
</entry>
<entry>
<title>Tetris</title>
<url>/Game/Tetris/b91468e2.html</url>
<content><![CDATA[<img data-src="/Game/Tetris/b91468e2/tetris-randomizers.jpg" class="">
<h1 id="The-history-of-Tetris-randomizers"><a href="#The-history-of-Tetris-randomizers" class="headerlink" title="The history of Tetris randomizers"></a>The history of Tetris randomizers</h1><p><a href="https://simon.lc/the-history-of-tetris-randomizers">The history of Tetris randomizers</a></p>
<span id="more"></span>
<p>Nov 26, 2018</p>
<ul>
<li><a href="https://simon.lc/tags/programming">Programming</a></li>
<li><a href="https://simon.lc/tags/tetris">Tetris</a></li>
</ul>
<p>In 1985, Alexey Pajitnov and Vadim Gerasimov released Tetris to the public. This fun and highly addictive game challenged players to fit pieces together that were dealt in a <em>random</em> order.</p>
<p>Since then, over 150 licensed versions of Tetris games have been released. Varying in game modes, rules, and implementations, they all play slightly—or very—differently.</p>
<p>In Tetris, a randomizer is a function which returns a randomly chosen piece. Over the years, the rules of how pieces are chosen has evolved, affecting gameplay and actual randomness.</p>
<p>Several of them have been reversed engineered and documented. I’ve curated a list of ones that I believed to be important and show how the state of Tetris has changed over the years.</p>
<h2 id="Tetris-c-1985"><a href="#Tetris-c-1985" class="headerlink" title="Tetris (c. 1985)"></a><em>Tetris</em> (c. 1985)</h2><p>The first and original version of Tetris released had an unbiased randomizer. No opinion to which piece should come next, just pick one and give it to the player.</p>
<p>With an unbiased randomizer, there are situations where the player receives a sequence of the same piece (called floods) or a sequence omitting a certain piece (called a drought). We’ll see how the designers of Tetris games tried to solve these problems in a little bit.</p>
<p>While an unbiased randomizer offers the greatest pure puzzle challenge to players, it is unstable, and can actually <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.55.8562&rep=rep1&type=pdf">result in an unbeatable sequence (PDF)</a>. This however can not happen in a real game, as computers don’t use true random number generators. Pseudo random number generators try to mimic real randomness, but don’t have the properties required to deal out 70, 000 Z-pieces in a row.</p>
<h3 id="Truly-Pseudo-Random"><a href="#Truly-Pseudo-Random" class="headerlink" title="Truly Pseudo Random"></a>Truly Pseudo Random</h3><figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="keyword">function</span>* <span class="title function_">random</span>(<span class="params"></span>) {</span><br><span class="line"> <span class="keyword">const</span> pieces = [<span class="string">'I'</span>, <span class="string">'J'</span>, <span class="string">'L'</span>, <span class="string">'O'</span>, <span class="string">'S'</span>, <span class="string">'T'</span>, <span class="string">'Z'</span>];</span><br><span class="line"> <span class="keyword">while</span> (<span class="literal">true</span>) {</span><br><span class="line"> <span class="keyword">yield</span> pieces[<span class="title class_">Math</span>.<span class="title function_">floor</span>(<span class="title class_">Math</span>.<span class="title function_">random</span>() * pieces.<span class="property">length</span>)];</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>Puzzle factor: 4/5Flood Prevention: 0/5Drought Prevention: 0/5</p>
<h2 id="Tetris-Nintendo-1989"><a href="#Tetris-Nintendo-1989" class="headerlink" title="Tetris, Nintendo (1989)"></a><em>Tetris</em>, Nintendo (1989)</h2><p>Four years later, the immensely popular <a href="https://en.wikipedia.org/wiki/Nintendo_Entertainment_System">NES</a> version of Tetris was released.</p>
<p>To cut down on piece floods (repeating pieces) a history check was added to the randomizer. This simple check would, </p>
<ol>
<li>choose a piece,</li>
<li>check if the piece was the same as the last,</li>
<li>If it was it would chose a new piece, but only once,</li>
<li>and whatever was the result, was the piece dealt.</li>
</ol>
<p>While the chance of getting the same piece twice in a row was reduced, nothing was stopping the game from dealing out alternating pieces. Another common occurrence in this version is a piece drought of over 30 pieces. While every type of tetromino can have a drought, the I-piece is important for scoring in this game, and a big drought can mean the difference between a score max-out or not.</p>
<h3 id="1-Piece-history-with-1-roll"><a href="#1-Piece-history-with-1-roll" class="headerlink" title="1 Piece history with 1 roll"></a>1 Piece history with 1 roll</h3><figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="keyword">function</span>* <span class="title function_">historyRandomizer</span>(<span class="params"></span>) {</span><br><span class="line"> <span class="keyword">const</span> pieces = [<span class="string">'I'</span>, <span class="string">'J'</span>, <span class="string">'L'</span>, <span class="string">'O'</span>, <span class="string">'S'</span>, <span class="string">'T'</span>, <span class="string">'Z'</span>];</span><br><span class="line"> <span class="keyword">let</span> history;</span><br><span class="line"> <span class="keyword">while</span> (<span class="literal">true</span>) {</span><br><span class="line"> * <span class="comment">// First "roll"* piece = pieces[Math.floor(Math.random() * pieces.length)]; *// Roll is checked against the history*if (piece !== history) { piece = pieces[Math.floor(Math.random() * pieces.length)]; } history = piece; yield piece; }</span></span><br><span class="line"> }</span><br></pre></td></tr></table></figure>
<p>Puzzle factor: 5/5Flood Prevention: 2/5Drought Prevention: 0/5</p>
<h2 id="Tetris-The-Grand-Master-1998"><a href="#Tetris-The-Grand-Master-1998" class="headerlink" title="Tetris: The Grand Master (1998)"></a><em>Tetris: The Grand Master</em> (1998)</h2><p>While <em>NES Tetris</em> improved on pure unbiased randomization, droughts were still common. <em>Tetris: The Grand Master</em>, or <em>TGM</em>, essentially used the same system but with a larger history and more rolls to try and alleviate this.</p>
<p>By increasing these values, not only were floods even less common, but it also helped with droughts. Four pieces in the history meant that you had higher chances of getting a piece that hasn’t been dealt for a while. Despite this, there was still no strict rule preventing droughts, they can still happen, just much less frequently than in <em>NES Tetris</em>.</p>
<h3 id="4-Piece-history-with-4-rolls"><a href="#4-Piece-history-with-4-rolls" class="headerlink" title="4 Piece history with 4 rolls"></a>4 Piece history with 4 rolls</h3><figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="keyword">function</span>* <span class="title function_">historyRandomizer</span>(<span class="params"></span>) {</span><br><span class="line"> <span class="keyword">const</span> pieces = [<span class="string">'I'</span>, <span class="string">'J'</span>, <span class="string">'L'</span>, <span class="string">'O'</span>, <span class="string">'S'</span>, <span class="string">'T'</span>, <span class="string">'Z'</span>];* <span class="comment">// First piece special conditions*let piece = ['I', 'J', 'L', 'T'][Math.floor(Math.random() * 4)]; yield piece; let history = ['S', 'Z', 'S', piece]; while (true) { for (let roll = 0; roll < 4; ++roll) { piece = pieces[Math.floor(Math.random() * 7)]; if (history.includes(piece) === false) break; } history.shift(); history.push(piece); yield piece; }</span></span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>Puzzle factor: 4/5Flood Prevention: 4/5Drought Prevention: 2/5</p>
<h2 id="Tetris-Worlds-and-Onwards-2001"><a href="#Tetris-Worlds-and-Onwards-2001" class="headerlink" title="Tetris Worlds and Onwards (2001)"></a><em>Tetris Worlds</em> and Onwards (2001)</h2><img data-src="/Game/Tetris/b91468e2/tetris-bag.jpg" class="" title="tetris-bag">
<p><em>Tetris Worlds</em> introduced the Random Generator to the masses. Now the official randomizer, most official titles made after this date use it.</p>
<p>History based randomizers helped eliminate floods (or at least diminish them), but could not stop droughts. Given the right circumstances, a deadly piece sequence is still possible.</p>
<p>The Random Generator solves these problems by using a new system called bags. In a bag system, a list of pieces are put into a bag, and piece by piece are randomly picked out until it’s empty. Once the bag is empty, the pieces go back in and the process is repeated. The Random Generator has a 7-bag… or a bag filled with one of each of the 7 tetrominoes. Other types of bags are possible, such as a 14-bag, which includes two of each tetromino.</p>
<p>Having no history from bag to bag allows floods of 2 and snake sequences of 4 (ZSZS, ZSSZ, etc.) to happen at the seams of each bag. So in some ways it’s a step backwards from the traditional <em>NES Tetris</em>.</p>
<p>The 7-bag has a consistent piece output, making it more predictable. It’s easy to know where in a bag you are, and when a piece you need might come. Because of how predictable this random generator is, it’s actually possible to <a href="https://harddrop.com/wiki/Playing_forever">play forever</a>. Overall it’s a silly system that makes you wonder how it ever became the official randomizer.</p>
<h3 id="The-7-bag"><a href="#The-7-bag" class="headerlink" title="The 7-bag"></a>The 7-bag</h3><figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="keyword">function</span>* <span class="title function_">randomGenerator</span>(<span class="params"></span>) {</span><br><span class="line"> <span class="keyword">let</span> bag = [];</span><br><span class="line"> <span class="keyword">while</span> (<span class="literal">true</span>) {</span><br><span class="line"> <span class="keyword">if</span> (bag.<span class="property">length</span> === <span class="number">0</span>) {</span><br><span class="line"> bag = [<span class="string">'I'</span>, <span class="string">'J'</span>, <span class="string">'L'</span>, <span class="string">'O'</span>, <span class="string">'S'</span>, <span class="string">'T'</span>, <span class="string">'Z'</span>];</span><br><span class="line"> bag = <span class="title function_">shuffle</span>(bag);</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">yield</span> bag.<span class="title function_">pop</span>();</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>Puzzle factor: 3/5Flood Prevention: 3/5Drought Prevention: 4/5</p>
<h2 id="Tetris-The-Grand-Master-3-Terror-Instinct-2005"><a href="#Tetris-The-Grand-Master-3-Terror-Instinct-2005" class="headerlink" title="Tetris: The Grand Master 3 - Terror-Instinct (2005)"></a><em>Tetris: The Grand Master 3 - Terror-Instinct</em> (2005)</h2><p>TGM3 really advances the idea of random generation. It’s a unique system that doesn’t appear in any other release.</p>
<p>Instead of a bag or history, TGM3 uses a pool of pieces. Starting with 5 of each tetromino, for a total of 35 pieces. When a piece is dealt, instead of removing it from the pool, it is replaced with the most droughted piece. Eventually the pool will fill up more and more with this piece until picked. This solves the issues with bag systems, as well as history systems; the best of both worlds.</p>
<h3 id="35-Pool-with-6-rolls"><a href="#35-Pool-with-6-rolls" class="headerlink" title="35 Pool with 6 rolls"></a>35 Pool with 6 rolls</h3><figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="keyword">function</span>* <span class="title function_">tgm3Randomizer</span>(<span class="params"></span>) {</span><br><span class="line"> <span class="keyword">let</span> pieces = [<span class="string">'I'</span>, <span class="string">'J'</span>, <span class="string">'L'</span>, <span class="string">'O'</span>, <span class="string">'S'</span>, <span class="string">'T'</span>, <span class="string">'Z'</span>];</span><br><span class="line"> <span class="keyword">let</span> order = [];* <span class="comment">// Create 35 pool.*let pool = pieces.concat(pieces, pieces, pieces, pieces); *// First piece special conditions*const firstPiece = ['I', 'J', 'L', 'T'][Math.floor(Math.random() * 4)]; yield firstPiece; let history = ['S', 'Z', 'S', firstPiece]; while (true) { let roll; let i; let piece; *// Roll For piece*for (roll = 0; roll < 6; ++roll) { i = Math.floor(Math.random() * 35); piece = pool[i]; if (history.includes(piece) === false || roll === 5) { break; } if (order.length) pool[i] = order[0]; } *// Update piece order*if (order.includes(piece)) { order.splice(order.indexOf(piece), 1); } order.push(piece); pool[i] = order[0]; *// Update history* history.shift(); history[3] = piece; yield piece; }</span></span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>Puzzle factor: 4/5Flood Prevention: 4/5Drought Prevention: 4/5</p>
<h2 id="Onwards"><a href="#Onwards" class="headerlink" title="Onwards"></a>Onwards</h2><p>It’s hard to pin point it, but TGM3’s randomizer does feel more predictable, and less challenging. The clumsy 7-bag is unnatural feeling, but allows for many building strategies to be consistently viable. An unfriendly randomizer like in NES Tetris can ruin your game, or more likely, your mood to play.</p>
<p>Can we better these systems by making them more random feeling, and putting hard limits on droughts and floods? Or do these hard limits just make the game more predictable?</p>
]]></content>
<categories>
<category>Game</category>
<category>Tetris</category>
</categories>
</entry>
<entry>
<title>AI</title>
<url>/AI/a7bb958f.html</url>
<content><![CDATA[<p>Welcome to <a href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo new <span class="string">"My New Post"</span></span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
]]></content>
<categories>
<category>AI</category>
</categories>
</entry>
<entry>
<title>Doc</title>
<url>/Doc/be0cbb84.html</url>
<content><![CDATA[<p>Welcome to <a href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-1"><a href="#Generate-static-files-1" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-1"><a href="#Deploy-to-remote-sites-1" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-1"><a href="#Run-server-1" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-2"><a href="#Generate-static-files-2" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-2"><a href="#Deploy-to-remote-sites-2" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-2"><a href="#Run-server-2" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-3"><a href="#Generate-static-files-3" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-3"><a href="#Deploy-to-remote-sites-3" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-3"><a href="#Run-server-3" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-4"><a href="#Generate-static-files-4" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-4"><a href="#Deploy-to-remote-sites-4" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-4"><a href="#Run-server-4" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-5"><a href="#Generate-static-files-5" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-5"><a href="#Deploy-to-remote-sites-5" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
]]></content>
<categories>
<category>Doc</category>
</categories>
</entry>
<entry>
<title>hexo中如何支持公式 mathjax</title>
<url>/Doc/Hexo/6aa77778.html</url>
<content><![CDATA[<p>Welcome to <a href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2>]]></content>
<categories>
<category>Doc</category>
<category>Hexo</category>
</categories>
</entry>
<entry>
<title>Snake</title>
<url>/Game/Snake/90ac449a.html</url>
<content><![CDATA[<img data-src="/Game/Snake/90ac449a/snake.jpg" class="">
<h1 id="Snake"><a href="#Snake" class="headerlink" title="Snake"></a>Snake</h1><figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="keyword">var</span> <span class="variable constant_">FPS</span> = <span class="number">10</span>;</span><br><span class="line"><span class="keyword">var</span> gLoop;</span><br><span class="line"><span class="keyword">var</span> lastX;</span><br><span class="line"><span class="keyword">var</span> lastY;</span><br><span class="line"></span><br><span class="line"><span class="keyword">var</span> canvas = <span class="variable language_">document</span>.<span class="title function_">getElementById</span>(<span class="string">'c'</span>);</span><br><span class="line"><span class="keyword">var</span> ctx = canvas.<span class="title function_">getContext</span>(<span class="string">'2d'</span>);</span><br><span class="line"><span class="keyword">var</span> info = <span class="variable language_">document</span>.<span class="title function_">getElementById</span>(<span class="string">'i'</span>);</span><br><span class="line"><span class="keyword">var</span> wrapper = <span class="variable language_">document</span>.<span class="title function_">getElementById</span>(<span class="string">'w'</span>);</span><br><span class="line"><span class="keyword">var</span> classic = <span class="variable language_">document</span>.<span class="title function_">getElementById</span>(<span class="string">'classic'</span>);</span><br><span class="line"></span><br><span class="line">canvas.<span class="property">width</span> = <span class="number">500</span>;</span><br><span class="line">canvas.<span class="property">height</span> = <span class="number">300</span>;</span><br><span class="line">classic.<span class="title function_">addEventListener</span>(<span class="string">'click'</span>, init, <span class="literal">false</span>);</span><br><span class="line">wrapper.<span class="property">style</span>.<span class="property">width</span> = canvas.<span class="property">width</span> + <span class="string">'px'</span>;</span><br><span class="line">info.<span class="property">style</span>.<span class="property">width</span> = canvas.<span class="property">width</span> + <span class="string">'px'</span>;</span><br><span class="line"></span><br><span class="line"><span class="variable language_">document</span>.<span class="property">onkeydown</span> = <span class="keyword">function</span>(<span class="params">e</span>) {</span><br><span class="line"> snake.<span class="title function_">keyDown</span>(e);</span><br><span class="line">};</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> <span class="title function_">getRandomInt</span>(<span class="params">min, max</span>) {</span><br><span class="line"> <span class="keyword">return</span> ~~(<span class="title class_">Math</span>.<span class="title function_">random</span>() * (max - min + <span class="number">1</span>)) + min;</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> <span class="title function_">drawBox</span>(<span class="params">x, y, color</span>) {</span><br><span class="line"> ctx.<span class="property">fillStyle</span> = color;</span><br><span class="line"> ctx.<span class="title function_">fillRect</span>(x + <span class="number">1</span>, y + <span class="number">1</span>, <span class="number">8</span>, <span class="number">8</span>);</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> <span class="title function_">clear</span>(<span class="params"></span>) {</span><br><span class="line"> ctx.<span class="property">fillStyle</span> = <span class="string">'#eee'</span>;</span><br><span class="line"> ctx.<span class="title function_">beginPath</span>();</span><br><span class="line"> ctx.<span class="title function_">rect</span>(<span class="number">0</span>, <span class="number">0</span>, canvas.<span class="property">width</span>, canvas.<span class="property">height</span>);</span><br><span class="line"> ctx.<span class="title function_">closePath</span>();</span><br><span class="line"> ctx.<span class="title function_">fill</span>();</span><br><span class="line"></span><br><span class="line"> <span class="keyword">function</span> <span class="title function_">grid</span>(<span class="params">increment, color</span>) {</span><br><span class="line"> ctx.<span class="property">fillStyle</span> = color;</span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i < canvas.<span class="property">width</span> + <span class="number">1</span>; i += increment) {</span><br><span class="line"> ctx.<span class="title function_">fillRect</span>(i - <span class="number">1</span>, <span class="number">0</span>, <span class="number">2</span>, canvas.<span class="property">height</span>);</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i < canvas.<span class="property">height</span> + <span class="number">1</span>; i += increment) {</span><br><span class="line"> ctx.<span class="title function_">fillRect</span>(<span class="number">0</span>, i - <span class="number">1</span>, canvas.<span class="property">width</span>, <span class="number">2</span>);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="title function_">grid</span>(<span class="number">10</span>, <span class="string">'#ddd'</span>);</span><br><span class="line"> <span class="title function_">grid</span>(<span class="number">100</span>, <span class="string">'#ccc'</span>);</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="keyword">var</span> food = <span class="keyword">new</span> <span class="keyword">function</span>(<span class="params"></span>) {</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">x</span> = <span class="number">10</span> * <span class="title function_">getRandomInt</span>(<span class="number">0</span>, (canvas.<span class="property">width</span> - <span class="number">10</span>) / <span class="number">10</span>);</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">y</span> = <span class="number">10</span> * <span class="title function_">getRandomInt</span>(<span class="number">0</span>, (canvas.<span class="property">height</span> - <span class="number">10</span>) / <span class="number">10</span>);</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">color</span> = <span class="string">'#87af00'</span>;</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">draw</span> = <span class="keyword">function</span>(<span class="params"></span>) {</span><br><span class="line"> <span class="title function_">drawBox</span>(<span class="variable language_">this</span>.<span class="property">x</span>, <span class="variable language_">this</span>.<span class="property">y</span>, <span class="variable language_">this</span>.<span class="property">color</span>);</span><br><span class="line"> };</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">eaten</span> = <span class="keyword">function</span>(<span class="params"></span>) {</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">x</span> = <span class="number">10</span> * <span class="title function_">getRandomInt</span>(<span class="number">0</span>, (canvas.<span class="property">width</span> - <span class="number">10</span>) / <span class="number">10</span>);</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">y</span> = <span class="number">10</span> * <span class="title function_">getRandomInt</span>(<span class="number">0</span>, (canvas.<span class="property">height</span> - <span class="number">10</span>) / <span class="number">10</span>);</span><br><span class="line"> };</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="keyword">var</span> snake = <span class="keyword">new</span> <span class="keyword">function</span>(<span class="params"></span>) {</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">x</span> = canvas.<span class="property">width</span> / <span class="number">2</span>;</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">y</span> = canvas.<span class="property">height</span> / <span class="number">2</span>;</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">direction</span> = <span class="string">''</span>;</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">color</span> = <span class="string">'#268bd2'</span>;</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">tail</span> = [];</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">dead</span> = <span class="literal">true</span>;</span><br><span class="line"></span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">eat</span> = <span class="keyword">function</span>(<span class="params"></span>) {</span><br><span class="line"> food.<span class="title function_">eaten</span>();</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">tail</span>.<span class="title function_">unshift</span>([<span class="variable language_">this</span>.<span class="property">x</span>, <span class="variable language_">this</span>.<span class="property">y</span>]);</span><br><span class="line"> };</span><br><span class="line"></span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">keyDown</span> = <span class="keyword">function</span>(<span class="params">e</span>) {</span><br><span class="line"> <span class="keyword">if</span> (<span class="variable language_">this</span>.<span class="property">dead</span>) {</span><br><span class="line"> <span class="keyword">return</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">switch</span> (e.<span class="property">keyCode</span>) {</span><br><span class="line"> <span class="keyword">case</span> <span class="number">38</span>: <span class="comment">// Up</span></span><br><span class="line"> e.<span class="title function_">preventDefault</span>();</span><br><span class="line"> <span class="keyword">if</span> (<span class="variable language_">this</span>.<span class="property">direction</span> != <span class="string">'down'</span>) {</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">direction</span> = <span class="string">'up'</span></span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">break</span></span><br><span class="line"> <span class="keyword">case</span> <span class="number">40</span>: <span class="comment">// Down</span></span><br><span class="line"> e.<span class="title function_">preventDefault</span>();</span><br><span class="line"> <span class="keyword">if</span> (<span class="variable language_">this</span>.<span class="property">direction</span> != <span class="string">'up'</span>) {</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">direction</span> = <span class="string">'down'</span></span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">break</span></span><br><span class="line"> <span class="keyword">case</span> <span class="number">37</span>: <span class="comment">// Left</span></span><br><span class="line"> e.<span class="title function_">preventDefault</span>();</span><br><span class="line"> <span class="keyword">if</span> (<span class="variable language_">this</span>.<span class="property">direction</span> != <span class="string">'right'</span>) {</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">direction</span> = <span class="string">'left'</span></span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">break</span></span><br><span class="line"> <span class="keyword">case</span> <span class="number">39</span>: <span class="comment">// Right</span></span><br><span class="line"> e.<span class="title function_">preventDefault</span>();</span><br><span class="line"> <span class="keyword">if</span> (<span class="variable language_">this</span>.<span class="property">direction</span> != <span class="string">'left'</span>) {</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">direction</span> = <span class="string">'right'</span></span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">break</span></span><br><span class="line"> }</span><br><span class="line"> };</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">update</span> = <span class="keyword">function</span>(<span class="params"></span>) {</span><br><span class="line"> <span class="keyword">if</span> (!<span class="variable language_">this</span>.<span class="property">dead</span>) {</span><br><span class="line"> <span class="keyword">if</span> (<span class="variable language_">this</span>.<span class="property">direction</span> == <span class="string">'up'</span>) {</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">y</span> -= <span class="number">10</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span> (<span class="variable language_">this</span>.<span class="property">direction</span> == <span class="string">'down'</span>) {</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">y</span> += <span class="number">10</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span> (<span class="variable language_">this</span>.<span class="property">direction</span> == <span class="string">'left'</span>) {</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">x</span> -= <span class="number">10</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span> (<span class="variable language_">this</span>.<span class="property">direction</span> == <span class="string">'right'</span>) {</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">x</span> += <span class="number">10</span>;</span><br><span class="line"> }</span><br><span class="line"> } <span class="keyword">else</span> {</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">direction</span> = <span class="string">''</span>;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="comment">// Colision detection</span></span><br><span class="line"> <span class="keyword">if</span> ((<span class="variable language_">this</span>.<span class="property">x</span> == food.<span class="property">x</span>) && (<span class="variable language_">this</span>.<span class="property">y</span> == food.<span class="property">y</span>)) {</span><br><span class="line"> <span class="variable language_">this</span>.<span class="title function_">eat</span>();</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">1</span>; i < <span class="variable language_">this</span>.<span class="property">tail</span>.<span class="property">length</span>; i++) {</span><br><span class="line"> <span class="keyword">if</span> ((<span class="variable language_">this</span>.<span class="property">x</span> == <span class="variable language_">this</span>.<span class="property">tail</span>[i][<span class="number">0</span>]) && (<span class="variable language_">this</span>.<span class="property">y</span> == <span class="variable language_">this</span>.<span class="property">tail</span>[i][<span class="number">1</span>])) {</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">dead</span> = <span class="literal">true</span>;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span> (<span class="variable language_">this</span>.<span class="property">x</span> > canvas.<span class="property">width</span> - <span class="number">10</span> ||</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">y</span> > canvas.<span class="property">height</span> - <span class="number">10</span> ||</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">x</span> < <span class="number">0</span> ||</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">y</span> < <span class="number">0</span>) {</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">dead</span> = <span class="literal">true</span>;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> };</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">draw</span> = <span class="keyword">function</span>(<span class="params"></span>) {</span><br><span class="line"> <span class="title function_">drawBox</span>(<span class="variable language_">this</span>.<span class="property">x</span>, <span class="variable language_">this</span>.<span class="property">y</span>, <span class="variable language_">this</span>.<span class="property">color</span>);</span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">var</span> i = <span class="number">0</span>; i < <span class="variable language_">this</span>.<span class="property">tail</span>.<span class="property">length</span>; i++) {</span><br><span class="line"> <span class="title function_">drawBox</span>(<span class="variable language_">this</span>.<span class="property">tail</span>[i][<span class="number">0</span>], <span class="variable language_">this</span>.<span class="property">tail</span>[i][<span class="number">1</span>], <span class="variable language_">this</span>.<span class="property">color</span>);</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="keyword">if</span> (!<span class="variable language_">this</span>.<span class="property">dead</span>) {</span><br><span class="line"> lastX = <span class="variable language_">this</span>.<span class="property">x</span>;</span><br><span class="line"> lastY = <span class="variable language_">this</span>.<span class="property">y</span>;</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">tail</span>.<span class="title function_">unshift</span>([lastX, lastY]);</span><br><span class="line"> <span class="variable language_">this</span>.<span class="property">tail</span>.<span class="title function_">pop</span>();</span><br><span class="line"> }</span><br><span class="line"> };</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> <span class="title function_">gameLoop</span>(<span class="params"></span>) {</span><br><span class="line"> <span class="comment">// Update</span></span><br><span class="line"> snake.<span class="title function_">update</span>();</span><br><span class="line"></span><br><span class="line"> <span class="comment">// Draw</span></span><br><span class="line"> <span class="title function_">clear</span>();</span><br><span class="line"> food.<span class="title function_">draw</span>();</span><br><span class="line"> snake.<span class="title function_">draw</span>();</span><br><span class="line"></span><br><span class="line"> <span class="comment">// Loop</span></span><br><span class="line"> gLoop = <span class="built_in">setTimeout</span>(gameLoop, <span class="number">1000</span> / <span class="variable constant_">FPS</span>);</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line"><span class="keyword">function</span> <span class="title function_">init</span>(<span class="params"></span>) {</span><br><span class="line"> info.<span class="property">style</span>.<span class="property">display</span> = <span class="string">'none'</span>;</span><br><span class="line"> snake.<span class="property">dead</span> = <span class="literal">false</span>;</span><br><span class="line"> <span class="title function_">gameLoop</span>();</span><br><span class="line">}</span><br><span class="line"><span class="title function_">clear</span>();</span><br></pre></td></tr></table></figure>
]]></content>
<categories>
<category>Game</category>
<category>Snake</category>
</categories>
<tags>
<tag>Snake</tag>
</tags>
</entry>
<entry>
<title>Python</title>
<url>/Software/Python/a378bd8e.html</url>
<content><![CDATA[<p>Welcome to <a href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo new <span class="string">"My New Post"</span></span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-1"><a href="#Run-server-1" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-1"><a href="#Generate-static-files-1" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-1"><a href="#Deploy-to-remote-sites-1" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-2"><a href="#Run-server-2" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-2"><a href="#Generate-static-files-2" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-2"><a href="#Deploy-to-remote-sites-2" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-3"><a href="#Run-server-3" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-3"><a href="#Generate-static-files-3" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-3"><a href="#Deploy-to-remote-sites-3" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-4"><a href="#Run-server-4" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-4"><a href="#Generate-static-files-4" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-4"><a href="#Deploy-to-remote-sites-4" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-5"><a href="#Run-server-5" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-5"><a href="#Generate-static-files-5" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-5"><a href="#Deploy-to-remote-sites-5" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server-6"><a href="#Run-server-6" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files-6"><a href="#Generate-static-files-6" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites-6"><a href="#Deploy-to-remote-sites-6" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
]]></content>
<categories>
<category>Software</category>
<category>Python</category>
</categories>
<tags>
<tag>python</tag>
</tags>
</entry>
<entry>
<title>Algorithm</title>
<url>/Software/Algorithm/17f44e1a.html</url>
<content><![CDATA[<p>Welcome to <a href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo new <span class="string">"My New Post"</span></span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
]]></content>
<categories>
<category>Software</category>
<category>Algorithm</category>
</categories>
<tags>
<tag>Algorithm</tag>
</tags>
</entry>
<entry>
<title>Android</title>
<url>/Software/Android/5d018fb1.html</url>
<content><![CDATA[<p>Welcome to <a href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo new <span class="string">"My New Post"</span></span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
]]></content>
<categories>
<category>Software</category>
<category>Android</category>
</categories>
<tags>
<tag>Android</tag>
</tags>
</entry>
<entry>
<title>SQL</title>
<url>/Software/DataBase/SQL/4d712855.html</url>
<content><![CDATA[<p>Welcome to <a href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ hexo new <span class="string">"My New Post"</span></span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p>
]]></content>
<categories>
<category>Software</category>
<category>DataBase</category>
<category>SQL</category>
</categories>
<tags>
<tag>Android</tag>
</tags>
</entry>
</search>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。