Merge pull request #1501 from xexyl/bf2005

This commit is contained in:
Landon Curt Noll authored and GitHub committed 2023-11-21 15:40:41 -07:00
commit c941b7f38c
5 files changed
+92 -29

No files matched your search

+7 -6
View File
@@ -28,12 +28,10 @@ simple 3-character fix will make it slightly less so.
Quite a few BF programs found on the Net expect byte-based memory, quite a few
exceed the capacity of this interpreter, but there are many that work. Some
small [quines][] work, some don't.
small [quines](https://en.wikipedia.org/wiki/Quine_(computing)) work, some don't.
Why?
[quines]: https://en.wikipedia.org/wiki/Quine_(computing)
## Author's remarks:
@@ -46,6 +44,7 @@ separated by whitespace (this will be the input to the BF program), then a `:`
You must not pass any command-line arguments.
### Features
* Supports the complete set of 8 BF instructions (`+-<>[].,`).
@@ -60,20 +59,22 @@ Use this to obfuscate your BF programs!
* Ignores all whitespace (newlines, spaces and tabs) in the input program.
### Limitations
Since the program, naturally, uses ints, the calculations must not exceed the
range of an int. (But then again, you can use the integer overflow to further
Since the program, naturally, uses `int`s, the calculations must not exceed the
range of an `int`. (But then again, you can use the integer overflow to further
obfuscate your BF programs in creative ways!)
You are limited to 3125 input integers and 3125 instructions. If you exceed
one of these limits, the behaviour is undefined.
### Obfuscations
Some of the superficial obfuscations are pretty obvious: I'm using `#define`s to
make everything look nice and lineal, and the program is merely a recursive
`main` function with only a single `return` statement which uses nested ternary
`main()` function with only a single `return` statement which uses nested ternary
operators to make even the pre-processed code unreadable.
However, the more subtle obfuscations relate to the way the program works.
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 2005/timwi
#
# This only does one thing and that is from the judges. This is because
# brainfuck has too much potential to knacker the brain.
#
# 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
echo "$ (echo \"20 : ,-->+.>+.<<[>[>>+>+<<<-]>[>>+>+<<<-]>"; \
echo "[<+>-]>[<<<+>>>-]>[-]<<<<.<-]\") | ./timwi" 1>&2
(echo "20 : ,-->+.>+.<<[>[>>+>+<<<-]>[>>+>+<<<-]>"; echo "[<+>-]>[<<<+>>>-]>[-]<<<<.<-]") | ./timwi
echo 1>&2
echo "Now please go take better care of your brain. You only get one." 1>&2
+25 -6
View File
@@ -25,13 +25,18 @@ make
Two alternate versions of this entry, [toledo2.c](toledo2.c) and
[toledo3.c](toledo3.c) are provided.
To compile these alternate versions:
### Alternate build:
To compile the alternate versions:
```sh
make alt
```
Use `toledo2` and `toledo3` as you would `toledo` above.
### Alternate use:
Use Use `toledo2` and `toledo3` as you would `toledo` above.
## Judges' remarks:
@@ -41,6 +46,13 @@ Challenge your knowledge of C operator precedence. The following is the
move analysis via recursion while it executes moves. All while playing
by the rules of C and Chess within a single function!
### Historical note:
When this entry was submitted the code was a recursive call to `main()` - that
was it. In 2023 due to problems with `clang` `main()` calls another function,
`pain()`, which calls itself. But it might be said that the Chess is still a
single function.
## Author's remarks:
@@ -74,31 +86,36 @@ And each successive argument will analyze one
limit, but beyond 7 ply is very slow, try it at your own risk and computing
time.
### Entering movements
When is your turn, you can enter your move, by example, as `d2d4` and press the
enter key. The computer will check move legality and will warn you of illegal
moves. All legal chess moves are permitted.
When it is your turn, you can enter your move, for example, as `d2d4` and press the
enter key. This will move the pawn at `D2` to `D4`, assuming that a pawn is
there (as it would be in the beginning). The computer will check move legality
and will warn you of illegal moves. All legal chess moves are permitted.
One special case is when you are doing promotion, you must enter the move with
an extra letter indicating the desired piece.
By example `f7f8n` (supposing you have a pawn on `F7`), will promote it to a
For example `f7f8n` (supposing you have a pawn on `F7`), will promote it to a
knight; substitute `n` for the desired piece (`N`/`Q`/`R`/`B`).
Note that the program requires the piece letter; it will not select
automatically a queen, so don't be surprised if it doesn't accept your move.
### Game status
The computer will check for checkmate and stalemate. Also, after each machine
move, it will show the score of the position: a higher number is better for
the computer, i.e. worse for you.
### Quirks
None.
### Program operation
This is a good example of a chess program reduced to the essential. In order
@@ -115,6 +132,7 @@ they are verified.
It also sets a standard on ultra-mini-chess programs. The player and the
computer can do all legal chess moves.
### Additional features
Other features are:
@@ -126,6 +144,7 @@ Other features are:
7-[ply](https://en.wikipedia.org/wiki/Ply_(game_theory))) and even in 5 ply can give a surprise to
amateur players.
### Obfuscation tricks
* Only one very modular C function.
+28 -17
View File
@@ -39,6 +39,7 @@ through user configured [maps](https://en.wikipedia.org/wiki/Map). User defined
worlds support up to 26 different wall textures that can even be animated. One
example of a user defined world is submitted with the entry.
### Features
This program is a complete 3D engine with
@@ -47,21 +48,27 @@ This program is a complete 3D engine with
* Up to 26 different bitmap textures in a maze.
* Support for animated bitmap textures.
* Uses default bitmaps in case the configured bitmaps can't be found.
* A default map in case no one is specified.
* A default map in case none is specified.
* Configurable window size.
* Navigation using cursor keys (rotate left and right, move forward and
backward).
### Build and Run
Compile the source code and link [x
Compile the source code and link in [X
libraries](https://en.wikipedia.org/wiki/Xlib) if necessary. The program takes
three options which have to be typed in a specific order as described below.
```sh
./vik [-w <width>] [mapfile]
```
Usage: ./vik [-w <width>] [mapfile]
width - Specifies the width of the window
mapfile - Filename containing a map
where:
```
width - Specifies the width of the window
mapfile - Filename containing a map
```
#### Examples
@@ -91,31 +98,33 @@ located in the current directory.
Use the cursor keys to navigate through the labyrinth.
### Creating mazes
A maze consist of a map file and texture bitmap files. The map file is an
A maze consists of a map file and texture bitmap files. The map file is an
ASCII text file where lower case letters represent walls. The letter tells the
engine what bitmap texture file to use. The `*` character lets the engine know
where to position the user. The example below shows how a map file can look:
```
aaaaaaaaaaaaa
a a
a * a
a bbbb cccccccc
c c
cccccccccccccccccccc
aaaaaaaaaaaaa
a a
a * a
a bbbb cccccccc
c c
cccccccccccccccccccc
```
The engine loads the map, and creates walls. When a character `a`-`z` is found,
the engine will load the corresponding texture bitmap. The bitmap file must be
named `*.bmp` where `*` is substituted with the letter of the wall in the map.
The engine loads the map, and creates walls. When a character in the range `a-z`
is found, the engine will load the corresponding texture bitmap. The bitmap file
must be named `*.bmp` where `*` is substituted with the letter of the wall in
the map (note that only `a`, `b` and `c` exist).
So to load the map above, the files `a.bmp`, `b.bmp`, and `c.bmp` should be
located in the same directory as the engine executable (or rather in the
current directory).
### Obfuscation
The program is obfuscated in several ways:
@@ -123,16 +132,18 @@ The program is obfuscated in several ways:
* Bad use of variables.
* Use of the `?` operator.
* Recursive calls to `main()`.
* Bad use of for variables and the comma operator.
* Bad use of `for` loops and the comma operator.
* To make the final obfuscated touch I ran indent which really made the program
unreadable (I guess that is not really the intent with indent ;) )
### Compiler warnings
There are no compiler warnings when compiling with `-ansi` but there are quite
a few warnings from `lclint`. Mainly because the program is very optimized for
code size.
### Limitations
The program only compiles and runs on [X based
+6
View File
@@ -3023,6 +3023,12 @@ how https is set up, in which case just enjoy it for what it was. But there
might be some command line that will let it work that way.
## [2005/timwi](2005/timwi/timwi.c) ([README.md](2005/timwi/README.md]))
Cody added [try.sh](2005/timwi/try.sh). It only has one command as he doesn't
want to knacker his brain any more than it might or might not already be.
## [2005/toledo](2005/toledo/toledo.c) ([README.md](2005/toledo/README.md))
Cody fixed this to compile with some versions of clang which have an additional