From 396f92f9b00a783038925f3c136a4b11bf6e2bc8 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 14 Nov 2023 11:17:57 -0800 Subject: [PATCH 1/2] Rename 2019/karns/demo.sh try.sh It was already documented as such (in the thanks file) but it was still the old name (demo.sh). The README.md had demo.sh still but this has been updated as it's all for the try section. --- 2019/karns/Makefile | 6 +++--- 2019/karns/README.md | 2 +- 2019/karns/{demo.sh => try.sh} | 13 +++++++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) rename 2019/karns/{demo.sh => try.sh} (62%) diff --git a/2019/karns/Makefile b/2019/karns/Makefile index 6cb1f6e3f..5677b3f1d 100644 --- a/2019/karns/Makefile +++ b/2019/karns/Makefile @@ -114,7 +114,7 @@ PROG= prog # OBJ= ${PROG}.o CSRC= ${PROG}.o -DATA= maze demo.sh +DATA= maze try.sh TARGET= ${PROG} # ALT_OBJ= @@ -141,8 +141,8 @@ ${PROG}: ${PROG}.c ${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} ${LN} -sf ${PROG} tbfs -test: prog - ${CAT} prog.c | ./prog +test: ${PROG} + ./${PROG} < ${PROG}.c # alternative executable diff --git a/2019/karns/README.md b/2019/karns/README.md index df51ddeb5..257946013 100644 --- a/2019/karns/README.md +++ b/2019/karns/README.md @@ -26,7 +26,7 @@ The last two can be done in a sequence, first showing the respective files at the terminal, like: ```sh -./demo.sh +./try.sh ``` diff --git a/2019/karns/demo.sh b/2019/karns/try.sh similarity index 62% rename from 2019/karns/demo.sh rename to 2019/karns/try.sh index e70d0f521..e8e02483d 100755 --- a/2019/karns/demo.sh +++ b/2019/karns/try.sh @@ -5,8 +5,17 @@ # Doesn't run the program on README.md as it's longer and slower. # -# make prog first and exit if failure -make || exit +# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it +# this way allows us to have the user specify a different compiler in an easy +# way. +if [[ -z "$CC" ]]; then + CC="cc" +fi + +make CC="$CC" all >/dev/null || exit 1 + +# clear screen after compilation so that only the entry is shown +clear # display prog.c to the user echo "$ cat prog.c" From 5a99d745c55a241f059e258d8a17994557b72583 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 14 Nov 2023 11:44:15 -0800 Subject: [PATCH 2/2] Fix infinite loop in 2000/robison w/invalid input If someone entered invalid input (say because they don't know the format yet or because they make a typo or some other reason) their terminal would be flooded with an error message, forcing them to kill the game. This was done in much the same way as the fix for 1987/lievaart. Without this fix the words: Black position and direction: illegal would flood the screen. The Makefile CINCLUDE now has -include stdio.h (not strictly necessary however). Format and typo check README.md. --- 2000/robison/Makefile | 2 +- 2000/robison/README.md | 25 ++++++++++---------- 2000/robison/robison.c | 52 ++++++++++++++++++++++++++++++------------ thanks-for-fixes.md | 14 ++++++++++++ 4 files changed, 65 insertions(+), 28 deletions(-) diff --git a/2000/robison/Makefile b/2000/robison/Makefile index b5c5f627c..17d460fa0 100644 --- a/2000/robison/Makefile +++ b/2000/robison/Makefile @@ -63,7 +63,7 @@ CDEFINE= # Include files that are needed to compile # -CINCLUDE= +CINCLUDE= -include stdio.h # Optimization # diff --git a/2000/robison/README.md b/2000/robison/README.md index eacacaa25..49e4b5747 100644 --- a/2000/robison/README.md +++ b/2000/robison/README.md @@ -12,13 +12,6 @@ make ``` -### Try: - -```sh -echo "Do or do not. There is no try." -``` - - ## Judges' remarks: The program plays almost always reasonably, but does not always detect @@ -33,27 +26,32 @@ author a patent he applied for. :-) ## Author's remarks: + ### TITLE OF INVENTION Highly Compressed Program for Playing Hygienic Checkers + ### FIELD OF INVENTION The present invention generally relates to [checkers](https://en.wikipedia.org/wiki/Checkers). + ### BACKGROUND OF THE INVENTION -Within the field of [checkers](https://en.wikipedia.org/wiki/Checkers), the +Within the field of [Checkers](https://en.wikipedia.org/wiki/Checkers), the problem of finding a hygienic opponent is difficult, as good opponents are peculiar to the tavern habitat of cracker-barrels, pot-belly stoves, tobacco, and spittoons. + ### BRIEF SUMMARY OF THE INVENTION -The present invention plays [checkers](https://en.wikipedia.org/wiki/Checkers) +The present invention plays [Checkers](https://en.wikipedia.org/wiki/Checkers) without spitting. + ### BRIEF DESCRIPTION OF SEVERAL VIEWS OF THE INVENTION FIG. 1 shows a numbering of positions. @@ -64,6 +62,7 @@ FIG. 3 shows a sample board. FIG. 4 shows a method in accordance with the present invention. + ### DETAILED DESCRIPTION OF THE INVENTION Operator plays Black (`x`); the program plays White (`o`). Said Black goes first. @@ -85,7 +84,7 @@ said loser. FIG. 4 shows a C program in accordance with the present invention. Control flow is straightforward: control enters routine `main()`, executes a plurality of -statements, and exits via `return` statement. FIG. 4 presumes that type `int` +statements, and exits via a `return` statement. FIG. 4 presumes that type `int` is `32 bits` and `short` is `16 bits`, which are essential to the preferred embodiment of the invention. FIG. 4 also presumes that the host computer uses ASCII encoding for characters. It should be obvious that practitioners skilled @@ -95,6 +94,7 @@ The disclosure here describes a particular embodiment of the present invention, and other embodiments within the spirit of this disclosure are possible, as well as consumption of spirits while playing. + ### CLAIMS I claim, by letters patently absurd: @@ -110,10 +110,10 @@ I claim, by letters patently absurd: and beta cuts. 3. The method of claim 1, further comprising the step of formatting the - source code with short lines, in order to impress manager with + source code with short lines, in order to impress the manager with high productivity, when measured in lines of code. -4. The method of claim 3, further comprising the step for telling +4. The method of claim 3, further comprising the step for telling the skeptical manager that this is the well-known technique of "linear programming". @@ -129,6 +129,7 @@ I claim, by letters patently absurd: sequence to either sum a plurality of bits in an N-bit word or reverses them, in lg(N) time, depending upon a parameter. + ### DRAWINGS #### FIG 1. diff --git a/2000/robison/robison.c b/2000/robison/robison.c index 0cd09773d..454d655e3 100644 --- a/2000/robison/robison.c +++ b/2000/robison/robison.c @@ -689,22 +689,44 @@ C o& 4) { -o& -1? +char +X1[ +5]= +{'\ +\0'} +,X2 +[5] +={\ +'\0\ +'}; +C o +&1 +){ scanf -("%d" -,& -n) -:( +("%4s" +,X1); +n=at\ +oi(X1); +}else +{X1[ +0]= +'\ +\0' +;X2 +[0] +='\0'; scanf -("%d%d" -,& -m, -&n -), --- -m) -; +("%4s\ +%4s", +X1, +X2); +m= +atoi +(X1); +n= +atoi +(X2) +;--m; Z= A N>> @@ -729,7 +751,7 @@ B, H"{ ; { { } { } { ; } ; { " )) ; -} +}} } else { diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index ba8a1fb13..6335b1a42 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -2304,6 +2304,20 @@ Cody also added the [try.sh](2000/primenum/try.sh) script. Cody added the [try.sh](2000/rince/try.sh) script. +## [2000/robison](2000/robison/robison.c) ([README.md](2000/robison/README.md])) + +Cody fixed an infinite loop that occurred if invalid input was entered, flooding +the screen with: + +``` +Black position and direction: illegal +``` + +This was fixed by having the `scanf(3)` read in a string and then use `atoi(3)` +on it to assign to the `int`s, much like with `1987/lievaart`. The strings are +`char[5]` and the `%` specifier is `%4s` which is enough for the game. + + ## [2000/thadgavin](2000/thadgavin/thadgavin.c) ([README.md](2000/thadgavin/README.md])) Cody fixed the code and added an appropriate make rule so that the SDL version