IOCC 2014 not winning entries 25/03/2020
In the year of the Lord (of the Ring) 2014 i won two times the IOCCC contest for my [Super Mario Bros Engine]() (aka MARIO) and [ASCII ART Generator]() (aka ART) programs.
These are others three programs that i have created and send to the 2014 contest but, unfortunately, was not winning entries.
Some info extracted from the official DOCS:
This is not another Ray Tracer.
This is a classical 3D Software Rasterizer that supports:
- perspective texture mapping
- gouraud shading
- one light source
- backface culling
- texture color blending
The program reads an infinite list of frame descriptors from stdin and generate an infinite sequence of rendered frames to stdout.
HOW IT WORK
The program starts reading the output resolution from the command line arguments; then reads a raw BGRA texture image from stdin.
The texture format is very simple:
- FIRST BYTE: size of the texture expressed as a power of two (004 means "2^4")
OTHERS BYTE: a list of size*size BGRA pixels. You can generate the raw BGRA image using imagemagick convert, with something like this:
convert INPUT OUTPUT.bgra
After that, the program continue to reading an infinite list of frame descriptor from stdin. Each frame descriptor is encoded in ASCII and contain a list of float values, comma separated:
- 16 float values describing the PROJECTION MATRIX
- 16 float values describing the MODELVIEW MATRIX
- 4 float values describing the position of the LIGHT
a variable length list of float values describing all vertices in the scene. Each vertex is described from 13 values:
X, Y, Z, W, 1, R, G, B, U, V, NX, NY, NZ, 1,
- NX,NY,NZ are the vertex normal
- U,V are the texture coordinates
- R,G,B are the color components
- X,Y,Z are the vertex position in 3d space
The list of float values must terminate with the "E" character. For each 3 vertices the renderer will generate a single triangle.
This is an example of a descriptor for one coloured triangle:
-1.81066, 0, 0, 0, 0, -2.414213, 0, 0, 0, 0, -1.083333, -1, 0, 0, -8.333333, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, -10, 1, 10, 10, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, -1, -1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, -1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, E
This command will generate the same triangle in the file frame.bgra, using a white 2x2 texture:
$ printf "\001\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077\077 -1.81066, 0, 0, 0, 0, -2.414213, 0, 0, 0, 0, -1.083333, -1,0, 0, -8.333333, 0,1, 0, 0, 0,0, 1, 0, 0,0, 0, 1, 0,0, 0, -10, 1, 10, 10, 1, 1, 0, 0, 1, 1,1, 0, 0, 0, 0, -1, -1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, -1, 1, 1, 0, 0, 1, 1, 1, 1, 1,1, 1, 1, 1, 1, 1, E" | ./prog 320 200 > frame.bgra
To convert frame.bgra to JPG you can use this:
convert -size 320x200 -depth 8 frame.bgra frame.jpg
Some shell scripts used to generate the required input data:
Sourcecode (obfuscated, obviously) of the additional tools used to test and prepare the required input data:
INFO extracted from the official DOCS
Obviously this is a SPACE INVADER game. It use NCURSES to get the terminal screen size and handle inputs/outputs.
The program return 0 if the user win or not-zero if the user is A LOSER.
To run the program type
You can move the ship to the LEFT using key A and to the RIGHT using any other key. Use SPACE to shoot a rocket.
The program return 0 if the user win so you can test it and make something usefull (or not), like that:
./prog && echo "you win"
Try the following alias! Every time you type ls you need to beat the aliens to list your files! :D
alias ls="'`pwd`/prog' && ls"
This is The mad SOURCECODE.
INFO extracted from the official DOCS
How small can be a Rubik's cube solver?
This is a Rubik's cube solver.
The program solves a 3x3 Rubik's cube using a modified version of the method "layer by layer" (explained here: http://solvethecube.com/).
This is not a bruteforce solver. One bruteforce solver takes too time to find a solution... This program will find its in the blink of an eye.
The program reads a scramble sequence from stdin and writes the solution to stdout. The program will not solve the cube by reversing the scramble sequence (this would be too simple!!). It uses the method "layer by layer", and is capable of solving any permutation of the cube (one of 43252003274489856000 permutations).
This program works with a cube with a standard color schema.
The program starts with a solved cube. You need to type a sequence of moves to scramble the cube.
You can get a scramble sequence from http://www.jaapsch.net/scramble_cube.htm or use one of these scramble:
L U B2 F' L' R B2 L' R2 F' R F2 D U' B D U' B U F' B2 F' L U' F D' B D2 U2 R' U2 F' U F2 D' U2 B D2 U R' L' R2 D2 U F2 D2 U2 L2 R2 B2 F D B2 U' L2 R2 D' B F' D R U B2 L2 U2 F R'
The starts position of your cube MUST BE with the GREEN FACE on front and the WHITE FACE on top. The scramble sequence MUST NOT include the rotation moves: x, y, z.
You can type the scramble to the program using EOF (CTRL+D) to terminate the sequence, or use a pipe:
$ echo "R U B2 L2 U2 F R'" | ./prog