Thought provoking program.

Here’s a program that will show a picture of you every instant from before you were born till after you die. In fact it will do that for every person who ever lived, is living, and yet to be born. It will also show every program ever written plus all the programs not yet written. It will show you the answer to every question asked plus those not asked yet. In other words, this program will show you a picture of everything and anything. You’re probably wondering what I’m talking about. Well, this code is set up to show every rgb color combination for every pixel of the display. It assumes the alpha of the color is always 255. Just in case you’re anxious to run this, don’t bother. It will take 6.27 x 10 ^ 4,155,880 years to run this to completion. That’s 461,764 times longer than the existence of the Universe so far. As I said in the title, it’s thought provoking. If you do try to run this, you’ll see the parameter values change, with a red pixel in the lower left corner of the screen when the r value of the parameter.watch gets high. In other words, if you can take a picture of something, it will be shown here at some point in time. Even pictures that can’t be taken will be show here. I think I did all the calculations correct.


supportedOrientations(LANDSCAPE_ANY)

function setup()
    parameter.watch("x")
    parameter.watch("y")
    parameter.watch("rgb")
    img=image(WIDTH,HEIGHT)
    print("It will take 3.2363 days to display all the color combinations for the first pixel.")
    print("It will take 6.279478 x 10^4155880 years for this program to complete.")
    print("The age of Universe is 13.798 x 10^9 years.")
    print("This program will take 461764.44 times longer than the Universe existed so far.")
    print("Dont expect anything usefull from this program anytime soon.")
    x=1
    y=1
    r=0
    g=0
    b=0 
end

function draw()
    background(0)
    img:set(x,y,r,g,b)    
    sprite(img,WIDTH/2,HEIGHT/2)
    r=r+1
    if r>255 then
        r=0
        g=g+1
        if g>255 then
            g=0
            b=b+1
            if b>255 then
                b=0
                x=x+1
                if x>WIDTH then
                    x=1
                    y=y+1
                    if y>HEIGHT then
                        print("done")
                    end
                end
            end
        end
    end
    rgb=string.format("%3d %3d %3d",r,g,b)
end

@Monkeyman32123 I would like to see that pi program if you find it. You can send it to me, I don’t care what language it’s in. That’s part of the fun, converting from one language to another.

@Dave1707 understandable :stuck_out_tongue: it’s the theory that matters more than execution in this case (considering the chunks of time make it pointless to worry about whether it actually does or not). Still quite thought provoking, and I much appreciate your calculations :slight_smile:
If you’re interested, I calculated the total possible combinations of mass and energy arrangements for our observable universe (in other words, the likelihood of a hunk of the infinite universe being the exact same as our observable one, which is a staggeringly large (inconceivably large) number). Of course it’s based on the Planck length being the smallest possible “step” between two locations any particle can take.
And I’ll work on digging up the pi program, I have like 300 google drives now (because I forget passwords a lot) so it may take a bit :stuck_out_tongue:

@Goatboy76 The beauty of mathematics is that I don’t have to argue the point. It either is or isn’t true that pi contains all finite sequences of numbers. Likelihood doesn’t come into it. However, the truth of this isn’t known. Indeed, it isn’t known whether or not pi ends up all 1s and 0s after a point. If it does then it cannot have all finite sequences of numbers.

The decimal that I wrote down is precisely defined. It has a 1 in the n(n+1)/2 th places and 0 everywhere else. So it never, ever has a 2 in it and there are lots of finite sequences that do not appear in its expansion.

@Monkeyman32123 You’re almost correct. After looking at my program in detail, it isn’t doing what I intended it to do. I guess I was trying to get the calculations correct more than the program, since no one would run the program past pixel 1 anyways. The program should iterating thru all the colors for pixel 1, then the red value of pixel 2 would increase by 1 and pixel 1 would then iterate thru all the colors again That would continue until every pixel combination would show and the screen would be all white at the end. In landscape mode with parameters showing, the screen size is 749w x 768h or 575232 pixels. So the current program should take 575232 x 3.2363 days or 1,861,623 days to complete. @Ignatz My calculations were based on the size of the screen in landscape mode with parameters showing or 749w x 768h. The possible colors per pixel is 16,777,216. The total pixels is 749 x 768 or 575232. The total color combination is 16777216 ^ 575232 or 1.18899 x 10 ^ 4155890. Since I do 60 iterations per second, it will take 1.98165 x 10 ^ 4155888 seconds, 3.30275 x 10 ^ 4155886 minutes, 5.50459 x 10 ^ 4155884 hours, 2.293579 x 10 ^ 4155883 days, 6.279478 x 10 ^ 4155880 years. I’m not sure why we’re coming up so different even accounting for the screen size difference.

@Andrew_Stacey Im gonna argue with a mathematician. I’m saying that, while it cant be confirmed, its highly likely that pi contains all possable finaite sequances of numbers. The section 0.0000100000000000010000000001 is a piece of a infinate and irrational number. While this piece doesnt have a 2, it doesnt mean that there cant be one but it doesnt mean that there will either.

@Saturn031000 I’m aware :stuck_out_tongue: that movie is in my top 10 list (book is in the top 5)

Just in case anyone is interested, here is the correct program that I intended to write. I show the r,g,b values for the first 2 pixels. Thanks to @Monkeyman32123 for pointing out that what I wrote initially and what I intended weren’t the same thing. I also changed the code to restart instead of printing done at the end.


supportedOrientations(LANDSCAPE_ANY)

function setup()
    parameter.watch("x1_rgb")
    parameter.watch("x2_rgb")    
    img=image(WIDTH,HEIGHT)
    x,y=1,1
    r,g,b=0,0,0
    img:set(x,y,r,g,b)
end

function draw()
    background(0)    
    sprite(img,WIDTH/2,HEIGHT/2)
    r1,g1,b1=img:get(1,1)
    x1_rgb=string.format("%3d %3d %3d",r1,g1,b1)
    r1,g1,b1=img:get(2,1)
    x2_rgb=string.format("%3d %3d %3d",r1,g1,b1)
    next=true
    while next do
        addRGB()
    end
    img:set(x,y,r,g,b)
    x,y=1,1
    r,g,b=img:get(x,y)
end

function addRGB()
    next=false
    r=r+1
    if r>255 then
        r=0
        g=g+1
        if g>255 then
            g=0
            b=b+1
            if b>255 then
                b=0
                img:set(x,y,0,0,0)
                x=x+1
                if x>WIDTH then
                    x=1
                    y=y+1
                    if y>HEIGHT then
                        restart()
                    end
                end
                r,g,b=img:get(x,y)
                next=true
            end
        end
    end
end

@GoatBoy76 Re Pi. Not true. It’s not known how random the digits of pi are. Just because a number has an infinite decimal doesn’t mean that every pattern will occur in it. Even an irrational isn’t guaranteed to have this property. For example: 0.101001000100001000001… is irrational but never has a 2 in it.

@Saturn031000, that could only take 42 frames, depending how you look at it :stuck_out_tongue:

@Monkeyman32123 — Point taken, but I was referring to the Hitchhiker’s Guide to the Galaxy, in which the meaning of life is 42. (I have no clue how, don’t ask me). :stuck_out_tongue:

@Dave1707 lol! you are turning Mystical!

@dave1707 Spoooooooooky! This is similar to my Pi idea. Because Pi is infinate with no pattern, every thing that has ever been or will ever be is in a number code in Pi. Everything including the “magical” program that acts as a directory to find things in Pi

I made an error in one of my calculations. When I said the program will take 461,764 times longer that the Univers was in existence, I was wrong. When working with exponents and you do a division, you don’t divide the exponents, you subtract them. So this program will take (4155880 - 9) or 10 ^ 4,155,871 times longer than the Universe existed. I guess Apple better get to work on a better battery for my iPad if I’m going to run this to completion.

Once pixel one is done iterating over all of the possible combinations it then moves on to pixel two, but while pixel two is going, pixel one doesn’t reiterate over its possible combinations for every possible combination of pixel two (and so on). This means the calculation will actually only take approximately 2,550,000 days, and, unfortunately, the result will be a bunch of white pixels while the current one is iterating, and thus no life solutions or hidden messages (I have an equal fascination with the concept of near-infinity, and so I couldn’t help point this out). Unless, of course, I overlooked something (which I don’t put out of the question).
And on the subject of infinity, I made a program that calculates digits of pi infinitely that I could dig up from the depths of my google drive, somewhere

EDIT: that said, love both the program and the concept :slight_smile:

@dave1707, I get a different answer

3.2363 days per pixel

1024 x 768 = 786432 pixels on our fullscreen Codea display

so 3.2363^786432 in total

to convert to base 10, take log(3.2363) = 0.51

ie 10^401118 days

universe has been going about 13.8 x 10^9 x 365 days

so give or take about 10^401109 x age of universe

a bit smaller than your estimate

@Andrew_Stacey While were on this topic, where the daily responsibilities of a mathematician?

@Saturn031000 yes it is.

@Andrew_Stacey — Off-topic, is MathOverflow related to StackOverflow?

@Ignatz Maybe my next update should save its last position so that we won’t have to start over. Maybe I should save all the images too so we don’t lose them. I wonder how much memory that would take. I have a feeling there wouldn’t be enough space in the Universe to hold them all.