diff --git a/1993/rince/.gitignore b/1993/rince/.gitignore index 7b03e212b..70de81aee 100644 --- a/1993/rince/.gitignore +++ b/1993/rince/.gitignore @@ -1,4 +1,5 @@ jkb rince rince.orig +rince.alt prog.orig diff --git a/1993/rince/Makefile b/1993/rince/Makefile index 3a8cd3e71..c8c32af76 100644 --- a/1993/rince/Makefile +++ b/1993/rince/Makefile @@ -58,7 +58,7 @@ ARCH= # Defines that are needed to compile # -CDEFINE= +CDEFINE= -DZ=17 # Include files that are needed to compile # @@ -115,8 +115,8 @@ OBJ= ${PROG}.o DATA= TARGET= ${PROG} # -ALT_OBJ= -ALT_TARGET= +ALT_OBJ= ${PROG}.alt.o +ALT_TARGET= ${PROG}.alt ################# diff --git a/1993/rince/README.md b/1993/rince/README.md index df6b21999..fccb1a902 100644 --- a/1993/rince/README.md +++ b/1993/rince/README.md @@ -1,9 +1,6 @@ # Most Well Rounded James Bonfield -MRC Laboratory of Molecular Biology, -Hills Road -Cambridge England @@ -13,6 +10,8 @@ England make all ``` +NOTE: there is an alternate version of this program that allows one to slow down +the game. See the Alternate code section below. ## To run: @@ -21,12 +20,39 @@ make all ``` where: - + `[cabbage]` is a CABBAGE description file (default: `rince.c`) +### Alternate code: slowing down the game + +Some people may want to slow down the game by increasing the +value 17 in the lines: + + +```c +struct timeval v= {0,1<<17} ; +``` + +and + +```c +refresh(),c=select(k,&y,0,0,(v.tv_usec=1<<17,&v))?getch():0; +``` + +to another value like 18 or 19. You can do this via the alternate code like: + + +```sh +make CDEFINE="-DZ=18" clobber alt +``` + +Replace 18 with whatever number you wish. + +Use `rince.alt` as you would `rince` above. + ## Judges' remarks: - + The author has provided several CABBAGE files for your amusement: - [rince.data1](rince.data1) plays @@ -72,7 +98,7 @@ should be replaced with: ```c select(k,&y,0,0,(v.tv_usec=1< +< # > v +< < +< > > < v +X X j +x X j +X x ^ k +^ ^ +^ # +X X X X + +^ v +v v +v # +v X +v x +> # < v +> > +X X l +x X l + +41 20 +######################################## +# # +# < < < < <> < < < # +# > > > <> > > > > # +# < < < < <> < < < # +# > > > <> > > > > # +# < < < < <> < < < # +# > > > <> > > > > # +# # +# # +# # +# # +# # +# # +# # +# # +# # +# # +# X # +########################################*/ +#include +#include +#include +#include +#include +int _tty_ch; +bool _echoit; +bool _rawmode; +int _tty; +#define U char +#define G for( +#define I )malloc(sizeof( + +typedef struct z {U x[20]; struct z*y; } j; j*J[2][256]; +struct timeval v= {0,1<y) { + U*f=t->x; + if (d==f[17]|f[17]==c) { + int i=k&2,u=9,k=1,w=x,_=y,T; + G; + --u||(d-f[8]&&(X[y][x]=f[8]),w---_--,i=0,u=8,k--);) { + _+=P[T=i>u?u:i]-'o'; + w+=P[4+T]-'p'; + if(k) { + if (d-f[i]&&f[i]-X[_][w]) break; + i++; + } else + f[++i+8]-d && (X[_][w]=f[i+8]); +} } } } } } + +jmp_buf E; + +int main(int open, U**exit) { + FILE*C=fopen ( + open-2?__FILE__:*++exit,P+8); + j*t; + volatile int Q,Y=0; + int i,q; d=open-2?'\t':'*'; L: + + Q=0; G; setjmp(E)<256; Q-- + ) + longjmp(E,(J[Y][Q]=0,Q++)); + G; ; ) { + if(!C)return 1; + if('\n'==(c=getc(C))) + if(!Y++)goto L; else + { fscanf(C,"%d %d\n",&i,&q); + X=(U**I P++)*q*(i+1)); + Q=0; G; Qy=J[Y][c]; J[Y][c]=t; + fgets(t->x,20,C); } +} diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index b8dacf403..821319ee3 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -18,7 +18,8 @@ compile with clang, fixing entries to work with macOS (some of which are **very complicated** such as [1998/schweikh1](1998/schweikh1/schweikh1.c)), providing alternate code where useful or necessary, fixing where possible dead links and otherwise removing them, typo and consistency fixes and writing the [sgit -tool](https://github.com/xexyl/sgit) that we've published on the website. Thank +tool](https://github.com/xexyl/sgit) that we installed locally and have used to +easily run `sed` on files in the repository to help build the website. Thank you **very much** for your extensive efforts in helping improve the IOCCC presentation of past IOCCC winners and making many many past entries work with modern systems! @@ -384,7 +385,8 @@ compilers to compile the code, based on the author's remarks. ## [1990/cmills](1990/cmills/cmills.c) ([README.md](1990/cmills/README.md])) -Yusuke got this to work in modern systems (it resulted in a bus error). +Yusuke got this to work in modern systems (it previously resulted in a bus +error). To prevent alarming warnings at linking or runtime Cody made the entry use `fgets()` rather than `gets()`. He notes that another option would have been to @@ -626,7 +628,7 @@ NOTE: as noted in the README.md file and the [bugs.md](/bugs.md), this program a world](https://en.wikipedia.org/wiki/Earth) or just the [USA](https://en.wikipedia.org/wiki/United_States), respectively, without enough args (2). And not that we need the help or anything for this :-) but we do -encourage you to test this :-) This should not be fixed. +encourage you to test this :-) This should NOT be fixed. ## [1993/jonth](1993/jonth/jonth.c) ([README.md](1993/jonth/README.md])) @@ -670,6 +672,10 @@ README.md files for details. Yusuke supplied a patch to get this to work in modern systems. +Cody provided an alternate version to simplify slowing the game down. This was +based on our suggestion that it might be desired to slow down but done in a way +that makes it easy to configure at compile time. See the README.md for details. + ## [1993/schnitzi](1993/schnitzi/schnitzi.c) ([README.md](1993/schnitzi/README.md])) diff --git a/tmp/src/Makefile b/tmp/src/Makefile index cde17fc94..b3ff8c272 100644 --- a/tmp/src/Makefile +++ b/tmp/src/Makefile @@ -44,7 +44,7 @@ CFLAGS= -O3 -g3 --pedantic -Wall # target information # ###################### -TARGETS= winner_name +TARGETS= winner_name ioccc_status ###################################### # all - default rule - must be first # diff --git a/tmp/src/ioccc_status/.gitignore b/tmp/src/ioccc_status/.gitignore new file mode 100644 index 000000000..3617626f6 --- /dev/null +++ b/tmp/src/ioccc_status/.gitignore @@ -0,0 +1 @@ +ioccc_status diff --git a/tmp/src/ioccc_status/Makefile b/tmp/src/ioccc_status/Makefile new file mode 100644 index 000000000..7c2f0aed3 --- /dev/null +++ b/tmp/src/ioccc_status/Makefile @@ -0,0 +1,67 @@ +#!/usr/bin/env make +# +# ioccc_status - quickly update status.json file +# +# Written by Cody Boone Ferguson in 2023 +# +# @xexyl +# https://xexyl.net Cody Boone Ferguson +# https://ioccc.xexyl.net +# +# Share and enjoy! :-) + +############# +# utilities # +############# + +CC= cc +CHMOD= chmod +CP= cp +INSTALL= install +RM= rm +SHELL= bash + +#CFLAGS= -O3 -g3 --pedantic -Wall -Werror +CFLAGS= -O3 -g3 --pedantic -Wall + +###################### +# target information # +###################### + +DESTDIR= ../../bin + +TARGETS= ioccc_status + +###################################### +# all - default rule - must be first # +###################################### + +all: ${TARGETS} + @: + +ioccc_status: ioccc_status.sh + ${RM} -f -v $@ + ${CP} -f -v $? $@ + ${CHMOD} +x $@ + +################################################# +# .PHONY list of rules that do not create files # +################################################# + +.PHONY: all configure clean clobber install + +################################### +# standard Makefile utility rules # +################################### + +configure: + @: + +clean: + @: + +clobber: clean + rm -f ${TARGETS} + +install: all + ${INSTALL} -m 0555 ${TARGETS} ${DESTDIR} diff --git a/tmp/src/ioccc_status/ioccc_status.sh b/tmp/src/ioccc_status/ioccc_status.sh new file mode 100755 index 000000000..607a7bda8 --- /dev/null +++ b/tmp/src/ioccc_status/ioccc_status.sh @@ -0,0 +1,181 @@ +#!/usr/bin/env bash +# +# ioccc_status.sh - quickly update status.json file +# +# Written by Cody Boone Ferguson in 2023 +# +# @xexyl +# https://xexyl.net Cody Boone Ferguson +# https://ioccc.xexyl.net +# +# The script is at this just point a proof of concept but it does work, allowing +# one to update the date of the latest news, the date of the status, the status +# version and the status of the contest. It's not required to update all or for +# that matter any of them. +# +# If that is not clear: it might or might not be needed or desired and that is +# perfectly okay. If it's used but modified that's also okay. It gave me +# something to do and whether or not it's useful it has served a purpose. +# +# If -s option is used, the status field is updated, providing that the status +# arg is either "closed" or "open". +# +# If the -d or -n flags are used then it will update the status_date or +# latest_news fields, respectively. +# +# If the -I status_ver option is used the IOCCC_status_version field will be +# updated. +# +export IOCCC_STATUS_VERSION="0.0.1-0 2023-10-02" # major.minor.release-patch YYYY-MM-DD + +USAGE="usage: $(basename "$0") [-h] [-V] [-v level] [-s status] [-d] [-n] [-i status_ver] status.json + + -h print help and exit + -V print version and exit + -v level set verbosity level + -s status set contest status to open or closed + + NOTE: status must be one of \"open\" or \"closed\" + + -d update status_date + -n update latest_news date + -i status_ver update IOCCC_status_version + + status.json the file to update + +status version: $IOCCC_STATUS_VERSION" + +export UPDATE_DATE="" +export UPDATE_NEWS="" +export UPDATE_IOCCC_STATUS_VERSION="" +export IOCCC_STATUS_VERSION="" +export VERBOSITY=0 +export STATUS_JSON_FILE="" +export STATUS_FLAG="" +export STATUS="closed" # default closed + +# parse args +# +while getopts :hVv:s:dni: flag; do + case "$flag" in + h) echo "$USAGE" 1>&2 + exit 2 + ;; + V) echo "$IOCCC_STATUS_VERSION" 1>&2 + exit 2 + ;; + v) VERBOSITY="$OPTARG"; + ;; + s) STATUS_FLAG="-s" + STATUS="$OPTARG"; + ;; + d) UPDATE_DATE="-d" + ;; + n) UPDATE_NEWS="-n" + ;; + i) UPDATE_IOCCC_STATUS_VERSION="-i" + IOCCC_STATUS_VERSION="$OPTARG" + ;; + :) echo "$0: ERROR: option -$OPTARG requires an argument" 1>&2 + echo 1>&2 + echo "$USAGE" 1>&2 + exit 3 + ;; + *) + ;; + esac +done + +# +# remove the options +# +shift $(( OPTIND - 1 )); +# +# verify arg count +# +if [[ $# -gt 1 ]]; then + echo "$0: ERROR: expected 0 or 1 args, found: $#" 1>&2 + echo "$USAGE" 1>&2 + exit 3 +fi +# +# parse args +# +if [[ $# -gt 0 ]]; then + export STATUS_JSON_FILE="$1" +fi + +# firewall STATUS_JSON_FILE must be a readable file +# +if [[ ! -e $STATUS_JSON_FILE ]]; then + echo "$0: ERROR: status.json does not exist: $STATUS_JSON_FILE" 1>&2 + exit 1 +fi +if [[ ! -f $STATUS_JSON_FILE ]]; then + echo "$0: ERROR: status.json not a file: $STATUS_JSON_FILE" 1>&2 + exit 1 +fi +if [[ ! -r $STATUS_JSON_FILE ]]; then + echo "$0: ERROR: status.json not a readable file: $STATUS_JSON_FILE" 1>&2 + exit 1 +fi + +# check that if -s used that the status ($STATUS) is either 'open' or 'closed' +if [[ -n "$STATUS_FLAG" ]]; then + if [[ "$STATUS" != "open" && "$STATUS" != "closed" ]]; then + echo "$0: ERROR: status must be 'open' or 'closed'" 1>&2 + exit 1 + fi +fi + +if [[ "$VERBOSITY" -gt 1 ]]; then + echo "$0: status.json file: $STATUS_JSON_FILE" 1>&2 + if [[ -n "$STATUS_FLAG" ]]; then + echo "$0: will update contest status to: \"$STATUS\"" 1>&2 + fi + if [[ -n "$UPDATE_DATE" ]]; then + echo "$0: will update status_date to: $(date)" 1>&2 + fi + if [[ -n "$UPDATE_NEWS" ]]; then + echo "$0: will update latest_news to: $(date)" 1>&2 + fi + if [[ -n "$UPDATE_IOCCC_STATUS_VERSION" ]]; then + echo "$0: will update IOCCC_status_version to: $IOCCC_STATUS_VERSION" 1>&2 + fi +fi + +# first status_date if requested +if [[ -n "$UPDATE_DATE" ]]; then + sed -i'' "s|\"status_date\" : \".*[^\"]\"|\"status_date\" : \"$(date)\"|g" "$STATUS_JSON_FILE" + + if [[ "$VERBOSITY" -ge 1 ]]; then + echo "$0: updated status_date to: $(date)" 1>&2 + fi +fi + +# then update latest_news date if requested +if [[ -n "$UPDATE_NEWS" ]]; then + sed -i'' "s|\"latest_news\" : \".*[^\"]\"|\"latest_news\" : \"$(date)\"|g" "$STATUS_JSON_FILE" + + if [[ "$VERBOSITY" -ge 1 ]]; then + echo "$0: updated latest_news to: $(date)" 1>&2 + fi +fi + +# then update IOCCC_STATUS_VERSION if requested +if [[ -n "$UPDATE_IOCCC_STATUS_VERSION" ]]; then + sed -i'' "s|\"IOCCC_status_version\" : \".*[^\"]\"|\"IOCCC_status_version\" : \"$IOCCC_STATUS_VERSION\"|g" "$STATUS_JSON_FILE" + + if [[ "$VERBOSITY" -ge 1 ]]; then + echo "$0: updated IOCCC_status_version to: \"$IOCCC_STATUS_VERSION\"" 1>&2 + fi +fi + +# finally if we need to change the status of the contest do so +if [[ -n "$STATUS_FLAG" ]]; then + sed -i'' "s|\"contest\" : \".*[^\"]\"|\"contest\" : \"$STATUS\"|g" "$STATUS_JSON_FILE" + + if [[ "$VERBOSITY" -ge 1 ]]; then + echo "$0: updated contest status to: \"$STATUS\"" 1>&2 + fi +fi