algorithmic art

Blitz3D Forums/Blitz3D Programming/algorithmic art

Does anybody know how to do this? I want to create random art that looks good and hopefully changes in realtime. Like windows media player and all the random pictures it creates, except just random, not to music.

Any help, advice, or code would be greatly apreciated!

Well use Rand and Rnd functions! (and seedRnd as well) Then do some fancy math, apply it to 2D drawings/3D geometry and it's done! (look in the code archive for a start)

Honestly the question sounds like "How do I program graphic software?" and the answer to this question is certainly not "ask other people to do it", you'll have to learn from the tutorials, the examples or the code archives.

That's a bit harsh LAB, there certainly are algorithms to use in this kind of task, that's what he's asking for (not how to plot pixels etc).

Agreed Jams, LAB little too harsh, this IS a forum after all

there was an amiga example on the forums somewhere, i dont remember where it is yet. i'll search for it

Sorry, but I was not expecting anyone to give me a working program. I just wanted some advice and help. I tried doing this, but have no idea how. I am willing to do as much work as necissary, I just need somewhere to start. I searched for any examples I could find, but could not find any, does anybody know of any?

im not sure if this will be of any use, this is something i found a lot of fun and gave me some idea's later

it was a technique the amiga programmers where fond of a while back. take a look at it see what you think.

its a basic 2D graphics code but again. it could be fun to see it.

http://www.blitzbasic.com/codearcs/codearcs.php?code=711

Thanks! That is kind of cool!

For some inspiration, go to http://www.proce55ing.org , it seems to be the place where most people doing "algorithmic art" or "generative art" are these days. (more the arty side of it)

You can as well search google for visualisation processed with Mathematica, or just read some Wolfram's thoughts about cellular automata.(this is really the mathematics side of it).

Look a bit everywhere for "Perlin Noise", "Fractals", "Game of Life", "Lorenz", "Rossler", "Chua", as theses are mathematical functions they are "easily" converted from any language to BlitzBasic. (keywords)

I was trying to make a cellular automata program, but none of my tests behaved the way other websites said they should. Do you know why? All the code looks right to me.
Const gw=80
Const gh=60
Graphics gw,gh,0,3
SetBuffer BackBuffer()

Dim pixel(gw,gh)
Dim pixel2(gw,gh)

SeedRnd(MilliSecs())
For x=0 To gw
	For y=0 To gh
		temp=Rand(0,1)+Rand(0,1)
		If temp<1 Then pixel(x,y)=1
	Next
Next

For x=0 To gw-1
	For y=0 To gh-1
		pixel2(x,y)=pixel(x,y)
	Next
Next

Delay 2000

While Not KeyDown(1)
LockBuffer BackBuffer()
For x=1 To gw-2
	For y=1 To gh-2
		If pixel2(x,y)=1 Then WritePixelFast x,y,-1
		If pixel2(x,y)=0 Then WritePixelFast x,y,$ff000000
		
		neibors=0
		If pixel(x+1,y+1)=1 Then neibors=neibors+1
		If pixel(x-1,y-1)=1 Then neibors=neibors+1
		If pixel(x+1,y-1)=1 Then neibors=neibors+1
		If pixel(x-1,y+1)=1 Then neibors=neibors+1
		If pixel(x,y+1)=1 Then neibors=neibors+1
		If pixel(x,y-1)=1 Then neibors=neibors+1
		If pixel(x+1,y)=1 Then neibors=neibors+1
		If pixel(x-1,y)=1 Then neibors=neibors+1
		
		If pixel(x,y)=1 And neibors<2 Then pixel2(x,y)=0
		If pixel(x,y)=1 And neibors>3 Then pixel2(x,y)=0
		If pixel(x,y)=0 And neibors=3 Then pixel2(x,y)=1
	Next
Next
For x=0 To gw-1
	For y=0 To gh-1
		pixel(x,y)=pixel2(x,y)
	Next
Next
UnlockBuffer()
If KeyDown(57) Then Delay 500
Flip
Wend
End


It behaves like it should ...
Just a bit modified your code...


Const gw=800
Const gh=600
Graphics gw,gh,0,2
SetBuffer BackBuffer()

Dim pixel(gw,gh)


SeedRnd(MilliSecs())

For x=gw/4 To (gw-gw/4)
	For y=gh/4 To (gh-gh/4)
		temp=Rand(-30,1)
		If temp<0
			pixel(x,y)=0
		Else
		
			pixel(x,y)=temp
		EndIf
	Next
Next


Delay 2000

While Not KeyDown(1)
Cls
SeedRnd(MilliSecs())

LockBuffer BackBuffer()

For y=1 To gh-2
	For x=1 To gw-2
			
		neibors=0
		
		If pixel(x+1,y+1)=1 Then neibors=neibors+1
		If pixel(x-1,y-1)=1 Then neibors=neibors+1
		If pixel(x+1,y-1)=1 Then neibors=neibors+1
		If pixel(x-1,y+1)=1 Then neibors=neibors+1
		If pixel(x,y+1)=1 Then neibors=neibors+1
		If pixel(x,y-1)=1 Then neibors=neibors+1
		If pixel(x+1,y)=1 Then neibors=neibors+1
		If pixel(x-1,y)=1 Then neibors=neibors+1
		
		
		If pixel(x,y)=0 And (neibors=3); Or neibors=6)
			pixel(x,y)=1
		Else If pixel(x,y)=1 And (neibors=2 Or neibors=3)
			pixel(x,y)=1
		Else
			pixel(x,y)=0
		EndIf
		
		If pixel(x,y)=1 Then WritePixelFast x,y,$ffffffff
		If pixel(x,y)=0 Then WritePixelFast x,y,$ff000000
	Next
Next

UnlockBuffer()
Delay 1
If KeyDown(57) Then Delay 500
Flip
Wend
End



Thanks for the reply. I thought my code was right, but here is the code that made me think it is not. It is suposed to be Gosper's Glider Gun (see animation at the top of http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life ), and it works for the first cycle, then it starts going crazy. Do you know why?
Const gw=80
Const gh=60
Graphics gw,gh,0,3
SetBuffer BackBuffer()

Dim pixel(gw,gh)
Dim pixel2(gw,gh)

SeedRnd(MilliSecs())

pixel(1+5,5+5)=1
pixel(1+5,6+5)=1
pixel(2+5,5+5)=1
pixel(2+5,6+5)=1
pixel(11+5,5+5)=1
pixel(11+5,6+5)=1
pixel(11+5,7+5)=1
pixel(12+5,4+5)=1
pixel(12+5,8+5)=1
pixel(13+5,3+5)=1
pixel(13+5,9+5)=1
pixel(14+5,3+5)=1
pixel(14+5,9+5)=1
pixel(15+5,6+5)=1
pixel(16+5,4+5)=1
pixel(16+5,8+5)=1
pixel(17+5,5+5)=1
pixel(17+5,6+5)=1
pixel(17+5,7+5)=1
pixel(18+5,6+5)=1
pixel(21+5,3+5)=1
pixel(21+5,4+5)=1
pixel(21+5,5+5)=1
pixel(22+5,3+5)=1
pixel(22+5,4+5)=1
pixel(22+5,5+5)=1
pixel(23+5,2+5)=1
pixel(23+5,6+5)=1
pixel(25+5,1+5)=1
pixel(25+5,2+5)=1
pixel(25+5,6+5)=1
pixel(25+5,7+5)=1
pixel(35+5,2+5)=1
pixel(35+5,3+5)=1
pixel(36+5,2+5)=1
pixel(36+5,3+5)=1

For x=0 To gw-1
	For y=0 To gh-1
		pixel2(x,y)=pixel(x,y)
	Next
Next

Delay 1000

While Not KeyDown(1)
LockBuffer BackBuffer()
For x=1 To gw-2
	For y=1 To gh-2
		If pixel2(x,y)=1 Then WritePixelFast x,y,-1
		If pixel2(x,y)=0 Then WritePixelFast x,y,$ff000000
		
		neibors=0
		If pixel(x+1,y+1)=1 Then neibors=neibors+1
		If pixel(x-1,y-1)=1 Then neibors=neibors+1
		If pixel(x+1,y-1)=1 Then neibors=neibors+1
		If pixel(x-1,y+1)=1 Then neibors=neibors+1
		If pixel(x,y+1)=1 Then neibors=neibors+1
		If pixel(x,y-1)=1 Then neibors=neibors+1
		If pixel(x+1,y)=1 Then neibors=neibors+1
		If pixel(x-1,y)=1 Then neibors=neibors+1
		
		If pixel(x,y)=1
			If Not(neibors=2 Or neibors=3) Then pixel2(x,y)=0
		Else
			If (neibors=3) Then pixel2(x,y)=1
		EndIf
	Next
Next
For x=0 To gw-1
	For y=0 To gh-1
		pixel(x,y)=pixel2(x,y)
	Next
Next
UnlockBuffer()
Delay 50
Flip
Wend
End


Altough not an expert, your implementation is the basic Conway implementation with 23/3 rule representing 2 states, a cell is living=1 or dead=0. Apparently Gopher's Glider gun requires more states...

Regarding your code everything seems fine, except that you don't need 2 arrays but it doesn't hurt either...

There is an implementation in code archive as well:
http://www.blitzbasic.com/codearcs/codearcs.php?code=912

I think wikipedia has the initial state wrong, or you have copied it incorrectly. Here is an alternative starting state I found on the web.

Const px=10,py=10

Data "Gospers Glider Gun",0,2,0,3,1,2,1,3,8,3,8,4,9,2,9,4,10,2,10,3,16,4,16,5,16,6,17,4,18,5,22,1,22,2,23,0,23,2
Data 24,0,24,1,24,12,24,13,25,12,25,14,26,12,34,0,34,1,35,0,35,1,35,7,35,8,35,9,36,7,37,8,-1,-1
Read pat$,x,y
While x>=0 
pixel(px+x,py+y)=1
Read x,y
Wend


Hey, since you are talking about 2d random art, does naybody know if there is anything on this in the 3d realm of things? I think that would be cool, but I don't know how you would go about doing it? Maybe start with a Pivot entity, and Child pixels to it?

Thanks a bunch DJWoodgate! I finaly had time to look at this and get your code working. Now that I know my cellular automata are working right, how do I make them look cool? (any ideas are welcome)