Format fix 2006/monge/README.md + update bugs.md

This commit is contained in:
Cody Boone Ferguson committed 2023-04-30 09:14:30 -07:00
1 parent 1cb018146d
commit 69d530e978
2 files changed
+71 -64

No files matched your search

+66 -64
View File
@@ -1,15 +1,11 @@
# Best Compiled Graphics # Best Compiled Graphics
Maurizio Monge Maurizio Monge
Department of Mathematics Italy
University of Pisa <maurizio.monge at gmail dot com>
Pisa
Italy
maurizio.monge at gmail dot com
## To build: ## To build:
Make sure you have the SDL1 (not SDL2!) development environment installed. Make sure you have the SDL1 (not SDL2!) development environment installed.
```sh ```sh
@@ -37,11 +33,16 @@ it segfaulted on his MacBook Pro with the M1 chip).
./monge "z = 0" "z = z*z*z + c; Abs2(z) < 4" ./monge "z = 0" "z = z*z*z + c; Abs2(z) < 4"
``` ```
### INABIAF - it's not a bug it's a feature! :-)
Incorrect formulas will ungracefully crash the program.
## Judges' remarks: ## Judges' remarks:
For those who are familiar with the previous IOCCC winners, this program For those who are familiar with the previous [IOCCC winners](/winners.html),
is best described as "1994/tvr meets 2001/bellard". Here you have this program is best described as "[1994/tvr](/1994/tvr/tvr.c) meets
mouse-manipulated fractals AND generated binary code, all in one package. [2001/bellard](/2001/bellard/bellard.c)". Here you have mouse-manipulated
fractals AND generated binary code, all in one package.
A more appropriate award could have been "Best abuse of the A more appropriate award could have been "Best abuse of the
rules", because on a non-x86-based architecture this program rules", because on a non-x86-based architecture this program
@@ -49,7 +50,7 @@ is, quite predictably, a dud.
At the time of judging we were too mesmerized by the graphics At the time of judging we were too mesmerized by the graphics
to realize it; and, after all, this entry does take a special to realize it; and, after all, this entry does take a special
effort to work on both i386 and x86_64. Portable it is! :) effort to work on both `i386` and `x86_64`. Portable it is! :)
## Author's remarks: ## Author's remarks:
@@ -63,103 +64,103 @@ effort to work on both i386 and x86_64. Portable it is! :)
./monge "z = 0" "z = z*z + c; Abs2(z) < 4" ./monge "z = 0" "z = z*z + c; Abs2(z) < 4"
2. Keep clicked with left or right button to zoom in or out. 2. Keep clicking with left or right button to zoom in or out.
3. Use the number pad '+' and '-' to increase/decrease the iteration 3. Use the number pad `+` and `-` to increase/decrease the iteration count when
count when needed. needed.
4. Enjoy, unless you're more interested in trying to understand 4. Enjoy, unless you're more interested in trying to understand how it works. :)
how it works. :)
### Introduction ### Introduction
This is a fractal generator that supports custom formulas and This is a fractal generator that supports custom formulas and real time zoom.
real time zoom. The program needs to be run with two arguments, The program needs to be run with two arguments, the first being a semicolon
the first being a semicolon separated list of assignments to separated list of assignments to do once per pixel, and the second a semicolon
do once per pixel, and the second a semicolon separated list separated list of assignments and conditions that will be executed (and
of assignments and conditions that will be executed (and conditions conditions checked) for each iteration (up to the maximum). Using the left and
checked) for each iteration (up to the maximum). Using the right mouse buttons you will be able to zoom in and out (a la
left and right mouse buttons you will be able to zoom in and [XaoS](https://github.com/xaos-project/XaoS)), the zooming algorithm is a bit
out (a la Xaos), the zooming algorithm is a bit slower than slower than `XaoS`'s but it should give slightly better results.
Xaos's but it should give slightly better results.
Formulas can use all a-z (lowercase) variables, and the special Formulas can use all `a-z` (lowercase) variables, and the special
variables 'c' and 'i' are respectively set by default to the variables `c` and `i` are respectively set by default to the
complex coordinate of the pixel and to the complex imaginary 'i'. complex coordinate of the pixel and to the complex imaginary `i`.
All the constant numbers will be interpreted as real double All the constant numbers will be interpreted as real double values. Each
values. Each expression must be an assignment ([variable] = expression must be an assignment (`[variable] = [expr]`) or a comparison with
[expr]) or a comparison with < or > ([expr1] < or > [expr2]), `<` or `>` (`[expr1] < [expr2]` or `[expr1] > [expr2]`), and you can add spaces
and you can add spaces as you like (as understood by the c as you like (as understood by the C function `isspace()`).
function 'isspace').
Supported operations and functions are: Supported operations and functions are:
Operation | Description Operation | Description
:-------- | :---------- :-------- | :----------
> `+,-,*,/` | Arithmetic operations, priority of `*`,`/` over `+,-` is respected. `+,-,*,/` | Arithmetic operations, priority of `*`,`/` over `+,-` is
> `<,>` | Compares the real parts of two complex numbers (the imaginary part is ignored). Any number of conditions is allowed, the iteration will just stop as soon as one of them fails. respected.
> Abs2 | Calculates the squared norm, ie: `Abs2(a+b*i)` is `(a*a+b*b)+0*i` |
> Re | Extract the real part, ie: `Re(a+b*i) is a+0*i` `<,>` | Compares the real parts of two complex numbers (the imaginary part
> Im | Extract the imaginary part, ie: `Im(a+b*i) is b+0*i` | is ignored). Any number of conditions is allowed, the iteration
> Exp | Calculates the complex exponential, ie `Exp(a+b*i)` is | will just stop as soon as one of them fails.
> `e^a*(cos(b)+sin(b)*i)` `Abs2` | Calculates the squared norm, i.e.: `Abs2(a+b*i)` is `(a*a+b*b)+0*i`.
> Ln | Calculates the principal value of the natural logarithm, ie `Re` | Extract the real part, i.e.: `Re(a+b*i)` is `a+0*i`.
> `Ln(a+b*i)` is `ln(a*a+b*b)/2` + `atan(b/a)*i` `Im` | Extract the imaginary part, i.e.: `Im(a+b*i) is b+0*i`.
`Exp` | Calculates the complex exponential, i.e. `Exp(a+b*i)` is
| `e^a*(cos(b)+sin(b)*i)`
Ln | Calculates the principal value of the natural logarithm, i.e.
`Ln(a+b*i)` is `ln(a*a+b*b)/2` + `atan(b/a)*i`
Here are a few examples of fractals you can draw: Here are a few examples of fractals you can draw:
- Mandelbrot: - Mandelbrot:
./program "z=1" "z=z*z+c; Abs2(z)<4" ./monge "z=1" "z=z*z+c; Abs2(z)<4"
- Mandelbrot (return time variation): - Mandelbrot (return time variation):
./program "z=c" "z=z*z+c; Abs2(z-c)>0.0001" ./monge "z=c" "z=z*z+c; Abs2(z-c)>0.0001"
- Julia, for `c=0.31+i*0.5`: - Julia, for `c=0.31+i*0.5`:
./program "z=c; c=0.31+i*0.5" "z=z*z+c; Abs2(z)<4" ./monge "z=c; c=0.31+i*0.5" "z=z*z+c; Abs2(z)<4"
- Julia (return time variation), `for c=0.31+i*0.5`: - Julia (return time variation), `for c=0.31+i*0.5`:
./program "z=c; c=0.31+i*0.5" "z=z*z+c; Abs2(z-c)>0.0001" ./monge "z=c; c=0.31+i*0.5" "z=z*z+c; Abs2(z-c)>0.0001"
- Newton, for `x^3-1`: - Newton, for `x^3-1`:
./program "z=c" "p=z; z=0.6666*z+0.3333/(z*z); Abs2(p-z) > 0.001" ./monge "z=c" "p=z; z=0.6666*z+0.3333/(z*z); Abs2(p-z) > 0.001"
- Newton-Mandelbrot: - Newton-Mandelbrot:
./program "z=0" "p=z; z=z-(z*z*z + (c-1)*z - c)/(3*z*z+c-1); Abs2(p-z) > 0.001" ./monge "z=0" "p=z; z=z-(z*z*z + (c-1)*z - c)/(3*z*z+c-1); Abs2(p-z) > 0.001"
- Phoenix, Mandelbrot version: - Phoenix, Mandelbrot version:
./program "z=0; q=0" "t=z; z=z*z+Re(c)+Im(c)*q; q=t; Abs2(z)<4" ./monge "z=0; q=0" "t=z; z=z*z+Re(c)+Im(c)*q; q=t; Abs2(z)<4"
- Phoenix, Julia version for `c=0.56667-i*0.5` - Phoenix, Julia version for `c=0.56667-i*0.5`:
./program "z=c; c=0.56667-i*0.5; q=0" "t=z; z=z*z+Re(c)+Im(c)*q; q=t; Abs2(z)<4" ./monge "z=c; c=0.56667-i*0.5; q=0" "t=z; z=z*z+Re(c)+Im(c)*q; q=t; Abs2(z)<4"
### Compilation and portability ### Compilation and portability
This program will only work on x86 (with an x87 FPU) or x86_64 machines, This program will only work on x86 (with an x87 FPU) or x86_64 machines,
and requires the SDL library. but it requires the SDL library.
Another system requirement is the mmap function (as `#define`d Another system requirement is the `mmap()` function (as `#define`d at the
at the beginning of the program). If it is not available the beginning of the program). If it is not available the macro `M(a)` will have to
macro M(a) will have to be replaced with a system dependent be replaced with a system dependent function that allocates readable, writable
function that allocates readable, writable *AND* executable *AND* executable memory (it will not be possible to make this program run on
memory (it will not be possible to make this program run on paranoid systems (like OpenBSD IIRC) that do not allow `rwx` memory).
paranoid systems (like OpenBSD IIRC) do not allow rwx memory).
However I was able to compile and make work the program under However I was able to compile and make work the program under
Linux (Debian/x86 and OpenSuSE/x86_64) and under Cygwin/x86. A Linux (Debian/x86 and openSUSE/x86_64) and under Cygwin/x86. A
friend of mine was able to make it work under macOS too. friend of mine was able to make it work under macOS too.
If you want you can change the window width and height, or the default If you want you can change the window width and height, or the default
number of iterations (that one can be tweaked at runtime, anyway) by number of iterations (that one can be tweaked at runtime, anyway) by
changing the definitions of W, H and I at the beginning of the code. changing the definitions of `W`, `H` and `I` at the beginning of the code.
### Caveats (I just a selected few of them!) ### Caveats (I just a selected few of them!)
@@ -187,25 +188,26 @@ of how all the program works to be worked out).
This program is a formula parser that outputs machine code that This program is a formula parser that outputs machine code that
calculates the formula and check the given conditions. The calculates the formula and check the given conditions. The
machine code targets the x87 stack based FPU, and it is almost machine code targets the x87 stack based
[FPU](https://en.wikipedia.org/wiki/Floating-point_unit), and it is almost
identical for x86 and x86_64 (except for the comparison identical for x86 and x86_64 (except for the comparison
instructions, that have to be generated differently). The instructions, that have to be generated differently). The
program keeps track of the FPU stack (the FPU has a cyclic stack program keeps track of the FPU stack (the FPU has a cyclic stack
of 8 registers) and will automatically swap to and from the of 8 registers) and will automatically swap to and from the
main memory when required (ie, adds instructions to the generated main memory when required (i.e., adds instructions to the generated
machine code to take care of this issue). machine code to take care of this issue).
The formulas are parsed recursively and machine code for the The formulas are parsed recursively and machine code for the
inner iteration loop is also generated. inner iteration loop is also generated.
After generating the machine code, a big event loop creates (or After generating the machine code, a big event loop creates (or
zooms into) the factal executing the generated code when needed, zooms into) the fractal executing the generated code when needed,
and then waits for input events. and then waits for input events.
The zooming algorithm works by remembering for each pixel the The zooming algorithm works by remembering for each pixel the
floating point offset to where the value was actually calculated. floating point offset to where the value was actually calculated.
When zooming, the best match is searched, and if the offset is When zooming, the best match is searched, and if the offset is
too big (>1) the pixel is recalculated. too big (`>1`) the pixel is recalculated.
## Copyright and CC BY-SA 4.0 License: ## Copyright and CC BY-SA 4.0 License:
+5
View File
@@ -1772,6 +1772,11 @@ operators supported.
Don't try dividing by 0 (zero). Don't try dividing by 0 (zero).
## [2006/monge](2006/monge/monge.c) ([README.md](2006/monge/README.md))
## STATUS: INABIAF - please **DO NOT** fix
Incorrect formulas will ungracefully crash the program.
# 2007 # 2007
# 2008 # 2008
# 2009 # 2009