Prepare for the winners of **IOCCC28**. > However these are not the 2024 droids you are looking for. :-) The HTML menu (both JavaScript and non-JavaScript) has been updated. The `Status -> Rules and guidelines' have been replaced with two separate menus `Status -> IOCCC rules` and `Status -> IOCCC guidelines`. Added a new top level `social.html` page: built from a new `social.md`. Sorted rules for building specific web pages in the top level `Makefile`. Added `make social` to make the `social.html` page from `social.md`. The `bin/gen-top-html.sh` now is able to process a argument of **social** to process the new top level `social.html` page. Changed `bin/gen-top-html.sh` VERSION from "2.0.0 2025-03-13" to "2.0.1 2025-07-25". Below `About -> Home page` a new `About -> IOCCC social media` menu item as added. Because the menu change touched every HTML file, we changed the general copyright date range for HTML files from "1984-2024" to "1984-2025" due to the extensive changes made for **IOCCC28**. Those markdown files that were modified in 2025 had their copyright date range also changed from "1984-2024" to "1984-2025". Rebuilt tarballs and sitemap due to the extensive HTML rebuilding. Ran `make update` to perform the above.
887 lines
38 KiB
HTML
887 lines
38 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="troubleshooting.md for 2020/ferguson1">
|
||
<meta name="keywords" content="IOCCC, 2020/ferguson1, troubleshooting.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/troubleshooting.md -->
|
||
<!-- -->
|
||
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 2020/ferguson1/troubleshooting.md !!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 2020/ferguson1/troubleshooting.md !!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 2020/ferguson1/troubleshooting.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 authors
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../bugs.html" class="sub-item-link">
|
||
Bugs and (mis)features
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#fix_an_entry" class="sub-item-link">
|
||
Fixing entries
|
||
</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">
|
||
Status
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../news.html" class="sub-item-link">
|
||
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/rules.html" class="sub-item-link">
|
||
IOCCC rules
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../next/guidelines.html" class="sub-item-link">
|
||
IOCCC guidelines
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../markdown.html" class="sub-item-link">
|
||
Markdown guidelines
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../SECURITY.html" class="sub-item-link">
|
||
Security policy
|
||
</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">
|
||
Frequently asked questions
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../quick-start.html#enter" class="sub-item-link">
|
||
Enter the IOCCC
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#compiling" class="sub-item-link">
|
||
Compiling entries
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#running_entries" class="sub-item-link">
|
||
Running entries
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#help" class="sub-item-link">
|
||
How to help
|
||
</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">
|
||
Home page
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../social.html" class="sub-item-link">
|
||
IOCCC social media
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../about.html" class="sub-item-link">
|
||
About the IOCCC
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../judges.html" class="sub-item-link">
|
||
The judges
|
||
</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="../../contact.html" class="sub-item-link">
|
||
Contact us
|
||
</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">
|
||
Winning authors
|
||
</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>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#fix_an_entry">
|
||
Fixing entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#fix_author">
|
||
Updating author info
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../thanks-for-help.html">
|
||
Thanks for the help
|
||
</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="../../news.html">
|
||
News
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../status.html">
|
||
Contest status
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../next/rules.html">
|
||
IOCCC rules
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../next/guidelines.html">
|
||
IOCCC guidelines
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../markdown.html">
|
||
Markdown guidelines
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../SECURITY.html">
|
||
Security policy
|
||
</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="../../quick-start.html#enter">
|
||
Enter the IOCCC
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#compiling">
|
||
Compiling entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#running_entries">
|
||
Running entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#help">
|
||
How to help
|
||
</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">
|
||
Home page
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../social.html">
|
||
IOCCC social media
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../about.html">
|
||
About the IOCCC
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../judges.html">
|
||
The judges
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../contact.html">
|
||
Contact us
|
||
</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>troubleshooting.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%2Fwww.ioccc.org%2F2020%2Fferguson1%2Ftroubleshooting.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/troubleshooting.md -->
|
||
<p>9 Troubleshooting Snake</p>
|
||
<p>In this file I have a list of a number of possible problems that could show up
|
||
under some situations as well as some things that might appear to be happening
|
||
or be a problem but actually are not. For each one I have included a summary, a
|
||
more thorough description and any resolutions (from easiest to hardest). For
|
||
anything that can cause more than one issue I will list those separately to keep
|
||
it as structured as possible/easiest to find.</p>
|
||
<div id="top">
|
||
<ul>
|
||
<li><a href="#topwall">The top wall isn’t (all/some of the time) visible!</a></li>
|
||
<li><a href="#notmoving">The snake isn’t moving!</a></li>
|
||
<li><a href="#invisiblehead">I can’t see the snake head (or other part of the snake)!</a></li>
|
||
<li><a href="#invisiblebug">I can’t see the bug!</a></li>
|
||
<li><a href="#froze">The game froze!</a></li>
|
||
<li><a href="#bigsnake">The game gets slower as the snake gets bigger!</a></li>
|
||
<li><a href="#headonly">I set SIZE=0 GROW=1, ate a bug but still only the head was visible! Why?</a></li>
|
||
<li><a href="#monochrome">I like black text on a white background but even with a white background terminal it ends up black!</a></li>
|
||
<li><a href="#toodark">The text is hard to see (not bright enough)!</a></li>
|
||
<li><a href="#movefaster">Can I move the snake faster temporarily without having to modify the wait time?</a></li>
|
||
<li><a href="#envvars">On environmental variables more generally and string to int conversions</a></li>
|
||
<li><a href="#errors">Errors and error reporting</a></li>
|
||
</ul>
|
||
</div>
|
||
<div id="topwall">
|
||
<h2 id="the-top-wall-isnt-allsome-of-the-time-visible"><a href="#toc">The top wall isn’t (all/some of the time) visible!</a></h2>
|
||
</div>
|
||
<p>Because the score line is dynamic in length depending on the terminal size it
|
||
can happen that the score/status wraps to the next line(s). This can be fixed by
|
||
modifying the status line (see <a href="HACKING.html">HACKING.html</a>) but
|
||
you shouldn’t need it to be very wide.</p>
|
||
<ul>
|
||
<li><p><strong>RESOLUTION #0</strong>: use a bigger screen (it doesn’t take that many columns)</p>
|
||
<p><strong>Tip:</strong> try running <code>make test</code> to get an estimate of the minimum number of columns
|
||
needed. This won’t work right if you change the score line!</p>
|
||
<p>Note that this utility is not perfect; I describe this elsewhere. Either way a
|
||
small screen will make it harder to play esp without the cheat modes enabled
|
||
(but they can still be fun with large screens).</p></li>
|
||
<li><p><strong>RESOLUTION #1</strong>: open the <a href="https://github.com/ioccc-src/winner/blob/master/2020/ferguson1/prog.c">prog.c</a> and change the line</p>
|
||
<pre><code> #define J Z(X:%d/%d Y:%d/%d S:%zu/%zu B:%zu\n),Y,y[-2],X, *y, A, g, c );</code></pre>
|
||
<p>To be something like:</p>
|
||
<pre><code> #define J Z(B:%zu\n), c);</code></pre>
|
||
<p>Recompile and try again. That will then show only the number of bugs eaten.
|
||
See the <a href="HACKING.html">HACKING.html</a> file for other data you
|
||
can include (though there are some discrepancies here and there as you’ll
|
||
see).</p></li>
|
||
</ul>
|
||
<div id="notmoving">
|
||
<h2 id="the-snake-isnt-moving"><a href="#toc">The snake isn’t moving!</a></h2>
|
||
</div>
|
||
<p>Unless the game is paused this should not be happening. It can appear sometimes
|
||
that there isn’t movement and sometimes it might have to take a moment to
|
||
‘unwind’ but as long as the head is moving then everything is fine.</p>
|
||
<p>The tail might not always be moving which could make it seem like the snake
|
||
isn’t moving but as long as the head is moving then the snake can be assumed to
|
||
be moving.</p>
|
||
<ul>
|
||
<li><p><strong>RESOLUTION #0</strong>: unless the game is paused as long as the snake head is moving
|
||
everything is fine even if it seems sometimes that the snake tail is still: this
|
||
is normal and there are a few conditions that this might especially show itself
|
||
e.g. when the snake is growing.</p>
|
||
<p>If you want to see this in action try:</p>
|
||
<pre><code> SIZE=150 SHEDS=10 SHED=1 ./prog</code></pre>
|
||
<p>Once you start moving you’ll see that the tail stays still for a while and
|
||
when it does move you’ll see it doesn’t move for long.</p>
|
||
<p>Sometimes also it might appear that the movement is delayed but there are
|
||
numerous causes for this some of which are a busy computer but ultimately
|
||
it’ll catch up; just give it the time it needs.</p></li>
|
||
<li><p><strong>BOTTOM LINE</strong>: if you want more information then see the <a href="bugs.html">bugs.html</a>
|
||
file.</p></li>
|
||
</ul>
|
||
<div id="invisiblehead">
|
||
<h2 id="i-cant-see-the-snake-head-or-other-part-of-the-snake"><a href="#toc">I can’t see the snake head (or other part of the snake)!</a></h2>
|
||
</div>
|
||
<p>Possibly this could happen with too long a score line which I already discussed.
|
||
It also used to be possible during cannibal mode whilst cannibalising: you would
|
||
just have to continue moving on and you’d eventually find your head (assuming
|
||
the rest of the screen isn’t covered with your body!). And what else could you
|
||
expect if you decided to shove your head up your …. ? :))</p>
|
||
<ul>
|
||
<li><p><strong>RESOLUTION #0</strong>: actually I thought it would look better that you could see the
|
||
head even when cannibalising so you should be able to lose your head and at the
|
||
same time see it!</p></li>
|
||
<li><p><strong>RESOLUTION #1</strong>: if the terminal width is too small then it could be that the
|
||
score line is covering the wall, snake and even bug; I gave two resolutions to
|
||
that earlier in this file. To get a recommended number of columns use <code>make test</code>.</p></li>
|
||
</ul>
|
||
<div id="invisiblebug">
|
||
<h2 id="i-cant-see-the-bug"><a href="#toc">I can’t see the bug!</a></h2>
|
||
</div>
|
||
<p>This has happened to me a number of times and early in development there were
|
||
times that I could swear I even saw it beyond the walls but this should not be a
|
||
problem now if it ever was.</p>
|
||
<p>However I have made a lot of effort to think of situations that might make the
|
||
bug location calculation and placement be a problem and even did some debug
|
||
output and wrote another test program to calculate the maximum number of places
|
||
the bug could be put etc.</p>
|
||
<p>One of the reasons I have the terminal dimensions have a minimum and also a
|
||
maximum has to do with the way the bug placement and max size of the snake (and
|
||
so arrays) are calculated: it could happen that because of it being unsigned
|
||
without there being restrictions it could end up being a bad value that causes
|
||
the bug placement loop to never end (in this case the snake would also stop
|
||
moving).</p>
|
||
<ul>
|
||
<li><p><strong>RESOLUTION #0</strong>: if evasion mode is enabled (default after 300 moves) just wait
|
||
it out and the bug will move to a new place and it might be easier to see in the
|
||
new place.</p></li>
|
||
<li><p><strong>RESOLUTION #1</strong>: the terminal size is too small for the score line. See the
|
||
earlier problem for how to resolve this if that’s the case.</p></li>
|
||
<li><p><strong>RESOLUTION #2</strong>: sometimes you have to look closely for it can be easy to miss.
|
||
If it’s against the wall and the screen is <a href="https://www.hp-lexicon.org/character/gaunt-family/morfin-gaunt/">Snakey</a> or you’re tired or the colour
|
||
contrast isn’t right for you or something like that it might be harder to see.
|
||
Try pausing the game (space) and scan the screen for it. If you really are
|
||
desperate copy and paste the entire file into a document and search for the bug
|
||
char (if it’s an editor like vi/vim you will have to be sure to escape the char
|
||
since <code>*</code> is a regexp metacharacter). This has happened to me numerous times.</p></li>
|
||
<li><p><strong>RESOLUTION #3</strong>: if the colour contrast is not good for your eyes use the
|
||
<a href="https://github.com/ioccc-src/winner/blob/master/2020/ferguson1/snake-colours.sh">snake-colours.sh</a> script to select a different colour scheme.</p></li>
|
||
</ul>
|
||
<div id="froze">
|
||
<h2 id="the-game-froze"><a href="#toc">The game froze!</a></h2>
|
||
</div>
|
||
<p>This should not be possible either but without certain safety checks in place I
|
||
have caused this (and I did this deliberately in development to find all the
|
||
conditions I could to resolve them).</p>
|
||
<ul>
|
||
<li><p><strong>RESOLUTION #0</strong>: if this does happen it likely is to do with placement of the
|
||
bug; that is why I have the max size of the snake capped a fair bit below the
|
||
maximum number of coordinates in the game field: because the bug isn’t to be at
|
||
a place the snake already occupies.</p></li>
|
||
<li><p><strong>RESOLUTION #1</strong>: if the system <code>rand()</code> implementation is really bad maybe it’s
|
||
having a problem finding a location to place the bug. The best I can think of is
|
||
to try increasing the screen size or decrease the max size of the snake.</p></li>
|
||
<li><p><strong>BOTTOM LINE</strong>: if the bug cannot find a place to be this will likely cause the
|
||
game to freeze because the game loops until it finds an available place for the
|
||
bug to be; if the pRNG is so bad wrt where the snake occupies it could
|
||
theoretically happen. If this happens you will have to kill the game by e.g.
|
||
ctrl-c. Try increasing the screen size and/or decreasing the max size of the
|
||
snake. See below for some tests.</p>
|
||
<p>I removed caps in a test and then:</p>
|
||
<pre><code> GROW=1 COLUMNS=30 LINES=10 CANNIBAL=1 MAXSIZE=10000 ./prog</code></pre>
|
||
<p>It froze at this point:</p>
|
||
<pre><code> X:14/29 Y:5/9 S:323/10000 B:318</code></pre>
|
||
<p>This is because there was only one place for the bug - where the snake head
|
||
was to be. With these parameters the limit is actually 189! This could
|
||
perhaps be increased but the calculation I have used is easy and although I
|
||
certainly could make it so it’s one less than the max that takes more bytes
|
||
and I don’t see it actually mattering.</p>
|
||
<p>Another time I tried:</p>
|
||
<pre><code> LINES=6 COLUMNS=6</code></pre>
|
||
<p>And it also froze (as noted I impose a minimum of >= 10 for both LINES and
|
||
COLUMNS).</p>
|
||
<p>Ultimately I had to kill the program due to the game being stuck in the bug
|
||
placement routine. I could have put in a maximum number of loops but what
|
||
good would that do? It would use more bytes and what would it do anyway,
|
||
win? Well that’s what the max size is for.</p></li>
|
||
<li><p>TERMINAL SIZE TO MAX SNAKE SIZE CALCULATION ETC.</p>
|
||
<p>For this information and more use the termcaps utility:</p>
|
||
<pre><code> make test</code></pre>
|
||
<p>An example:</p>
|
||
<pre><code> terminal supports cursor movement
|
||
terminal supports making cursor invisible
|
||
terminal supports bold
|
||
terminal supports colours
|
||
|
||
terminal rows 41 (38 playable)
|
||
terminal cols 154 (152 playable)
|
||
|
||
snake size: 997 (max size: 5738)
|
||
bugs: 199 (max size: 1147)
|
||
|
||
at least 34 columns (currently 154) recommended for snake size 997
|
||
at least 37 columns (currently 154) recommended for capped snake size 5738
|
||
|
||
No problems detected.</code></pre>
|
||
<p>Why are there only 38 playable lines for 41 rows? The first row is the score
|
||
line, the second is the top wall, the last is the bottom wall. For columns
|
||
you have the left and rightmost columns for the walls.</p>
|
||
<p>The calculation for max size takes place after decrementing the max y/x;
|
||
then it’s <code>(maxy - 2) * (maxx - 2)</code>; above that would be:</p>
|
||
<pre><code> (41 - 2) * (156 - 2) == 6006</code></pre>
|
||
<p>If for some reason the game were to stall for this purpose you would have to
|
||
kill the game by e.g. ctrl-c since the bug placement is stuck in a loop.
|
||
This shouldn’t happen though.</p></li>
|
||
</ul>
|
||
<div id="bigsnake">
|
||
<h2 id="the-game-gets-slower-as-the-snake-gets-bigger"><a href="#toc">The game gets slower as the snake gets bigger!</a></h2>
|
||
</div>
|
||
<p>Realistically the game shouldn’t take that much memory but maybe in some very
|
||
busy systems it would have a problem.</p>
|
||
<ul>
|
||
<li><p><strong>RESOLUTION #0</strong>: if the <code>rand(3)</code> implementation is particularly poor then it might
|
||
be that the bug placement is taking more time.</p></li>
|
||
<li><p><strong>RESOLUTION #1</strong>: it could also be the arrays being updated as the snake gets
|
||
bigger.</p></li>
|
||
<li><p><strong>BOTTOM LINE</strong>: I find it unlikely that either of these happen and I don’t know
|
||
what to say; you can try decreasing the max size to see if it doesn’t reach this
|
||
problem. Otherwise it would be good to see if you can find a pattern: is it when
|
||
the snake is bigger i.e. the screen is rather fuller than when you first begin?
|
||
Or is the system rather busy?</p></li>
|
||
</ul>
|
||
<div id="headonly">
|
||
<h2 id="i-set-size0-grow1-ate-a-bug-but-still-only-the-head-was-visible-why"><a href="#toc">I set <code>SIZE=0 GROW=1</code>, ate a bug but still only the head was visible! Why?</a></h2>
|
||
</div>
|
||
<ul>
|
||
<li><p><strong>RESOLUTION #0</strong>: the size includes the head but what should it show if the size
|
||
is 0? The head is the obvious choice so once you do get to size 1 you will still
|
||
only have the head. When you get to size 2 you’ll have part of the body too.
|
||
Try:</p>
|
||
<pre><code> SIZE=1 GROW=1</code></pre>
|
||
<p>And you will see that at one bug you’ll have size two and just as if you had
|
||
two bugs with the previous invocation.</p>
|
||
<p>BTW: when you are size 1 you can go back on yourself even if cannibalism is
|
||
disabled because there really isn’t anything to go back through: it’s just
|
||
you moving the head until you find a body to use! Once you have size >= 2
|
||
then cannibalism mode counts.</p></li>
|
||
<li><p><strong>BOTTOM LINE</strong>: in some senses <code>SIZE=0</code> and <code>SIZE=1</code> are the same thing.</p></li>
|
||
</ul>
|
||
<div id="monochrome">
|
||
<h2 id="i-like-black-text-on-a-white-background-but-even-with-a-white-background-terminal-it-ends-up-black"><a href="#toc">I like black text on a white background but even with a white background terminal it ends up black!</a></h2>
|
||
</div>
|
||
<p>This is a curses thing but fortunately it should be easy enough to solve.</p>
|
||
<ul>
|
||
<li><p><strong>RESOLUTION #0</strong>: try setting the terminal to monochrome for the invocation of
|
||
the game. Depending on what is installed on your system you might not have a
|
||
monochrome terminal but you can certainly get them. In Red Hat systems these can
|
||
be found in the package ncurses-term but maybe that will vary on others. I don’t
|
||
recall having to install it under macOS nor Fedora but those systems have GUIs
|
||
so that’s probably why; in CentOS I did have to install it specially.</p>
|
||
<p>The <code>-m</code> suffix to terminal names means monochrome. Under Linux this
|
||
terminal is under <code>/usr/share/terminfo/l/linux-m</code> and under macOS (Catalina
|
||
at least) it’s at <code>/usr/share/terminfo/6c/linux-m</code> (for macOS Ventura it’s
|
||
<code>/usr/share/terminfo/6c/linux-m</code>).</p></li>
|
||
<li><p><strong>BOTTOM LINE</strong>: try using a monochrome terminal for the game by e.g.:</p>
|
||
<pre><code> TERM=linux-m ./prog</code></pre>
|
||
<p>And then on your white background terminal the game should keep the
|
||
background white and the foreground black. This will of course mean you have
|
||
no colour but unfortunately changing the background colour of curses would
|
||
eat too many bytes in the entry (I cite the functions in the
|
||
<a href="HACKING.html">HACKING.html</a>.</p>
|
||
<p>I discuss colours and terminals in much more detail in
|
||
<a href="terminals.html">terminals.html</a>.</p></li>
|
||
</ul>
|
||
<div id="toodark">
|
||
<h2 id="the-text-is-hard-to-see-not-bright-enough"><a href="#toc">The text is hard to see (not bright enough)!</a></h2>
|
||
</div>
|
||
<ul>
|
||
<li><p><strong>RESOLUTION #0</strong>: make sure that your terminal settings have for bold text a
|
||
brighter font. The way I have my terminal profiles set up is to use bright
|
||
colours for bold text. I specifically enable bold in the program so try and find
|
||
out if enabling brighter colours is possible.</p>
|
||
<p>If it’s already set at brighter colours I do not know what to say. Try
|
||
playing with the colours in your terminal, maybe the font size or various
|
||
other settings. Probably better to make a new profile for this first in case
|
||
you mess up your old one. FWIW I haven’t had this problem on consoles only
|
||
and in my systems I have the option to enable brighter colours for bold - it
|
||
was only in testing that I came across this problem. Of course you might
|
||
also try changing the colours of the game. For that see
|
||
<a href="https://github.com/ioccc-src/winner/blob/master/2020/ferguson1/snake-colours.sh">snake-colours.sh</a> and
|
||
<a href="https://github.com/ioccc-src/winner/blob/master/2020/ferguson1/play.sh">play.sh</a>.</p></li>
|
||
</ul>
|
||
<div id="movefaster">
|
||
<h2 id="can-i-move-the-snake-faster-temporarily-without-having-to-modify-the-wait-time"><a href="#toc">Can I move the snake faster temporarily without having to modify the wait time?</a></h2>
|
||
</div>
|
||
<p>Yes. The <code>getch()</code> call is non-blocking when the timeout value is positive so
|
||
it’s up to that number of milliseconds.</p>
|
||
<ul>
|
||
<li><p><strong>RESOLUTION #0</strong>: all you need to do then is hold down the direction key (or for
|
||
that matter any other key that <code>getch()</code> will pick up on). You can also rapidly
|
||
push the key instead of holding it down.</p></li>
|
||
<li><p><strong>BOTTOM LINE</strong>: depending on the key repeat rate and/or how fast you repeatedly
|
||
hit the key you can have more control over the speed - as long as it is quicker
|
||
than the regular wait time. For negative wait time (drawing mode) you have to
|
||
hit a key every time to move because it is blocking.</p></li>
|
||
</ul>
|
||
<div id="envvars">
|
||
<h2 id="on-environmental-variables-more-generally-and-string-to-int-conversions"><a href="#toc">On environmental variables more generally and string to int conversions</a></h2>
|
||
</div>
|
||
<p>What happens if you do:</p>
|
||
<pre><code> WALLS= ./prog</code></pre>
|
||
<p>Can you run into the wall since you didn’t specify a value and the default is 1?
|
||
No. That’s not the way it works. By saying WALLS= you have told the system that
|
||
there is that environmental variable. However the way the <code>strtoul()</code> functions
|
||
work is that if there’s no valid input it returns 0. This can be detected but
|
||
it’s wasteful (iocccsize wise) and I have never felt that having invalid input
|
||
for a number could have a better value than 0.</p>
|
||
<p>If however you were to give valid input followed by invalid input the valid
|
||
input would be parsed. For example:</p>
|
||
<pre><code> WALLS=1test ./prog</code></pre>
|
||
<p>would let you go through the walls. On the other hand</p>
|
||
<pre><code> WALLS=test1 ./prog</code></pre>
|
||
<p>would not. Furthermore if you specify the same variable more than once it’s the
|
||
last one that counts. For example:</p>
|
||
<pre><code> WALLS=0 WALLS=1 CANNIBAL=1 CANNIBAL=0 ./prog</code></pre>
|
||
<p>would allow you to go through walls but you could not cannibalise.</p>
|
||
<p>Also note that I specify base 0 which means that you can also have it in hex and
|
||
octal. These are all the same:</p>
|
||
<pre><code> SIZE=0x3
|
||
SIZE=3
|
||
SIZE=03</code></pre>
|
||
<p>The way the functions work is if 0x (or 0X) it’s considered hex; if prefixed
|
||
with a 0 it’s octal and otherwise it’s decimal. If you specify invalid data
|
||
(even if only at the beginning of the string) the functions return 0. For
|
||
example:</p>
|
||
<pre><code> SIZE=0
|
||
SIZE=f
|
||
SIZE=-
|
||
SIZE=f1</code></pre>
|
||
<p>are all equivalent.</p>
|
||
<p>Observe that:</p>
|
||
<pre><code> SIZE=08</code></pre>
|
||
<p>is invalid input because octal only has digits 0 - 7: the resulting size will be
|
||
0.</p>
|
||
<p>I discuss the signed/unsigned issue to do with curses and sizes in C being
|
||
unsigned in <a href="bugs.html">bugs.html</a> but probably there isn’t
|
||
anything more to say here.</p>
|
||
<div id="errors">
|
||
<h2 id="errors-and-error-reporting"><a href="#toc">Errors and error reporting</a></h2>
|
||
</div>
|
||
<p>If curses fails to initialise you should get an error that says ‘curses error’
|
||
and you have every right to curse it to hell if that’s what you so wish.
|
||
Apparently curses will report an error itself if that function fails but that
|
||
escaped my notice until later on so you might get two errors in that case.</p>
|
||
<p>Assuming it succeeds the game obtains the maximum y/x of the terminal. The
|
||
screen size must be at least 10 lines/columns (though in code the number will
|
||
not be 10); if either is smaller you will get ‘screen too small’ and the game
|
||
will end (yes things that haven’t begun can be ended).</p>
|
||
<p>If <code>calloc()</code> fails to obtain the needed memory you’ll see something like (here it
|
||
was before I added proper - to make the perfect and obvious pun - capsizing
|
||
so that by setting the size to -1 it went to the max unsigned value):</p>
|
||
<pre><code> $ MAXSIZE=-1 ./prog
|
||
memory error
|
||
X:0/157 Y:0/42 S:3/18446744073709551614 B:0</code></pre>
|
||
<p><strong>BTW</strong>: there are two arrays that have to be <strong>MAXSIZE</strong> (technically + 1).</p>
|
||
<p>Is it possible that some value specified by the user could mess this up? I do
|
||
not know but what I do know is that because it’s unsigned it can’t be negative;
|
||
if the max size is 0 then the array size will be 1 but it won’t matter because
|
||
the snake size will be >= that max anyway. But here’s a curious output:</p>
|
||
<pre><code> SIZE=1 MAXSIZE=0 ./prog
|
||
YOU WIN!
|
||
X:78/156 Y:20/41 S:0/0 B:0</code></pre>
|
||
<p>Why does it show snake size as 0 when I specified 1? It’s because the max size
|
||
is 0 and I limit the size to be no bigger than the max size.</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/troubleshooting.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-2025 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-2025 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%2Fwww.ioccc.org%2F2020%2Fferguson1%2Ftroubleshooting.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 -->
|