|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
If anybody is interested, here's an implementation of a cellular
automaton, Conway's Game of Life, with POV's preprocessing language.
If special_pattern is true, the original pattern is taken from the file
specified by INIT (which must be the same size as the world), with white
pixels as dead cells and black pixels as living cells. If special_pattern
is false, then the initial cells are placed randomly (using seed SEED).
That's all, I hope Pan won't wrap my code, and if you have any question,
ask :)
////////////////////////////
#declare cell_thickness = 0.125;
#declare HEIGHT = 30;
#declare WIDTH = 30;
#declare SEED = 1792;
#declare special_pattern = yes;
#declare STEPS = 100;
#declare INIT="init.png"
////////////////////////////
#declare cell = box
{
<-0.5, 0.0, -0.5>
< 0.5, cell_thickness, 0.5>
texture
{
pigment
{
colour Yellow
}
}
}
#declare init_pattern = function
{
pattern
{
image_pattern
{
png INIT
}
}
}
////////////////////////////
#macro rnd (d)
#declare dec = d - int (d);
#if (dec < 0.5)
#declare ret = int (d);
#else
#declare ret = int (d) + 1;
#end
ret;
#end
#macro evolve () // computes the next state of each cell
#declare new_world = world;
#declare i=1;
#while (i <= HEIGHT)
#declare j=1;
#while (j <= WIDTH)
#declare somme = world[i ][j+1];
#declare somme = somme + world[i ][j-1];
#declare somme = somme + world[i+1][j-1];
#declare somme = somme + world[i+1][j ];
#declare somme = somme + world[i+1][j+1];
#declare somme = somme + world[i-1][j-1];
#declare somme = somme + world[i-1][j ];
#declare somme = somme + world[i-1][j+1];
#if (world[i][j] = 0)
#if (somme = 3)
#declare new_world[i][j] = 1;
#end
#else
#if (somme != 2 & somme != 3)
#declare new_world[i][j] = 0;
#end
#end
#declare j=j+1;
#end
#declare i=i+1;
#end
#declare world = new_world;
#end
#macro show (level)
#declare i=0;
#while (i <= HEIGHT)
#declare j=0;
#while (j <= WIDTH)
#if (world[i][j])
object
{
cell
translate <i-(HEIGHT/2), level*cell_thickness, j-(WIDTH/2)>
texture
{
pigment
{
#if (odd (STEP))
rgbft <STEP/STEPS/2, 1, STEP/STEPS, 0.0, 0.0>
#else
rgbft <1, STEP/STEPS/2, STEP/STEPS, 0.0, 0.0>
#end
}
normal
{
bozo
}
finish
{
reflection 0.25
}
}
}
#end
#declare j=j+1;
#end
#declare i=i+1;
#end
#end
#macro init_world (empty) // initialises the world, if (empty != 0), no cell is
placed
#declare world = array[HEIGHT+2];
#declare i=0;
#while (i <= HEIGHT+1)
#declare j=0;
#declare world[i] = array[WIDTH+2];
#while (j <= WIDTH+1)
#if (i != 0 & i != HEIGHT+1)
#if (j != 0 & j != WIDTH+1)
#if (empty)
#declare world[i][j] = 0;
#else
#declare world[i][j] = rnd (rand (germe) - 0.33);
#end
#else
#declare world[i][j] = 0;
#end
#else
#declare world[i][j] = 0;
#end
#declare j=j+1;
#end
#declare i=i+1;
#end
#end
////////////////////////////
#declare germe = seed (SEED);
init_world (special_pattern)
#if (special_pattern)
#declare i = 0;
#while (i < HEIGHT)
#declare j = 0;
#while (j < WIDTH)
#declare world[i][j] = -init_pattern ((i+0.5)/HEIGHT, (j+0.5)/WIDTH, 0) + 1;
#declare j = j + 1;
#end
#declare i = i + 1;
#end
#end
#declare STEP=0;
#while (STEP < STEPS)
#debug "Placing level "
#debug str (STEP+1, -(log (STEPS) + 1), 0)
#debug "....... "
union
{
show (STEP)
rotate <0, 130, 0>
}
#debug "finished\nComputing next state... " evolve () #debug
"finished\n"
#declare STEP=STEP+1;
#end
////////////////////////////
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Disapointed :-( "odd" is undefined. I'm going to cry, sniff...
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> Disapointed :-( "odd" is undefined. I'm going to cry, sniff...
Same problem here, on POV 3.6
--
KC6ETE Dave's Engineering Page, www.dvanhorn.org
Microcontroller Consultant, specializing in Atmel AVR
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Josh wrote:
> Disapointed :-( "odd" is undefined. I'm going to cry, sniff...
>
>
#include "math.inc"
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> #include "math.inc"
That helps!
--
KC6ETE Dave's Engineering Page, www.dvanhorn.org
Microcontroller Consultant, specializing in Atmel AVR
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On Wed, 08 Sep 2004 14:07:02 +0100, Josh wrote:
> Disapointed :-( "odd" is undefined. I'm going to cry, sniff...
Sorry for that... I forgot the includes section. "math.inc" was the only
one really needed I think. (Anyway this odd() is only used to alternate
colours between levels).
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On Wed, 08 Sep 2004 20:01:09 +0300, Rangifer
<rei### [at] rocketmailcom> wrote:
>Josh wrote:
>
>> Disapointed :-( "odd" is undefined. I'm going to cry, sniff...
>>
Glad it is not just me.
>>
>#include "math.inc"
Doops. It never occured to me to do that.
I wrote my own "odd" macro instead. :D
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On Mon, 06 Sep 2004 22:27:32 +0200, SeeSchloss
<adr### [at] seeschlossorg> wrote:
>If anybody is interested, here's an implementation of a cellular
>automaton, Conway's Game of Life, with POV's preprocessing language.
>
I am having fun with this little .pov
script you wrote. :D Tweaked some
things, used two gradients instead of all
the color calculations.
If you set one of the colors to a pale
yellow, it looks like you've got many
post-its floating in the picture :D
Weeee! Thanks for posting it.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On Fri, 10 Sep 2004 23:08:00 -0400, povray wrote:
> I am having fun with this little .pov script you wrote. :D Tweaked some
> things, used two gradients instead of all the color calculations.
>
> If you set one of the colors to a pale yellow, it looks like you've got
> many post-its floating in the picture :D
>
> Weeee! Thanks for posting it.
Thank you, I'm glad someone likes it :)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |