Merge pull request #1501 from xexyl/bf2005
This commit is contained in:
5 files changed
+92
-29
No files matched your search
@@ -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
|
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
|
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?
|
Why?
|
||||||
|
|
||||||
[quines]: https://en.wikipedia.org/wiki/Quine_(computing)
|
|
||||||
|
|
||||||
|
|
||||||
## Author's remarks:
|
## 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.
|
You must not pass any command-line arguments.
|
||||||
|
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* Supports the complete set of 8 BF instructions (`+-<>[].,`).
|
* 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.
|
* Ignores all whitespace (newlines, spaces and tabs) in the input program.
|
||||||
|
|
||||||
|
|
||||||
### Limitations
|
### Limitations
|
||||||
|
|
||||||
Since the program, naturally, uses ints, the calculations must not exceed the
|
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
|
range of an `int`. (But then again, you can use the integer overflow to further
|
||||||
obfuscate your BF programs in creative ways!)
|
obfuscate your BF programs in creative ways!)
|
||||||
|
|
||||||
You are limited to 3125 input integers and 3125 instructions. If you exceed
|
You are limited to 3125 input integers and 3125 instructions. If you exceed
|
||||||
one of these limits, the behaviour is undefined.
|
one of these limits, the behaviour is undefined.
|
||||||
|
|
||||||
|
|
||||||
### Obfuscations
|
### Obfuscations
|
||||||
|
|
||||||
Some of the superficial obfuscations are pretty obvious: I'm using `#define`s to
|
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
|
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.
|
operators to make even the pre-processed code unreadable.
|
||||||
|
|
||||||
However, the more subtle obfuscations relate to the way the program works.
|
However, the more subtle obfuscations relate to the way the program works.
|
||||||
|
|||||||
Executable
+26
@@ -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
@@ -25,13 +25,18 @@ make
|
|||||||
Two alternate versions of this entry, [toledo2.c](toledo2.c) and
|
Two alternate versions of this entry, [toledo2.c](toledo2.c) and
|
||||||
[toledo3.c](toledo3.c) are provided.
|
[toledo3.c](toledo3.c) are provided.
|
||||||
|
|
||||||
To compile these alternate versions:
|
|
||||||
|
### Alternate build:
|
||||||
|
|
||||||
|
To compile the alternate versions:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
make alt
|
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:
|
## 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
|
move analysis via recursion while it executes moves. All while playing
|
||||||
by the rules of C and Chess within a single function!
|
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:
|
## 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
|
limit, but beyond 7 ply is very slow, try it at your own risk and computing
|
||||||
time.
|
time.
|
||||||
|
|
||||||
|
|
||||||
### Entering movements
|
### Entering movements
|
||||||
|
|
||||||
When is your turn, you can enter your move, by example, as `d2d4` and press the
|
When it is your turn, you can enter your move, for example, as `d2d4` and press the
|
||||||
enter key. The computer will check move legality and will warn you of illegal
|
enter key. This will move the pawn at `D2` to `D4`, assuming that a pawn is
|
||||||
moves. All legal chess moves are permitted.
|
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
|
One special case is when you are doing promotion, you must enter the move with
|
||||||
an extra letter indicating the desired piece.
|
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`).
|
knight; substitute `n` for the desired piece (`N`/`Q`/`R`/`B`).
|
||||||
|
|
||||||
Note that the program requires the piece letter; it will not select
|
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.
|
automatically a queen, so don't be surprised if it doesn't accept your move.
|
||||||
|
|
||||||
|
|
||||||
### Game status
|
### Game status
|
||||||
|
|
||||||
The computer will check for checkmate and stalemate. Also, after each machine
|
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
|
move, it will show the score of the position: a higher number is better for
|
||||||
the computer, i.e. worse for you.
|
the computer, i.e. worse for you.
|
||||||
|
|
||||||
|
|
||||||
### Quirks
|
### Quirks
|
||||||
|
|
||||||
None.
|
None.
|
||||||
|
|
||||||
|
|
||||||
### Program operation
|
### Program operation
|
||||||
|
|
||||||
This is a good example of a chess program reduced to the essential. In order
|
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
|
It also sets a standard on ultra-mini-chess programs. The player and the
|
||||||
computer can do all legal chess moves.
|
computer can do all legal chess moves.
|
||||||
|
|
||||||
|
|
||||||
### Additional features
|
### Additional features
|
||||||
|
|
||||||
Other features are:
|
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
|
7-[ply](https://en.wikipedia.org/wiki/Ply_(game_theory))) and even in 5 ply can give a surprise to
|
||||||
amateur players.
|
amateur players.
|
||||||
|
|
||||||
|
|
||||||
### Obfuscation tricks
|
### Obfuscation tricks
|
||||||
|
|
||||||
* Only one very modular C function.
|
* Only one very modular C function.
|
||||||
|
|||||||
+28
-17
@@ -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
|
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.
|
example of a user defined world is submitted with the entry.
|
||||||
|
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
This program is a complete 3D engine with
|
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.
|
* Up to 26 different bitmap textures in a maze.
|
||||||
* Support for animated bitmap textures.
|
* Support for animated bitmap textures.
|
||||||
* Uses default bitmaps in case the configured bitmaps can't be found.
|
* 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.
|
* Configurable window size.
|
||||||
* Navigation using cursor keys (rotate left and right, move forward and
|
* Navigation using cursor keys (rotate left and right, move forward and
|
||||||
backward).
|
backward).
|
||||||
|
|
||||||
|
|
||||||
### Build and Run
|
### 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
|
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.
|
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
|
where:
|
||||||
mapfile - Filename containing a map
|
|
||||||
|
```
|
||||||
|
width - Specifies the width of the window
|
||||||
|
mapfile - Filename containing a map
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Examples
|
#### Examples
|
||||||
@@ -91,31 +98,33 @@ located in the current directory.
|
|||||||
|
|
||||||
Use the cursor keys to navigate through the labyrinth.
|
Use the cursor keys to navigate through the labyrinth.
|
||||||
|
|
||||||
|
|
||||||
### Creating mazes
|
### 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
|
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
|
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:
|
where to position the user. The example below shows how a map file can look:
|
||||||
|
|
||||||
```
|
```
|
||||||
aaaaaaaaaaaaa
|
aaaaaaaaaaaaa
|
||||||
a a
|
a a
|
||||||
a * a
|
a * a
|
||||||
a bbbb cccccccc
|
a bbbb cccccccc
|
||||||
c c
|
c c
|
||||||
cccccccccccccccccccc
|
cccccccccccccccccccc
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The engine loads the map, and creates walls. When a character `a`-`z` is found,
|
The engine loads the map, and creates walls. When a character in the range `a-z`
|
||||||
the engine will load the corresponding texture bitmap. The bitmap file must be
|
is found, the engine will load the corresponding texture bitmap. The bitmap file
|
||||||
named `*.bmp` where `*` is substituted with the letter of the wall in the map.
|
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
|
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
|
located in the same directory as the engine executable (or rather in the
|
||||||
current directory).
|
current directory).
|
||||||
|
|
||||||
|
|
||||||
### Obfuscation
|
### Obfuscation
|
||||||
|
|
||||||
The program is obfuscated in several ways:
|
The program is obfuscated in several ways:
|
||||||
@@ -123,16 +132,18 @@ The program is obfuscated in several ways:
|
|||||||
* Bad use of variables.
|
* Bad use of variables.
|
||||||
* Use of the `?` operator.
|
* Use of the `?` operator.
|
||||||
* Recursive calls to `main()`.
|
* 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
|
* 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 ;) )
|
unreadable (I guess that is not really the intent with indent ;) )
|
||||||
|
|
||||||
|
|
||||||
### Compiler warnings
|
### Compiler warnings
|
||||||
|
|
||||||
There are no compiler warnings when compiling with `-ansi` but there are quite
|
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
|
a few warnings from `lclint`. Mainly because the program is very optimized for
|
||||||
code size.
|
code size.
|
||||||
|
|
||||||
|
|
||||||
### Limitations
|
### Limitations
|
||||||
|
|
||||||
The program only compiles and runs on [X based
|
The program only compiles and runs on [X based
|
||||||
|
|||||||
@@ -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.
|
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))
|
## [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
|
Cody fixed this to compile with some versions of clang which have an additional
|
||||||
|
|||||||
Reference in new issue
Block a user