fix Makefile and README.md for 2011/blakely
This commit is contained in:
1 parent
f53e555cbc
commit
16f8c28e50
2 files changed
+301
-83
No files matched your search
+259
-46
@@ -1,53 +1,163 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# 2011 makefile
|
||||
# IOCCC 2011 winning entry - blakely
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Copyright (C) 2011, Landon Curt Noll, Simon Cooper, and Leonid A. Broukhis.
|
||||
# Regarding individual entries:
|
||||
#
|
||||
# IOCCC winning entry code may not work on your system. Even with standards,
|
||||
# conditions and build environments change, especially when it comes to more
|
||||
# extreme code such you might find in an IOCCC winner. Moreover, what was
|
||||
# allowed and liked in one IOCCC contest may no longer be liked/allowed in
|
||||
# later IOCCC years.
|
||||
#
|
||||
# Corrections on winning author and fixing typos in remarks are VERY WELCOME.
|
||||
#
|
||||
# GitHub pull requests are welcome:
|
||||
#
|
||||
# If you have a patch that might make running an entry work in modern Unix-like
|
||||
# environments, please create a GitHub pull request for the IOCCC judges to
|
||||
# consider.
|
||||
#
|
||||
# Suggestions and corrections regarding Makefiles, winning author information,
|
||||
# fixing typos in remarks, and code patches are welcome via opening a GitHub
|
||||
# issue or better yet, by creating a GitHub pull request for the IOCCC judges
|
||||
# to consider. To form a GitHub issue or GitHub pull, please visit:
|
||||
#
|
||||
# https://github.com/ioccc-src/winner
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# This work by Landon Curt Noll and Leonid A. Broukhis is licensed under:
|
||||
#
|
||||
# Creative Commons Attribution-ShareAlike 3.0 Unported License.
|
||||
#
|
||||
# Creative Commons Attribution-ShareAlike 3.0 Unported License.
|
||||
# See: http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
|
||||
################
|
||||
# tool locations
|
||||
################
|
||||
#############################
|
||||
# shell used by this Makefile
|
||||
#############################
|
||||
#
|
||||
SHELL= bash
|
||||
CP= cp
|
||||
CPP= cpp
|
||||
GUNZIP= gunzip
|
||||
LD= ld
|
||||
MAKE= make
|
||||
RM= rm
|
||||
SED= sed
|
||||
TAR= tar
|
||||
TRUE= true
|
||||
|
||||
# optimization
|
||||
#######################
|
||||
# common tool locations
|
||||
#######################
|
||||
#
|
||||
include ../../var.mk
|
||||
|
||||
# Set X11_LIBDIR to the directory where the X11 library resides
|
||||
#
|
||||
#X11_LIBDIR= /usr/X11R6/lib
|
||||
#X11_LIBDIR= /usr/X11/lib
|
||||
X11_LIBDIR= /opt/X11/lib
|
||||
|
||||
# Set X11_INCLUDEDIR to the directory where the X11 include files reside
|
||||
#
|
||||
#X11_INCDIR= /usr/X11R6/include
|
||||
#X11_INCDIR= /usr/X11/include
|
||||
X11_INCDIR= /opt/X11/include
|
||||
|
||||
# Common C compiler warnings to silence
|
||||
#
|
||||
#CSILENCE=
|
||||
CSILENCE= -Wno-error -Wno-implicit-function-declaration -Wno-logical-op-parentheses \
|
||||
-Wno-unused-parameter
|
||||
|
||||
# Common C compiler warning flags
|
||||
#
|
||||
#CWARN= ${CSILENCE}
|
||||
#CWARN= -Wall ${CSILENCE}
|
||||
#CWARN= -Wall -Wextra ${CSILENCE}
|
||||
CWARN= -Wall -Wextra -pedantic ${CSILENCE}
|
||||
|
||||
# Compiler standard
|
||||
#
|
||||
#CSTD=
|
||||
#CSTD= -ansi
|
||||
CSTD= -std=gnu11
|
||||
|
||||
# Compiler bit architecture
|
||||
#
|
||||
# Some entries require 32-bitness:
|
||||
# ARCH= -m32
|
||||
#
|
||||
# Some entries require 64-bitness:
|
||||
# ARCH= -m64
|
||||
#
|
||||
# By default we assume nothing:
|
||||
#
|
||||
ARCH=
|
||||
|
||||
# Defines that are needed to compile
|
||||
#
|
||||
#CDEFINE=
|
||||
CDEFINE= -Do=char -Dn=return -Dd=int -Dz=memset -Dk=sizeof
|
||||
|
||||
# Include files that are needed to compile
|
||||
#
|
||||
#CINCLUDE=
|
||||
#CINCLUDE= -include stdlib.h
|
||||
#CINCLUDE= -include stdio.h
|
||||
CINCLUDE= -include stdio.h -include string.h -include unistd.h
|
||||
#CINCLUDE= -I ${X11_INCDIR} -I ${X11_INCDIR}/X11
|
||||
#CINCLUDE= `${SDL2_CONFIG} --cflags`
|
||||
|
||||
# Optimization
|
||||
#
|
||||
# Most compiles will safely use -O2. Some can use only -O1 or -O.
|
||||
# A few compilers have broken optimizers or this entry make break
|
||||
# under those buggy optimizers and thus you may not want anything.
|
||||
# Reasonable compilers will allow for -O3.
|
||||
#
|
||||
OPT= -O2
|
||||
#OPT=
|
||||
#OPT= -O
|
||||
#OPT= -O1
|
||||
#OPT= -O2
|
||||
OPT= -O3
|
||||
|
||||
# bitness
|
||||
# Default flags for ANSI C compilation
|
||||
#
|
||||
# Some entries require 32-bitness,
|
||||
# other entries require 64-bitess.
|
||||
# By default we assume nothing.
|
||||
#
|
||||
ARCH=
|
||||
CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT}
|
||||
|
||||
# default flags for ANSI C compilation
|
||||
# Libraries needed to build
|
||||
#
|
||||
CFLAGS= -Wall -ansi -pedantic -Do=char -Dn=return -Dd=int -Dz=memset -Dk=sizeof -include stdio.h -include string.h -include unistd.h ${ARCH} ${OPT}
|
||||
LIBS=
|
||||
#LIBS= -lm
|
||||
#LIBS= -L ${X11_LIBDIR} -lX11
|
||||
#LIBS= `${SDL2_CONFIG} --libs`
|
||||
|
||||
# ANSI compiler
|
||||
#
|
||||
# Set CC to the name of your ANSI compiler.
|
||||
# C compiler to use
|
||||
#
|
||||
CC= cc
|
||||
#CC=clang
|
||||
#CC=gcc
|
||||
|
||||
# Compiler add-ons or replacements for clang only
|
||||
#
|
||||
ifeq ($(CC),clang)
|
||||
#
|
||||
CSILENCE+= -Wno-comma -Wno-error -Wno-implicit-function-declaration \
|
||||
-Wno-implicit-int-conversion -Wno-logical-op-parentheses \
|
||||
-Wno-missing-prototypes -Wno-missing-variable-declarations \
|
||||
-Wno-poison-system-directories -Wno-sign-conversion -Wno-unused-parameter \
|
||||
-Wno-unreachable-code-return
|
||||
#
|
||||
CWARN+= -Weverything
|
||||
#
|
||||
endif
|
||||
|
||||
# Specific add-ons or replacements for gcc only
|
||||
#
|
||||
ifeq ($(CC),gcc)
|
||||
#
|
||||
#CSILENCE+=
|
||||
#
|
||||
#CWARN+=
|
||||
#
|
||||
endif
|
||||
|
||||
|
||||
##############################
|
||||
@@ -55,46 +165,85 @@ CC= cc
|
||||
##############################
|
||||
#
|
||||
ENTRY= blakely
|
||||
PROG= ${ENTRY}
|
||||
#
|
||||
OBJ= ${PROG}.o
|
||||
DATA= 3.dat evolve_to_3.dat t0_3.dat
|
||||
TARGET= ${PROG}
|
||||
#
|
||||
ALT_OBJ=
|
||||
ALT_TARGET=
|
||||
|
||||
|
||||
#################
|
||||
# build the entry
|
||||
#################
|
||||
#
|
||||
all: ${ENTRY} ${DATA}
|
||||
all: data ${TARGET}
|
||||
@${TRUE}
|
||||
|
||||
${ENTRY}: ${ENTRY}.c
|
||||
${CC} ${CFLAGS} ${ENTRY}.c -o ${ENTRY}
|
||||
.PHONY: all alt data everything clean clobber install \
|
||||
love haste waste maker easter_egg sandwich \
|
||||
supernova deep_magic magic charon pluto
|
||||
|
||||
${PROG}: ${PROG}.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LIBS}
|
||||
|
||||
# alternative executable
|
||||
#
|
||||
alt:
|
||||
alt: data ${ALT_TARGET}
|
||||
@${TRUE}
|
||||
|
||||
# data files
|
||||
#
|
||||
data: ${DATA}
|
||||
@${TRUE}
|
||||
|
||||
# both all and alt
|
||||
#
|
||||
everything: all alt
|
||||
|
||||
|
||||
###############
|
||||
# utility rules
|
||||
###############
|
||||
#
|
||||
everything: all alt
|
||||
|
||||
clean:
|
||||
${RM} -f ${ENTRY}.o
|
||||
${RM} -f ${OBJ} ${ALT_OBJ}
|
||||
@-if [ -f indent.c ]; then \
|
||||
echo ${RM} -f indent.c; \
|
||||
${RM} -f indent.c; \
|
||||
fi
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${ENTRY}
|
||||
|
||||
nuke: clobber
|
||||
@echo gnab gib!
|
||||
${RM} -f ${TARGET} ${ALT_TARGET}
|
||||
@-if [ -e sandwich ]; then \
|
||||
${RM} -f sandwich; \
|
||||
echo 'ate sandwich'; \
|
||||
fi
|
||||
|
||||
install:
|
||||
@echo "Surely you're joking Mr. Feynman!"
|
||||
@echo "Dr. Spock says that is not logical!"
|
||||
@${TRUE}
|
||||
|
||||
# backwards compatibility
|
||||
# you may be able to misunderstand the source by reading indent.c
|
||||
#
|
||||
build: all
|
||||
indent.c: ${PROG}.c
|
||||
@if which "${GINDENT}" >/dev/null 2>&1; then \
|
||||
echo ${RM} -f $@; \
|
||||
${RM} -f $@; \
|
||||
echo "${GINDENT} < $< > $@"; \
|
||||
${GINDENT} < $< > $@; \
|
||||
elif which "${INDENT}" >/dev/null 2>&1; then \
|
||||
echo ${RM} -f $@; \
|
||||
${RM} -f $@; \
|
||||
echo "${INDENT} < $< > $@"; \
|
||||
${INDENT} < $< > $@; \
|
||||
else \
|
||||
echo "no intent tool found, ident $< yourself, sorry"; \
|
||||
echo "exit 1"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
|
||||
##################
|
||||
@@ -103,15 +252,79 @@ build: all
|
||||
#
|
||||
love:
|
||||
@echo 'not war?'
|
||||
@${TRUE}
|
||||
|
||||
haste:
|
||||
$(MAKE) waste
|
||||
@${TRUE}
|
||||
|
||||
waste:
|
||||
@echo 'waste'
|
||||
@echo 'haste'
|
||||
@${TRUE}
|
||||
|
||||
maker:
|
||||
@echo 'Participate in a maker faire'
|
||||
@${TRUE}
|
||||
|
||||
easter_egg:
|
||||
@echo you expected to mis-understand this $${RANDOM} magic
|
||||
@echo chongo '<was here>' "/\\oo/\\"
|
||||
@echo Readers shall not be disallowed from being unable to partly misunderstand this final echo.
|
||||
@echo "you expected to often misunderstand this $${RANDOM} magic"
|
||||
@echo "chongo '<was here>' /\\oo/\\"
|
||||
@echo "Eggy"
|
||||
|
||||
sandwich: easter_egg
|
||||
@if [ `id -u` -eq 0 ]; then \
|
||||
echo 'Okay.'; \
|
||||
echo "$${RANDOM}`date +%s`$${RANDOM}" > $@; \
|
||||
else \
|
||||
echo 'What? Make it yourself.'; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
# Understand the history of the Homebrew Computer Club
|
||||
# as well as the West Coast Computer Faire and
|
||||
# you might be confused different. :-)
|
||||
#
|
||||
supernova: sandwich
|
||||
@-if [ -r .code_anal ]; then \
|
||||
${RM} -f .code_anal_v6; \
|
||||
else \
|
||||
echo "planet deniers, like some members of the IAU, are so cute when they try to defend their logic"; \
|
||||
fi
|
||||
@echo "A $@ helps ${MAKE} the elements that help form planets"
|
||||
@${TRUE}
|
||||
|
||||
deep_magic: supernova
|
||||
@-if [ -r .code_anal ]; then \
|
||||
ccode_analysis --deep_magic 7889066cdbdf09b0408021754586e895be641cc9be29e7eafd3ca65359541f17 \
|
||||
--FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \
|
||||
else \
|
||||
echo "Wrong! Do it again!"; \
|
||||
sleep 2; \
|
||||
echo "Wrong! Do it again!"; \
|
||||
sleep 2; \
|
||||
echo "Wrong! Do it again!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
|
||||
magic: deep_magic
|
||||
@-if [ -r .code_anal ]; then \
|
||||
ccode_analysis --level 20003 --mode 5717175 --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \
|
||||
else \
|
||||
echo "If you don't eat yer meat, you can't have any pudding!"; \
|
||||
echo "How can you have any pudding if you don't eat yer meat?!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
|
||||
# The IOCCC resident astronomer states
|
||||
#
|
||||
charon: magic
|
||||
@echo "$@ is a dwarf planet"
|
||||
@echo "dwarf is a type of planet"
|
||||
@echo "therefore IAU, $@ is a planet"
|
||||
|
||||
pluto: charon
|
||||
${MAKE} charon
|
||||
@echo "$@ is a dwarf planet"
|
||||
@echo "dwarf is a type of planet"
|
||||
@echo "therefore, $@ is a planet"
|
||||
@echo "having lots of planets is good feature because supernovae can help ${MAKE} a lot of them"
|
||||
+42
-37
@@ -1,28 +1,33 @@
|
||||
# Most devolving
|
||||
|
||||
Philip Blakely
|
||||
Cambridge, UK
|
||||
<pmblakely@gmail.com>
|
||||
Philip Blakely
|
||||
Cambridge, UK
|
||||
<pmblakely@gmail.com>
|
||||
|
||||
# To build:
|
||||
|
||||
## Judges' comments:
|
||||
### To build:
|
||||
|
||||
make blakely
|
||||
```sh
|
||||
make
|
||||
```
|
||||
|
||||
### To run:
|
||||
|
||||
# Zoom out and make your terminal window 53 or more lines deep
|
||||
./blakely < blakely.c | head -300
|
||||
Zoom out and make your terminal window 53 or more lines deep.
|
||||
|
||||
```sh
|
||||
./blakely < blakely.c | head -300
|
||||
```
|
||||
|
||||
### Try:
|
||||
|
||||
./blakely < 3.dat | head -100
|
||||
./blakely - < 3.dat | head -40
|
||||
./blakely < evolve_to_3.dat | head -55
|
||||
./blakely < t0_3.dat
|
||||
```sh
|
||||
./blakely < 3.dat | head -100
|
||||
./blakely - < 3.dat | head -40
|
||||
./blakely < evolve_to_3.dat | head -55
|
||||
./blakely < t0_3.dat
|
||||
```
|
||||
|
||||
### Selected Judges Remarks:
|
||||
## Judges' comments:
|
||||
|
||||
This program plays Life, computes Pi to 16 digits
|
||||
if given its own source as input, and allows to check if your garden
|
||||
@@ -31,11 +36,13 @@ is a [Garden of Eden](http://en.wikipedia.org/wiki/Garden_of_Eden_%28cellular_au
|
||||
If you have enough time to spare, put the plan of your garden in a text file,
|
||||
and run:
|
||||
|
||||
./blakely - < garden.txt
|
||||
```sh
|
||||
./blakely - < garden.txt
|
||||
```
|
||||
|
||||
## Author's comments:
|
||||
Remarks
|
||||
-------
|
||||
|
||||
### Remarks
|
||||
|
||||
This program uses a well-known algorithm in order to display pi to
|
||||
fifteen decimal places. The source-layout itself demonstrates the importance of
|
||||
@@ -43,15 +50,16 @@ using the correct amount of whitespace in code and the clear superiority of spac
|
||||
|
||||
In order to see the main feature of the code, type:
|
||||
|
||||
./blakely < blakely.c
|
||||
```sh
|
||||
./blakely < blakely.c
|
||||
```
|
||||
|
||||
and wait for about four seconds before using Ctrl-C (or whatever) to end the program. The
|
||||
results are best viewed in a terminal window at least 60 characters
|
||||
high and wide. Alternatively, redirect the output to a separate file
|
||||
(killing when necessary).
|
||||
|
||||
Overview
|
||||
--------
|
||||
### Overview
|
||||
|
||||
The program emulates John Conway's ceullular automaton known as "The
|
||||
Game of Life", using standard input as a starting grid. The layout of
|
||||
@@ -59,14 +67,18 @@ the source-code is such that it evolves to a digital representation of
|
||||
the first 15 decimal places of pi after 4 time steps. This was setup
|
||||
using the other feature of the program which can be demonstrated as follows:
|
||||
|
||||
./blakely - < 3.dat
|
||||
```sh
|
||||
./blakely - < 3.dat
|
||||
```
|
||||
|
||||
The program will first display the grid given in 3.dat, and then three
|
||||
more grids (taking a few minutes to display the last). Waiting for any more grids will
|
||||
take a substantial amount of time. The final grid has been put into
|
||||
evolve\_to\_3.dat, and if you type
|
||||
|
||||
./blakely < evolve_to_3.dat
|
||||
```sh
|
||||
./blakely < evolve_to_3.dat
|
||||
```
|
||||
|
||||
then the 3 will reappear after three time steps.
|
||||
|
||||
@@ -81,8 +93,7 @@ will stop if it is unable to find a grid that will evolve to the
|
||||
current layout correctly. This can be seen with the sample grid
|
||||
t0_3.dat, which evolves backwards by only two time-steps.
|
||||
|
||||
Input file format
|
||||
-----------
|
||||
### Input file format
|
||||
|
||||
The input files must encode a square grid, where a space is a dead
|
||||
cell, and any other character (except a newline) is a living cell. Each line must be the same
|
||||
@@ -91,8 +102,7 @@ designing grids, it may help to type full-stops in place of spaces,
|
||||
and do a global replace afterwards. Any deviation from this format will
|
||||
cause errors in the output.
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
### Limitations
|
||||
|
||||
This is only an approximation to the original Life, as it takes place
|
||||
on a finite grid, with borders that are automatically killed off
|
||||
@@ -108,8 +118,7 @@ seg-fault), but changing the two 9802s to MAX\_SIZE*MAX\_SIZE+1 will
|
||||
solve this, although some reformatting of the
|
||||
code may have to be done to allow larger numbers.
|
||||
|
||||
Compiler warnings/assumptions
|
||||
-----------------------------
|
||||
### Compiler warnings/assumptions
|
||||
|
||||
When compiled with the -Wall -pedantic -ansi options of gcc, some
|
||||
warnings suggesting extra parentheses occur (not necessary for anyone
|
||||
@@ -123,8 +132,7 @@ ASCII based system is required to run it. Also, as mentioned above,
|
||||
any system that uses anything other than a plain '\n' to end a line will cause
|
||||
problems when reading in files.
|
||||
|
||||
Obfuscations
|
||||
------------
|
||||
### Obfuscations
|
||||
|
||||
Given the finely-tuned layout required to evolve into pi, this is one of the
|
||||
main obfuscations used in the code. However, running the code through the
|
||||
@@ -149,8 +157,7 @@ Other obfuscations used are:
|
||||
- Storing a variable whose value could easily be found from another
|
||||
- Use of gotos to emulate a for loop
|
||||
|
||||
Algorithm
|
||||
---------
|
||||
### Algorithm
|
||||
|
||||
The forwards evolution of the grid is straightforward.
|
||||
|
||||
@@ -174,8 +181,7 @@ Since this uses brute-force, it can be very slow. (In fact, the
|
||||
various obfuscations have, at least for the gcc compiler,
|
||||
caused a substantial slowdown.)
|
||||
|
||||
Program layout
|
||||
--------------
|
||||
### Program layout
|
||||
|
||||
The "calculation" of pi was chosen purely because algorithms to find
|
||||
pi are numerous, but the Game of Life is rarely (if ever?) used for
|
||||
@@ -217,11 +223,10 @@ universe.
|
||||
|
||||
The command ./blakely - < blakely.c is therefore *not* recommended.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
<!--
|
||||
### Copyright:
|
||||
|
||||
(c) Copyright 1984-2012, [Leo Broukhis, Simon Cooper, Landon Curt Noll][judges] - All rights reserved
|
||||
This work is licensed under a [Creative Commons Attribution-ShareAlike 3.0 Unported License][cc].
|
||||
|
||||
[judges]: http://www.ioccc.org/judges.html
|
||||
[cc]: http://creativecommons.org/licenses/by-sa/3.0/
|
||||
-->
|
||||
Reference in new issue
Block a user