+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Langton's Ants - TalkingGoose

  1. #11
    No u Divran's Avatar
    Join Date
    Jul 2008
    Location
    Sweden
    Posts
    4,582

    Default Re: Langton's Ants - TalkingGoose

    I thought this looked awesome so I made one for the digital screen.

    Features:
    • Maximum size is 512x512 pixels. You can set it to any resolution.
    • Fully customizable colors and their directions!
    • Extreme speed

    Code:
    Code:
    @inputs E:wirelink
    @persist [Pos Dir]:vector2 [Colors Dirs Cells]:array Res
    if (first()|~E) {
        Res = 128
        E[1048572] = Res
        E[1048573] = Res
        
        #Colors
        Colors[1,number] = 900
        Colors[2,number] = 999
        #Colors[3,number] = 90
        #Colors[4,number] = 9
        
        #Directions (1 right, -1 left, 0 forward, 2 turn around)
        Dirs[900,number] = -1
        Dirs[999,number] = 1
        #Dirs[90,number] = 0
        #Dirs[9,number] = 2
        
        Pos = vec2(Res/2,Res/2)
        Dir = vec2(0,1)
        
        if (!->E) {
            print("Screen not wired. Waiting...")
            exit()
        } else {
            print("Screen wired. Animating...")
        }
        
        runOnTick(1)
    }
    
    while(perf()) {
        Pos+=Dir
        PosN = Pos:x()+Pos:y()*Res
        CurColor = Cells[PosN,number]
        if (CurColor == 0) { #If this is the first time for this cell
            CurDir = Dirs[Colors[1,number],number]
            CurColor = Colors[1,number]
        } else {
            foreach(K,V:number = Colors) {
                if (CurColor == V) {
                    if (K == Colors:count()) {
                        CurColor = Colors[1,number]
                    } else {
                        CurColor = Colors[K+1,number]
                    }
                    CurDir = Dirs[V,number]
                    break
                }
            }
        }
        if (CurDir != 0) {
            Dir = round(Dir:rotate(CurDir*90))
        }
        Cells[PosN,number] = CurColor
        E[PosN] = CurColor*1000
        if (!inrange(Pos,vec2(),vec2(Res,Res))) {
            runOnTick(0)
            print("Filled.")
            exit()
        }
    }
    Video:


    Updated.
    Made the E2 wait for you to wire up the wirelink before starting the animation (or whatever you'd like to call it) so you don't have to refresh the E2 right after wiring it.

    TalkingGoose, I joined the server you were in, but you were AFK. I waited for as long as I could but I have to go now
    Wanted to show you my accomplishment :/
    Last edited by Divran; 08-27-2010 at 08:26 AM.
    SVN Tutorial
    My SVN:
    Code:
    http://divranspack.googlecode.com/svn/trunk/%20divranspack/
    Get dropbox and get 250 MB extra space: Dropbox

  2. #12
    Wire Noob TalkingGoose's Avatar
    Join Date
    Jan 2010
    Posts
    18

    Default Re: Langton's Ants - TalkingGoose

    Yeah, Sorry about that, Had a few things to do around the house and I left my Pc on.

    But, Yeah, That is awesome! I couldn't get the digital screen to work very well with my method, your way is a lot better.

    Just about to try it out real quick before I go to bed.

    +Rep.

    Wow... That's amazing!

    I really like it. <3

  3. #13
    billywitchdoctor.com Whosdr's Avatar
    Join Date
    Dec 2008
    Posts
    2,300

    Default Re: Langton's Ants - TalkingGoose

    So this is the reason for learning how to use a digital screen.
    .siht daer ot gniyrt emit detsaw ev'uoY

+ Reply to Thread
Page 2 of 2 FirstFirst 12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots