The core of `bin/gen-other-html.sh` code that converts entry non-README.md into HTML has been moved into a new tool: `bin/othermd2html.sh`. The `bin/othermd2html.sh` tool will be useful to the `bin/cvt-submission.sh` tool that is under development. Added info about `bin/othermd2html.sh` to `bin/README.md`. Changed `bin/gen-other-html.sh` VERSION from "1.4.1 2024-08-18" to "1.5 2024-08-27". HTML produced by `bin/gen-other-html.sh` now uses a "jump to" mid-bar test now shows the `YYYY/dir/index.html` link text (with `YYYY/dir/` added). Performed `make gen_other_html` to accomplish the above and to test under macOS. Performed `make gen_top_html` to accomplish the above and to test under macOS.
681 lines
27 KiB
HTML
681 lines
27 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||
<!-- START: two lines up starts content from: inc/top.default.html -->
|
||
|
||
<!-- END: this line ends content from: inc/top.default.html -->
|
||
<!-- START: this line starts content from: inc/head.default.html -->
|
||
|
||
<head>
|
||
<link rel="stylesheet" href="../../ioccc.css">
|
||
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@100..900&display=swap" rel="stylesheet">
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
||
<title>The International Obfuscated C Code Contest</title>
|
||
<link rel="icon" type="image/x-icon" href="../../favicon.ico">
|
||
<meta name="description" content="bugs.md for 2020/ferguson1">
|
||
<meta name="keywords" content="IOCCC, 2020/ferguson1, bugs.md">
|
||
</head>
|
||
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
|
||
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
|
||
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
|
||
<!-- END: this line ends content from: inc/head.default.html -->
|
||
|
||
<!-- -->
|
||
<!-- This web page was formed via the tool: bin/gen-other-html.sh -->
|
||
<!-- The content of main section of this web page came from: 2020/ferguson1/bugs.md -->
|
||
<!-- -->
|
||
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 2020/ferguson1/bugs.md !!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 2020/ferguson1/bugs.md !!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 2020/ferguson1/bugs.md !!! -->
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
|
||
<!-- Markdown content was converted into HTML via the tool: bin/md2html.sh -->
|
||
|
||
<!-- START: this line starts content from: inc/body.default.html -->
|
||
|
||
<body>
|
||
|
||
<!-- END: this line ends content from: inc/body.default.html -->
|
||
<!-- START: this line starts content from: inc/topbar.default.html -->
|
||
|
||
<div class="theader">
|
||
<nav class="topbar">
|
||
<div class="container">
|
||
<div class="logo">
|
||
<a href="../../index.html" class="logo-link">
|
||
IOCCC
|
||
</a>
|
||
</div>
|
||
|
||
<div class="topbar-items">
|
||
<div class="item">
|
||
<span class="item-header">
|
||
Entries
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
<div class="outfit-font">
|
||
<a href="../../years.html" class="sub-item-link">
|
||
Winning Entries
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../authors.html" class="sub-item-link">
|
||
Winning Authors
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../location.html" class="sub-item-link">
|
||
Location of winning authors
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../bugs.html" class="sub-item-link">
|
||
Bugs and (mis)features
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<span class="item-header">
|
||
Status
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
<div class="outfit-font">
|
||
<a href="../../news.html" class="sub-item-link">
|
||
IOCCC News
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../status.html" class="sub-item-link">
|
||
Contest status
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../next/index.html" class="sub-item-link">
|
||
Rules and Guidelines
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<span class="item-header">
|
||
FAQ
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html" class="sub-item-link">
|
||
FAQ
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#submit" class="sub-item-link">
|
||
How to enter the IOCCC
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#fix_an_entry" class="sub-item-link">
|
||
Fixing IOCCC entries
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#fix_web_site" class="sub-item-link">
|
||
Fixing the website
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#fix_author" class="sub-item-link">
|
||
Updating author info
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<span class="item-header">
|
||
About
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
<div class="outfit-font">
|
||
<a href="../../index.html" class="sub-item-link">
|
||
IOCCC Home
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../judges.html" class="sub-item-link">
|
||
The IOCCC Judges
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../contact.html" class="sub-item-link">
|
||
Contacting the IOCCC
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../SECURITY.html" class="sub-item-link">
|
||
IOCCC Security Policy
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../thanks-for-help.html" class="sub-item-link">
|
||
Thanks for the help
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../markdown.html" class="sub-item-link">
|
||
IOCCC markdown guidelines
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</nav>
|
||
|
||
<div class="header-mobile-menu">
|
||
<noscript>
|
||
<a href="../../nojs-menu.html" class="topbar-js-label">
|
||
Please Enable JavaScript
|
||
</a>
|
||
</noscript>
|
||
|
||
<button id="header-open-menu-button" class="topbar-mobile-menu">
|
||
<img
|
||
src="../../png/hamburger-icon-open.png"
|
||
alt="hamburger style menu icon - open state"
|
||
width=48
|
||
height=48>
|
||
</button>
|
||
|
||
<button id="header-close-menu-button" class="hide-content">
|
||
<img
|
||
src="../../png/hamburger-icon-closed.png"
|
||
alt="hamburger style menu icon - closed state"
|
||
width=48
|
||
height=48>
|
||
</button>
|
||
|
||
<div id="mobile-menu-panel" class="hide-content">
|
||
<div class="mobile-menu-container">
|
||
|
||
<div class="mobile-menu-wrapper">
|
||
<div class="mobile-menu-item">
|
||
Entries
|
||
</div>
|
||
<div class="mobile-submenu-wrapper">
|
||
|
||
<a class="mobile-submenu-item" href="../../years.html">
|
||
Winning Entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../authors.html">
|
||
Authors of winning IOCCC entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../location.html">
|
||
Location of authors
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../bugs.html">
|
||
Bugs and (mis)features
|
||
</a>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mobile-menu-wrapper">
|
||
|
||
<div class="mobile-menu-item">
|
||
Status
|
||
</div>
|
||
<div class="mobile-submenu-wrapper">
|
||
|
||
<a class="mobile-submenu-item" href="../../status.html">
|
||
Contest status
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../next/index.html">
|
||
Rules and Guidelines
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../news.html">
|
||
IOCCC News
|
||
</a>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mobile-menu-wrapper">
|
||
<div class="mobile-menu-item">
|
||
FAQ
|
||
</div>
|
||
<div class="mobile-submenu-wrapper">
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html">
|
||
Frequently Asked Questions
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#submit">
|
||
How to enter the IOCCC
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#fix_an_entry">
|
||
Fixing IOCCC entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#fix_web_site">
|
||
Fixing the website
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#fix_author">
|
||
Fixing author info
|
||
</a>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mobile-menu-wrapper">
|
||
<div class="mobile-menu-item">
|
||
About
|
||
</div>
|
||
<div class="mobile-submenu-wrapper">
|
||
|
||
<a class="mobile-submenu-item" href="../../index.html">
|
||
IOCCC Home
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../judges.html">
|
||
The IOCCC Judges
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../contact.html">
|
||
Contacting the IOCCC
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../thanks-for-help.html">
|
||
Thanks for the help
|
||
</a>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<script>
|
||
var headerOpenMenuButton = document.getElementById("header-open-menu-button");
|
||
var headerCloseMenuButton = document.getElementById("header-close-menu-button");
|
||
var mobileMenuPanel = document.getElementById("mobile-menu-panel");
|
||
|
||
headerOpenMenuButton.addEventListener("click", () => {
|
||
headerOpenMenuButton.classList.remove("topbar-mobile-menu");
|
||
headerOpenMenuButton.classList.add("hide-content");
|
||
|
||
headerCloseMenuButton.classList.remove("hide-content");
|
||
headerCloseMenuButton.classList.add("topbar-mobile-menu");
|
||
|
||
mobileMenuPanel.classList.remove("hide-content");
|
||
mobileMenuPanel.classList.add("topbar-mobile-panel");
|
||
});
|
||
|
||
headerCloseMenuButton.addEventListener("click", () => {
|
||
headerCloseMenuButton.classList.remove("topbar-mobile-menu");
|
||
headerCloseMenuButton.classList.add("hide-content");
|
||
|
||
mobileMenuPanel.classList.add("hide-content");
|
||
mobileMenuPanel.classList.remove("topbar-mobile-panel");
|
||
|
||
headerOpenMenuButton.classList.add("topbar-mobile-menu");
|
||
headerOpenMenuButton.classList.remove("hide-content");
|
||
});
|
||
</script>
|
||
|
||
<!-- END: this line ends content from: inc/topbar.default.html -->
|
||
<!-- START: this line starts content from: inc/header.default.html -->
|
||
|
||
<div class="header">
|
||
<a href="../../2011/zucker/index.html">
|
||
<img src="../../png/ioccc.png"
|
||
alt="IOCCC image by Matt Zucker"
|
||
width=300
|
||
height=110>
|
||
</a>
|
||
<h1>The International Obfuscated C Code Contest</h1>
|
||
<h2>bugs.html for 2020/ferguson1</h2>
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/header.default.html -->
|
||
<!-- START: this line starts content from: inc/navbar.up2index.html -->
|
||
|
||
<div class="navbar">
|
||
<a class="Left" href="index.html">↑ jump to 2020/ferguson1/index.html ↑</a>
|
||
<a class="Right" href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2020%2Fferguson1%2Fbugs.html">✓</a>
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/navbar.up2index.html -->
|
||
<!-- START: this line starts content from: inc/before-content.default.html -->
|
||
|
||
<div class="content" id="content">
|
||
|
||
<!-- END: this line ends content from: inc/before-content.default.html -->
|
||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||
|
||
<!-- BEFORE: 1st line of markdown file: 2020/ferguson1/bugs.md -->
|
||
<h1 id="current-bugs-and-things-that-look-like-bugs-but-are-not">Current bugs and things that look like bugs but are not</h1>
|
||
<p>.. as of 12 September 2020.</p>
|
||
<div id="toc">
|
||
<ul>
|
||
<li><a href="#builtin-test-unit">Built-in test unit for some features!</a></li>
|
||
<li><a href="#stillsnake">The snake doesn’t seem to be moving</a></li>
|
||
<li><a href="#getch">getch() also accepts input from some input hardware other than keyboards</a></li>
|
||
<li><a href="#size">SIZE=0 is the same as SIZE=1 and other oddities</a></li>
|
||
<li><a href="#bitetail">‘I was a few places behind my tail and I ran into it!’</a></li>
|
||
<li><a href="#middleofsnake">With negative growth the snake drops from the middle of the body</a></li>
|
||
<li><a href="#buginsnake">It looks like the bug is in the snake</a></li>
|
||
<li><a href="#bugplacement">On the safety of the bug placement loop</a></li>
|
||
</ul>
|
||
</div>
|
||
<div id="builtin-test-unit">
|
||
<h1 id="built-in-test-unit-for-some-features"><a href="#toc">Built-in test unit for some features!</a></h1>
|
||
</div>
|
||
<p>Fun fact: There’s something of a built-in test unit for some features; much
|
||
like some of the other features this was not intentionally designed but is
|
||
simply a fun consequence of the features I did implement.</p>
|
||
<p>Let’s say you want to verify that the evade mode is at the right count. How
|
||
can you verify it without modifying the code? Try:</p>
|
||
<pre><code> SIZE=0 SHED=1 SHEDS=1 EVADE=10 ./prog</code></pre>
|
||
<p>Since you start out at size 0 and you shed every movement then when you’re
|
||
size 10 (as long as you don’t eat a bug of course!) the bug should evade.</p>
|
||
<p>If you set it to <code>SIZE=10</code> there would be a difference of 10. Now every
|
||
move you will see the size the snake is. But then…Why is it that it
|
||
doesn’t seem to move until the snake is of size 20? Because you start out at
|
||
size 10 of course (but in fact if you observe the snake won’t appear to be
|
||
of size 20 yet).</p>
|
||
<p>There probably are combinations that can test these types of things I just
|
||
don’t at this time remember any I might have done.</p>
|
||
<div id="stillsnake">
|
||
<h1 id="the-snake-doesnt-seem-to-be-moving"><a href="#toc">The snake doesn’t seem to be moving</a></h1>
|
||
</div>
|
||
<p>One way to show this is in full is to set the initial size and growth size to a
|
||
high value; then try each one individually. For example:</p>
|
||
<pre><code> SIZE=100 ./prog</code></pre>
|
||
<p>In this case after you make the first move the snake will keep growing and
|
||
so the snake tail stays in the same spot until after it’s the ‘full size’.
|
||
When it has reached the full size then the entire body of the snake will
|
||
start to move too (i.e. if the tail isn’t moving it is growing or else paused).</p>
|
||
<p>In several tests I set the initial size to a high value, the max to a higher
|
||
value still and enabled cannibalism and much of the screen was full of the snake
|
||
before it started to move. The [cannibalism.log.md][] has some examples of both
|
||
cannibalism and a long snake that didn’t move for most of the game.</p>
|
||
<p>If however you let the snake get to the full size then eat a bug there can
|
||
be a moment of lingering where it appears the snake moves for a few places
|
||
before it then stops moving and just grows until it’s the full size.</p>
|
||
<p>It can also appear to be not moving when the snake is extraordinarily long
|
||
and more so when the snake has just eaten: which of course is when it would
|
||
grow (just like when shedding). Even so sometimes it takes a moment for the
|
||
snake tail to catch up with the body (so to speak) so that it could for a
|
||
few moments be difficult to know if where you’re going is going to be
|
||
occupied or not.</p>
|
||
<p>Basically if the snake head is moving you can consider the snake to be
|
||
moving or growing and that’s the important point (if you have the default
|
||
status line you can also see the coordinates being updated to show this).</p>
|
||
<div id="getch">
|
||
<h1 id="getch-also-accepts-input-from-some-input-hardware-other-than-keyboards"><a href="#toc">getch() also accepts input from some input hardware other than keyboards</a></h1>
|
||
</div>
|
||
<p>On my MacBook Pro the trackpad has actually triggered directions; if I were to
|
||
swipe up and then down the snake would run into itself. I believe this has to do
|
||
with the function call <code>keypad(v, 1);</code> which enables arrow keys.</p>
|
||
<div id="size">
|
||
<h1 id="size0-is-the-same-as-size1-and-other-oddities"><a href="#toc">SIZE=0 is the same as SIZE=1 and other oddities</a></h1>
|
||
</div>
|
||
<p>What this means is that for both you will only have the snake head. At this point
|
||
you can safely go back on yourself even without cannibalism enabled. This is
|
||
intentional; a snake size of 0 is pointless but why should it not be playable
|
||
anyway?</p>
|
||
<p>If <code>SIZE < 0</code> you’ll likely win straight away since it’s unsigned and it’ll wrap
|
||
back to the maximum so you will win automatically (this is the same as the
|
||
second mode the judges suggested with <code>SIZE=-1 ./prog</code>).</p>
|
||
<p>As for the growth sizes (including shedding) if it’s < 0: the snake will still
|
||
lose its length and display will still be odd: because the snake size is
|
||
decreased any element beyond the reduced size isn’t touched so the snake
|
||
characters will remain on the screen; only the moving snake is what matters.
|
||
But it’s likely the game will be won fairly quickly because once it’s -1 in size
|
||
it’ll be at the maximum size.</p>
|
||
<p>For example if I say <code>SIZE=3 GROW=-2</code> at two bugs the game is won.</p>
|
||
<p>As for growing: anything > 0 it will grow that many; 0 it will not grow (which I
|
||
show as a gameplay mode); and < 0 it will ‘shrink’ as I explained above. You could
|
||
say that it’s defying physics by growing and shrinking simultaneously but either
|
||
way negative size will force a win.</p>
|
||
<p>Here’s a fun output:</p>
|
||
<pre><code> < <<<+</code></pre>
|
||
<p>That’s from:</p>
|
||
<pre><code> SHED=1 SHEDS=-1 ./prog</code></pre>
|
||
<p>And right after that you would see:</p>
|
||
<pre><code> YOU WIN!
|
||
X:72/156 Y:20/41 S:997/997 B:0</code></pre>
|
||
<p>Try this though:</p>
|
||
<pre><code> SHEDS=-1 SHED=25 ./prog</code></pre>
|
||
<p>And you’ll see that you start to be the normal size but then you leave your
|
||
head several places until you end up getting to the max size (by way of it
|
||
being unsigned). This isn’t a bug even if it might seem like one. In fact
|
||
this is the basis of the grow/shrink mode of play that I talk about in the
|
||
<a href="gameplay.html">gameplay.html</a> file.</p>
|
||
<p>Here’s another thing to be aware of. Let’s say you do:</p>
|
||
<pre><code> SIZE=1 GROW=-1 ./prog</code></pre>
|
||
<p>How many bugs will it take before you win? In fact it’s two: you would see the
|
||
head twice: the second time once you ‘shrink’ down to size 0; it would then be
|
||
that if you get another bug you will be at the ‘max size’:</p>
|
||
<pre><code> YOU WIN!
|
||
X:81/156 Y:35/41 S:997/997 B:2</code></pre>
|
||
<div id="bitetail">
|
||
<h1 id="i-was-a-few-places-behind-my-tail-and-i-ran-into-it"><a href="#toc">‘I was a few places behind my tail and I ran into it!’</a></h1>
|
||
</div>
|
||
<p>I.e. what happens if you’re growing - for example after just eating a bug - and
|
||
you’re racing towards your tail? If you’re behind it should be fine since you’re
|
||
going the same speed as the snake is, right? Not quite. Because you’re growing
|
||
you might end up running into your tail (depending on how much you’ve left to
|
||
grow and how far away from your tail)! This happened to me once and it surprised
|
||
me and I figured I better note it.</p>
|
||
<p><strong>Remember: the tail at that point isn’t moving yet; the snake is growing!</strong></p>
|
||
<div id="middleofsnake">
|
||
<h1 id="with-negative-growth-the-snake-drops-from-the-middle-of-the-body"><a href="#toc">With negative growth the snake drops from the middle of the body</a></h1>
|
||
</div>
|
||
<p>For instance it might look like this (the first line is as it happens, the
|
||
second pointing to where it happens and the third being what’s left after the
|
||
rest of the snake has gone through). Doing <code>SHED=100 SHEDS=-1</code>:</p>
|
||
<pre><code> ooooooooo>ooo>
|
||
^
|
||
></code></pre>
|
||
<p>The <code>^</code> points to the part that’s split from the snake and which will be
|
||
there on its own after the snake passes through it. Here’s an example with
|
||
it being <code>SHEDS=-3</code>:</p>
|
||
<pre><code> <ooo<ooooo
|
||
^^^
|
||
<oo</code></pre>
|
||
<p>If you go through the part that has split (which for some might be difficult
|
||
to see whilst the snake has not fully left its skin) you won’t run into
|
||
yourself; if you run into another part though you do. This might be a bit
|
||
confusing I know but what kind of animal shrinks in size by leaving its head
|
||
behind only to sprout up a new head? Actually…on second thought, I won’t
|
||
go there! :)</p>
|
||
<p>Anyway it’s an odd idea for the snake to shrink by leaving part of its skin:
|
||
that’s how they grow in the wild so it’s a misnomer. The shrinking was only
|
||
‘discovered’ because it’s an unsigned number but happily it allows for different
|
||
gameplay modes.</p>
|
||
<div id="buginsnake">
|
||
<h1 id="it-looks-like-the-bug-is-in-the-snake"><a href="#toc">It looks like the bug is in the snake</a></h1>
|
||
</div>
|
||
<p>I show a different example in the [crazy.log.md][] file but what defines a coordinate
|
||
which the snake occupies? If the snake breaks apart then the only part
|
||
of the screen the snake is occupying is the place which is actually moving: if
|
||
the snake decreases in size by 3 then the three respective characters you can go
|
||
through safely. But this also means that a bug can go there! So you might see
|
||
something like:</p>
|
||
<pre><code> <*oooooooo</code></pre>
|
||
<p>This is because the snake is no longer there: in fact in this run the snake was
|
||
quite a bit lower on the screen and 25 in length.</p>
|
||
<div id="bugplacement">
|
||
<h1 id="on-the-safety-of-the-bug-placement-loop"><a href="#toc">On the safety of the bug placement loop</a></h1>
|
||
</div>
|
||
<p>Ilya Kurdyukov shared concern for the loop in the bug placement routine: is it
|
||
safe? What he refers to is that it’s a potential infinite loop. But is it? I
|
||
understand the concern and it’s something I played with a lot to be sure that it
|
||
doesn’t happen. This is how it works.</p>
|
||
<p>To explain it I will go back to the make test program <code>termcaps</code> (which is
|
||
imperfect for the recommended terminal size but the max snake size is exactly
|
||
how it’s done in Snake and works well). The minimum terminal size I require in
|
||
the game is 10 x 10. This includes the walls and score line.</p>
|
||
<p>Now the default max snake size is 997 but when the terminal is too small it
|
||
adjusts the max snake size. For 10 lines and 10 columns you would see:</p>
|
||
<pre><code> $ make test
|
||
terminal supports cursor movement
|
||
terminal supports making cursor invisible
|
||
terminal supports bold
|
||
terminal supports colours
|
||
|
||
terminal rows 10 (7 playable)
|
||
terminal cols 10 (8 playable)
|
||
|
||
snake size: 49 (max size: 49)
|
||
bugs: 9 (max size: 9)
|
||
|
||
at least 28 columns recommended for snake size 49 (is 10)
|
||
at least 28 columns recommended for snake size 49 (is 10)
|
||
|
||
1 problem detected (0 fatal).
|
||
make: *** [test] Error 1</code></pre>
|
||
<p>First: what’s the problem? It’s just a warning that for the snake size of 49 the
|
||
recommended size of columns is 28. However this is just for the score text; with
|
||
only 10 columns it will overflow and wrap to the next line(s). But if you observe
|
||
that 49 is the max snake size. How is this derived and why?</p>
|
||
<p>With 10 rows and columns it’s calculated as <code>7 * 7</code> (i.e. it’s
|
||
<code>(cols-3)*(rows-3)</code>. However the number of playable locations is in this case 56
|
||
(<code>playable_rows * playable_columns</code>). I have played with this many
|
||
times and I do not believe there should be a problem. If there is it’s from a
|
||
very poor implementation of rand() and I discuss this in
|
||
<a href="troubleshooting.html">troubleshooting.html</a>.</p>
|
||
<p>There I also give some test outputs without the cap in place to give an idea of
|
||
when it became a problem (or would have). In short this is known but I do not
|
||
think it will be a problem and I have given resolutions. In any event without
|
||
cannibal mode it’s even less likely that you’ll ever run into this problem.</p>
|
||
<p>The obvious question is why didn’t I put in a break? Because of the IOCCC size
|
||
rule 2 and what would it do anyway? I guess it would win but to my mind that is
|
||
a bug and I prefer putting in restrictions to try and make it very unlikely.</p>
|
||
<hr style="width:10%;text-align:left;margin-left:0">
|
||
<p>Jump to: <a href="#">top</a></p>
|
||
<!--
|
||
|
||
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
|
||
|
||
You are free to share and adapt this file under the terms of this license:
|
||
|
||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||
|
||
For more information, see:
|
||
|
||
https://creativecommons.org/licenses/by-sa/4.0/
|
||
|
||
-->
|
||
<!-- AFTER: last line of markdown file: 2020/ferguson1/bugs.md -->
|
||
|
||
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||
<!-- START: this line starts content from: inc/after-content.default.html -->
|
||
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/after-content.default.html -->
|
||
<!-- START: this line starts content from: inc/footer.default.html -->
|
||
|
||
<!--
|
||
|
||
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
|
||
|
||
You are free to share and adapt this file under the terms of this license:
|
||
|
||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||
|
||
For more information, see:
|
||
|
||
https://creativecommons.org/licenses/by-sa/4.0/
|
||
|
||
-->
|
||
|
||
<div class="footer">
|
||
|
||
<div id="copyright"><h3>Copyright © 1984-2024 by Landon Curt Noll:
|
||
<a href="https://creativecommons.org/faq/#what-does-some-rights-reserved-mean"
|
||
target="_blank"
|
||
rel="license noopener noreferrer">Some Rights Reserved</a></h3>
|
||
<p>
|
||
This work is <b>licensed by Landon Curt Noll</b> under
|
||
<b><a href="https://creativecommons.org/licenses/by-sa/4.0/?ref=chooser-v1"
|
||
target="_blank"
|
||
rel="license noopener noreferrer"
|
||
style="display:inline-block;">CC BY-SA 4.0</a></b>.
|
||
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
|
||
src="../../png/cc.png"
|
||
alt="cc inside circle symbol">
|
||
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
|
||
src="../../png/by.png"
|
||
alt="person inside circle symbol">
|
||
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
|
||
src="../../png/sa.png"
|
||
alt="arrow looping back on itself inside circle symbol"><br>
|
||
You should <b>carefully review</b> the
|
||
<b><a href="https://creativecommons.org/licenses/by-sa/4.0/legalcode.en"
|
||
target="_blank"
|
||
rel="license noopener noreferrer">CC BY-SA 4.0 LEGAL CODE</a></b>
|
||
before using the licensed material.<br>
|
||
You may wish to review the
|
||
<b><a href="../../license.html"
|
||
target="_blank"
|
||
rel="license noopener noreferrer">highlights of some of the key features and terms</a></b>
|
||
of <b>CC BY-SA 4.0</b>.<br>
|
||
</p>
|
||
</div>
|
||
|
||
<div id="coda"><h3>Coda</h3>
|
||
<p>
|
||
<a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2020%2Fferguson1%2Fbugs.html" rel="nofollow">Nu HTML check this web page</a><br>
|
||
<a href="#top">Jump to top</a> <a href="#content">Jump to Content</a>
|
||
</p>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/footer.default.html -->
|
||
<!-- START: this line starts content from: inc/bottom.default.html -->
|
||
|
||
</body>
|
||
</html>
|
||
|
||
<!-- END: this line ends content from: inc/bottom.default.html -->
|