improve how markdown code language is commented
We added a space between the markdown triple code mark and language that was enclosed in HTML comments. So a line of the form: ```` ```<!---c---> ```` became: ```` ``` <!---c---> ```` This was done to **help** some code see that the HTML comment string was not a markdown code specifier. Not all code understands this after this changed. For example, `pandoc(1)` still forms HTML classes of the form "<!---c-->" when it encounters the above mentioned change. We also fixed a problem with `2019/dogon/README.md` regarding a markdown code block. We also fixed a problem with `2020/yang/README.md` regarding a markdown code block.
This commit is contained in:
1 parent
c549f6585e
commit
3ddbac9e6b
357 files changed
+2432
-2399
No files matched your search
@@ -33,7 +33,7 @@ I imagine that it works for 32-bit systems but I do not know for sure.
|
||||
|
||||
You should be able to get the compiler with:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
sudo xcode-select --install
|
||||
```
|
||||
|
||||
@@ -53,13 +53,13 @@ you want to use the Makefile) to compile and link this entry. With Fedora more
|
||||
recent versions there's the `dnf` package manager but I cannot help with any of
|
||||
the GUI installers since I don't use them. Something like:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
sudo dnf install ncurses-devel ncurses make gcc
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
# dnf install ncurses-devel ncurses make gcc
|
||||
```
|
||||
|
||||
@@ -69,25 +69,25 @@ Just like Fedora you will need `gcc`, `ncurses`, `ncurses-devel` (and if you
|
||||
want to use the Makefile `make`). CentOS uses `yum` and CentOS 8 uses `dnf`.
|
||||
So:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
sudo yum install ncurses-devel ncurses make gcc
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
# yum install ncurses-devel ncurses make gcc
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
sudo dnf install ncurses-devel ncurses make gcc
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
# dnf install ncurses-devel ncurses make gcc
|
||||
```
|
||||
|
||||
|
||||
+13
-13
@@ -78,7 +78,7 @@ initialise a pair (make it 5 so as to not interfere with the script
|
||||
customisability) and then you use the bkgd() function with the colour pair.
|
||||
Something like this:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
init_pair(5, COLOR_BLACK, COLOR_WHITE);
|
||||
bkgd(COLOR_PAIR(5));
|
||||
```
|
||||
@@ -88,7 +88,7 @@ but that changes the background of the program anyway.
|
||||
|
||||
The standard colour identifiers are:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
COLOR_BLACK
|
||||
COLOR_RED
|
||||
COLOR_GREEN
|
||||
@@ -124,7 +124,7 @@ Let's say you don't want to use arrow keys or you don't have arrow keys. Instead
|
||||
you might want the keys `l`, `r`, `u` and `d` for the directions. Find the case
|
||||
statements:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
case KEY_LEFT:
|
||||
case KEY_RIGHT:
|
||||
case KEY_UP:
|
||||
@@ -133,7 +133,7 @@ statements:
|
||||
|
||||
Replace `KEY_LEFT` with:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
'l'
|
||||
```
|
||||
|
||||
@@ -141,7 +141,7 @@ and do the same thing for the other directions too. If you want more than one
|
||||
key e.g. the arrow keys and the letters just add another case statement e.g. for
|
||||
left it might be:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
case KEY_LEFT: case 'l':
|
||||
```
|
||||
|
||||
@@ -166,13 +166,13 @@ different sets. Please also be aware that if you don't want any information you
|
||||
must set it to the below at the very least; defining it without a value is not
|
||||
enough (it amounts to the parameters to a printf call):
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
#define J " " );
|
||||
```
|
||||
|
||||
If you don't care about brief displays of 'o' at 0,0 you can just have:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
#define J "");
|
||||
```
|
||||
|
||||
@@ -194,7 +194,7 @@ coordinates of where the snake is plus the other things that are there (a number
|
||||
of which were added over time). Obviously this would take many bug sized bytes
|
||||
(bites) even once let alone twice! Thus I made it into a define:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
#define J Z(X:%d/%d Y:%d/%d S:%zu/%zu B:%zu\n), Y, y[-2], X,*y,A,g, c);
|
||||
```
|
||||
|
||||
@@ -220,7 +220,7 @@ For an example this would only include the size of the snake and the number of
|
||||
bugs eaten (I think I have this correct; I've made many changes to the point of
|
||||
not wanting to mess with anything that's unnecessary):
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
#define J Z(SIZE: %zu BUGS: %zu\n), A, c);
|
||||
```
|
||||
|
||||
@@ -257,13 +257,13 @@ come to mind as information that might be of interest.
|
||||
|
||||
Quite simply change:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
X = H / 2; Y = *x / 2;
|
||||
```
|
||||
|
||||
To be something like:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
X = R(1,H-1);
|
||||
Y = R(2,*x-1);
|
||||
```
|
||||
@@ -395,7 +395,7 @@ street!).
|
||||
If you look at the walls code you will see a ternary operator for both `X` and `Y`
|
||||
coordinates. This of course is very different now but the idea remains the same:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
if (p && !(*O>=O[1]||H>=M(1)))
|
||||
{
|
||||
if (X<1||X>=H)
|
||||
@@ -414,7 +414,7 @@ coordinates to the correct new location.
|
||||
If however you wanted the walls to act as a barrier you could do something like
|
||||
this instead (omitting the inner if statements here):
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
X=X<1?1:*H-1;
|
||||
|
||||
Y=Y<2?2:*O-1;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
@@ -18,7 +18,7 @@ For more detailed information see [2020 ferguson1 bugs](../../bugs.html#2020_fer
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WAIT=N WALLS=[01] EVADE=N SIZE=N MAXSIZE=N GROW=N SHEDS=N SHED=N CANNIBAL=[01] ./prog
|
||||
# start pressing some arrow keys
|
||||
```
|
||||
@@ -87,7 +87,7 @@ and non-zero).
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make test
|
||||
|
||||
WAIT=75 WALLS=1 CANNIBAL=1 ./prog
|
||||
@@ -211,7 +211,7 @@ features.
|
||||
Because all IOCCC entries should have a man page I have included one (even
|
||||
though much of it is what's also above). To render try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
man ./snake.1
|
||||
```
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ simply a fun consequence of the features I did implement.
|
||||
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:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SIZE=0 SHED=1 SHEDS=1 EVADE=10 ./prog
|
||||
```
|
||||
|
||||
@@ -44,7 +44,7 @@ don't at this time remember any I might have done.
|
||||
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:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SIZE=100 ./prog
|
||||
```
|
||||
|
||||
@@ -113,7 +113,7 @@ Here's a fun output:
|
||||
|
||||
That's from:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SHED=1 SHEDS=-1 ./prog
|
||||
```
|
||||
|
||||
@@ -126,7 +126,7 @@ And right after that you would see:
|
||||
|
||||
Try this though:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SHEDS=-1 SHED=25 ./prog
|
||||
```
|
||||
|
||||
@@ -138,7 +138,7 @@ this is the basis of the grow/shrink mode of play that I talk about in the
|
||||
|
||||
Here's another thing to be aware of. Let's say you do:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SIZE=1 GROW=-1 ./prog
|
||||
```
|
||||
|
||||
@@ -146,7 +146,7 @@ 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':
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
YOU WIN!
|
||||
X:81/156 Y:35/41 S:997/997 B:2
|
||||
```
|
||||
@@ -228,7 +228,7 @@ the game is 10 x 10. This includes the walls and score line.
|
||||
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:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ make test
|
||||
terminal supports cursor movement
|
||||
terminal supports making cursor invisible
|
||||
|
||||
@@ -184,7 +184,7 @@ most of them.
|
||||
Another example invocation where the snake head is in the snake and where the snake
|
||||
hadn't yet moved (that is it was still growing):
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
CANNIBAL=1 SIZE=1500 GROW=2 MAXSIZE=1600 ./prog
|
||||
```
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
The following are a few screen dumps of:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SIZE=100 SHEDS=5 GROW=-10 SHED=50 MAXSIZE=250 ./prog
|
||||
```
|
||||
|
||||
|
||||
+20
-20
@@ -415,7 +415,7 @@ default) or setting the size to higher than the default (or < 0 which will end
|
||||
up being > the max size though I suppose there might be some value that makes it
|
||||
less than again - I'm not going to try and figure that out however). Anyway:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SIZE=-1 ./prog
|
||||
YOU WIN!
|
||||
X:24/49 Y:8/16 S:658/658 B:0
|
||||
@@ -487,7 +487,7 @@ If you want to draw the snake wherever you like on the screen you can do this by
|
||||
modifying the wait time (for input) to -1 (or any value < 0): then the snake
|
||||
does not move until you press a movement key. For example:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WAIT=-1 ./prog
|
||||
```
|
||||
|
||||
@@ -495,7 +495,7 @@ does not move until you press a movement key. For example:
|
||||
When you eat a bug the snake will grow and you can draw more. If you want to
|
||||
make it so you can go through yourself:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WAIT=-1 CANNIBAL=1 ./prog
|
||||
```
|
||||
|
||||
@@ -503,7 +503,7 @@ If you don't want to start out so small (i.e. you want to be able to draw more
|
||||
quickly) you can just set the size to a bigger number (and you could do the same
|
||||
with growth and moult/shed):
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SIZE=50 CANNIBAL=1 WAIT=-1 ./prog
|
||||
```
|
||||
|
||||
@@ -513,14 +513,14 @@ time.
|
||||
Okay but then if you get too many bugs the drawing will be over. If this proves
|
||||
to be a problem simply do:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SIZE=100 CANNIBAL=1 WAIT=-1 GROW=0 ./prog
|
||||
```
|
||||
|
||||
Or something like that (maybe make the size bigger but that's up to you). You
|
||||
could also set the max size to be the highest possible by saying
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
MAXSIZE=-1
|
||||
```
|
||||
|
||||
@@ -556,7 +556,7 @@ too.
|
||||
|
||||
If you're still here you can create this effect like:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WAIT=0 WALLS=1 CANNIBAL=1 ./prog
|
||||
```
|
||||
|
||||
@@ -582,7 +582,7 @@ so with fewer available it has a harder time finding a place in that one line.
|
||||
|
||||
Here's how to make the bug move every time the snake moves:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
CANNIBAL=1 WALLS=1 WAIT=0 EVADE=1 ./prog
|
||||
```
|
||||
|
||||
@@ -591,7 +591,7 @@ Here's how to make the bug move every time the snake moves:
|
||||
|
||||
If you want to see the game 'win' try something like:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
CANNIBAL=1 WALLS=1 WAIT=0 EVADE=1 MAXSIZE=10 ./prog
|
||||
```
|
||||
|
||||
@@ -601,7 +601,7 @@ If you want to see the game 'win' try something like:
|
||||
Here's a fun one I just thought of (a long time after these other modes were
|
||||
thought of):
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WAIT=0 EVADE=1 GROW=-1 SIZE=9 MAXSIZE=10 CANNIBAL=1 ./prog
|
||||
```
|
||||
|
||||
@@ -616,7 +616,7 @@ then the head again (i.e. 1 then 0 in size) and then win! This is also in the
|
||||
|
||||
Of course you can also do something like:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WAIT=5 WALLS=1 CANNIBAL=1 ./prog
|
||||
```
|
||||
|
||||
@@ -635,7 +635,7 @@ of success in catching bugs? Obviously the dimensions will affect this value.
|
||||
|
||||
How long will it take for the snake to run into itself? For instance by doing:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WAIT=0 ./prog
|
||||
```
|
||||
|
||||
@@ -660,7 +660,7 @@ You have a negative shedding growth and a positive growth size: negative and
|
||||
positive winning. Depending on the parameters specified it might go one way over
|
||||
the other. Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SIZE=150 SHEDS=-5 GROW=10 SHED=50 MAXSIZE=250 ./prog
|
||||
```
|
||||
|
||||
@@ -683,7 +683,7 @@ You could also have it so that eating a bug makes you shrink and moving so many
|
||||
moves you grow. I tried this and for me it was far more fun. The [play.sh][]
|
||||
also has this mode:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SIZE=100 SHEDS=5 GROW=-10 SHED=50 MAXSIZE=250 ./prog
|
||||
```
|
||||
|
||||
@@ -705,7 +705,7 @@ snake moving too.
|
||||
|
||||
Anyway this might sound absurd but it can be somewhat hypnotic by doing:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
EVADE=1 CANNIBAL=1 ./prog
|
||||
```
|
||||
|
||||
@@ -721,7 +721,7 @@ the growth size to 0 and then just move the snake round and round eating bugs
|
||||
until you want to quit. You can enable cannibalism so that you don't have to
|
||||
worry about even running into yourself and losing:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
GROW=0 CANNIBAL=1 ./prog
|
||||
```
|
||||
|
||||
@@ -752,13 +752,13 @@ this file discusses as well as allowing to easily change the colours.
|
||||
|
||||
To do this use the [snake-colours][] script like so:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./snake-colours
|
||||
```
|
||||
|
||||
If you want to pass in specific variables you can do that too e.g.:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
CANNIBAL=1 ./snake-colours
|
||||
```
|
||||
|
||||
@@ -777,13 +777,13 @@ you choose uses then the script will override what you pass in.
|
||||
|
||||
To use you can do something like:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./play.sh
|
||||
```
|
||||
|
||||
Or to make it so walls are an obstacle:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WALLS=0 ./play.sh
|
||||
```
|
||||
|
||||
|
||||
+10
-10
@@ -818,13 +818,13 @@ returned. In either case curses is ended.
|
||||
One of these optimisations saved four bytes simply by taking advantage of the
|
||||
value of a loop iterator after the loop. The loop is:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
for (I = 0; A && I < A - 1; ++I)
|
||||
```
|
||||
|
||||
However after the loop I had this:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
A > 1 && q(n[A - 1],e[A - 1], 'o');
|
||||
```
|
||||
|
||||
@@ -847,7 +847,7 @@ the problem.
|
||||
|
||||
First, the function that turns on colours looked like:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
if (h) attron(m(PAIR(L)));
|
||||
else attroff(m(PAIR(L)));
|
||||
```
|
||||
@@ -857,14 +857,14 @@ that the `attroff()` is called first then I could just do an `if (h)` -
|
||||
therefore getting rid of the `else`! But then I thought why not do what I've
|
||||
done elsewhere? I had:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
attroff(m(PAIR(L)));
|
||||
if (h) attron(m(PAIR(L)));
|
||||
```
|
||||
|
||||
But I then saved an extra byte by making it:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
attroff(m(PAIR(L)));
|
||||
h && attron(m(PAIR(L)));
|
||||
```
|
||||
@@ -875,7 +875,7 @@ Second let's look at the `B()` function: there were two things I thought of that
|
||||
would save some bytes (I no longer know how many but a few at least possibly six
|
||||
or even more). I had the following code:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
if (V && U && o) { S(N); b(1); }
|
||||
```
|
||||
|
||||
@@ -886,13 +886,13 @@ called with `1` (thus `o` is 1 so the if is true) was if the bug actually is
|
||||
caught. That means I could remove the `V && U &&` part of the if! Thus it became
|
||||
instead:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
if (o) { S(N); b(1); }
|
||||
```
|
||||
|
||||
Then this
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
!o && V && U && q U,V,' ');
|
||||
```
|
||||
|
||||
@@ -913,7 +913,7 @@ where the snake already is. So if I had to make sure the game had started (the
|
||||
snake has moved at least once) what could I check? In fact that means the
|
||||
direction is not 0! So I could just replace it with:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
!o && D && q *U,*V,' ');
|
||||
```
|
||||
|
||||
@@ -930,7 +930,7 @@ the score line is updated: so the empty space will be overwritten anyway. And if
|
||||
the score line is made an empty string it doesn't matter because it'll appear as
|
||||
all spaces anyway. Thus I could save another three bytes by changing it to:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
!o && q *U,*V,' ');
|
||||
```
|
||||
|
||||
|
||||
+13
-13
@@ -30,7 +30,7 @@ for the capabilities I use in the entry.
|
||||
It also tries to determine the minimum number of columns to play without the
|
||||
status line overflowing - even with the dynamic length. Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ make test
|
||||
```
|
||||
|
||||
@@ -67,7 +67,7 @@ If I pass in any of the variables **GROW**, **MAXSIZE**, **SIZE** and/or
|
||||
**LINES** or **COLUMNS** it bases its calculations on those variables. For
|
||||
example:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
terminal supports cursor movement
|
||||
terminal supports making cursor invisible
|
||||
terminal supports bold
|
||||
@@ -129,7 +129,7 @@ To specify the lines/columns of curses program per instance use the `LINES` and
|
||||
|
||||
For demonstration consider the following:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ echo $LINES $COLUMNS
|
||||
42 157
|
||||
```
|
||||
@@ -139,7 +139,7 @@ include the walls and score line but these values are for the terminal itself.
|
||||
|
||||
Say you want 55 columns:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ COLUMNS=55 ./prog
|
||||
```
|
||||
|
||||
@@ -166,7 +166,7 @@ In my tests there is one thing that at least allows you to see the final score
|
||||
and that is by running `clear` before running the program. That's what the
|
||||
prog.alt version does. You might run it as one of:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
LINES=20 ./prog.alt
|
||||
LINES=20 ./snake.alt
|
||||
```
|
||||
@@ -190,7 +190,7 @@ The Linux man page says:
|
||||
|
||||
If you don't have the reset utility you can try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
echo -e \\033c
|
||||
```
|
||||
|
||||
@@ -209,14 +209,14 @@ along and thinks he/she will be clever and mess with the dimensions a bit. Let's
|
||||
say they have a 13" monitor and they think it'd be funny to see how 997 lines
|
||||
would work; they might try something like:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
LINES=997 ./prog
|
||||
```
|
||||
|
||||
What then? Well expect trouble; curses will not know any better and the max
|
||||
number of lines will be 997. If they were to do:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
COLUMNS=997 ./prog
|
||||
```
|
||||
|
||||
@@ -265,7 +265,7 @@ According to my tests for monochrome terminals the screen has the white and
|
||||
black background; if terminal is configured to be black background white
|
||||
foreground that is the order it is too. You can try that like:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
TERM=linux-m ./prog
|
||||
```
|
||||
|
||||
@@ -301,7 +301,7 @@ Based on the two as well as the fact that monochrome terminals (I've tried under
|
||||
both Linux and macOS) seem to work fine I believe I am fine here too. And to
|
||||
confirm this I wrote the following code with the output below:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
#include <curses.h>
|
||||
|
||||
int main()
|
||||
@@ -314,7 +314,7 @@ confirm this I wrote the following code with the output below:
|
||||
}
|
||||
```
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
TERM=linux-m ./colour_pairs
|
||||
COLORS: 0
|
||||
COLOR_PAIRS: 0
|
||||
@@ -332,7 +332,7 @@ possible colour pairs than I have used so that's not a problem either. Perhaps
|
||||
even it would only be a runtime error if the colours are supported and the
|
||||
number is out of the range? To try and figure this out I did another test:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
int main()
|
||||
{
|
||||
initscr();
|
||||
@@ -351,7 +351,7 @@ number is out of the range? To try and figure this out I did another test:
|
||||
|
||||
Running it like
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
TERM=linux-m ./colour_pairs
|
||||
```
|
||||
|
||||
|
||||
@@ -328,7 +328,7 @@ hit a key every time to move because it is blocking.
|
||||
|
||||
What happens if you do:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WALLS= ./prog
|
||||
```
|
||||
|
||||
@@ -342,20 +342,20 @@ for a number could have a better value than 0.
|
||||
If however you were to give valid input followed by invalid input the valid
|
||||
input would be parsed. For example:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WALLS=1test ./prog
|
||||
```
|
||||
|
||||
would let you go through the walls. On the other hand
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WALLS=test1 ./prog
|
||||
```
|
||||
|
||||
would not. Furthermore if you specify the same variable more than once it's the
|
||||
last one that counts. For example:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WALLS=0 WALLS=1 CANNIBAL=1 CANNIBAL=0 ./prog
|
||||
```
|
||||
|
||||
@@ -414,7 +414,7 @@ If `calloc()` fails to obtain the needed memory you'll see something like (here
|
||||
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):
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ MAXSIZE=-1 ./prog
|
||||
memory error
|
||||
X:0/157 Y:0/42 S:3/18446744073709551614 B:0
|
||||
@@ -428,7 +428,7 @@ 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:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SIZE=1 MAXSIZE=0 ./prog
|
||||
YOU WIN!
|
||||
X:78/156 Y:20/41 S:0/0 B:0
|
||||
|
||||
Reference in new issue
Block a user