Why won't my CA work?

I'm trying to implement a simple cellular automata in processing and I've run into a strange problem. My code is here. I have a methods that change the state of two arrays, currentArray and nextArray, but for some reason I am having trouble changing the values in the array. I run the program and any changes I make don't seem to stick. Is this some sort of scope problem? I'd appreciate any help you can offer.

Answers

  • where's case "110"?

  • Ah, one of those 100's was supposed to be 110. That doesn't fix it though.

  • the usual problem, you are updating the same array as you are checking...

    in automataGuts()

    String onTick = tick(currentArray[i]);
    ...
    currentArray[i] = nextArray[i];
    

    do the update in a separate loop after you've worked out all of nextArray[].

  • what's the algorithm your are trying to implement?

    your code has exactly 0 comments. you are making it very hard for us (and for future you).

  • Putting the currentArray=nextArray in a separate loop didn't fix it. After testing I'm pretty sure it's problem with updating the array's contents themselves but I can't figure out what. Also, I tried to commend it better.

Sign In or Register to comment.