Conway's Game Of Life


Closed Thread
Results 1 to 40 of 46

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,645


    Did you find this post helpful? Yes | No

    Default Re: Conway's Game Of Life

    last time i played with "life" i never found a way to detect a stable repetitive cycling pattern.
    are you determining if boring stuck patterns ensue ?
    Warning I'm not a teacher

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: Conway's Game Of Life

    Quote Originally Posted by richard View Post
    last time i played with "life" i never found a way to detect a stable repetitive cycling pattern.
    are you determining if boring stuck patterns ensue ?
    Currently i'm using three things.

    1) A simple maximum number of generations reset limit (500). That catches everything.

    2) A simple live cell counter. If it's zero then it resets.

    3) A pseudo checksum which seem to work quite well.

    A word variable to which the address of every populated cell is added, it may overflow many times, and after all 1024 cells have been generated/examined you end up with a number.
    It also calculates the checksum for the next generation and if it matches the previous generation then it probably means we have a stuck pattern and resets.

    I've been testing this for thousands of patterns and generations now and it works well.
    It only falls back on the hard generation limit with huge repeating patterns that cycle over several generations.
    It detects small oscillators and stuck patterns etc quite well.

    I appreciate it is possible for two patterns to have the same checksum but the odds must be very very small.

    Cross post with Richard LOL!! Basically what I'm doing but I'm not quite as clever as the 'Life' experts.
    Last edited by retepsnikrep; - 24th May 2020 at 11:24.

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Conway's Game Of Life

    Thanks Henrick..

    If the array transform only takes call it ~5ms per generation then at 15hz it's using 75ms in a second.
    Roughly equivalent to one extra generation per second. Getting close to not much return for our efforts..

    Do we think we can directly evaluate the Neopixel array with it's weird layout.. ?

    I'm going to set my display up with some timing pins today and have a fiddle about.

    Thanks for all the interesting replies.

  4. #4
    Join Date
    Aug 2011
    Posts
    453


    Did you find this post helpful? Yes | No

    Default Re: Conway's Game Of Life

    To expand a little more on Henrick's last post, this gets it down to 3.51ms:
    Code:
    tLED VAR BYTE
    
    FOR Row = 0 to 31         ' Cycle thru 32 rows
         
        TempW = ROW * 32       ' Precalculate this instead of doing it every time thru the loop
    
        InPtr = TempW
        FOR Col = 0 To 30 Step 2
            tLED = lednew[InPtr]
            led[InPtr] = tLED
            OutPtr = InPtr
            IF tLED > 0 THEN
               NeoLed(OutPtr) = tLED
               alive = alive + 1
               dead = dead + InPtr
            ELSE
                NeoLED(OutPtr) = 0
            ENDIF
            InPtr = InPtr + 2
        NEXT
        
        InPtr = TempW + 1
        FOR Col = 1 To 31 Step 2    ' Odd rows
            tLED = lednew[InPtr]
            led[InPtr] = tLED
            OutPtr = (TempW) + (31-Col)   'Reversed order
            IF tLED > 0 THEN
               NeoLed(OutPtr) = tLED  
               alive = alive + 1
               dead = dead + InPtr
            ELSE
               NeoLED(OutPtr) = 0
            ENDIF
            InPtr = InPtr + 2
        NEXT
    NEXT
    You could get similar reductions in the other sections of code by eliminating multiple evaluations of things like 'led[CntMinus1]'.
    Every time it sees an array access using a variable it has to recompute the value of where it's pointing to.

    If you assign the array value to a temp byte
    Code:
    tLED = led[CntMinus1]
    and use that it saves a bunch of code/time. Obviously that only works for the RHS of an equation or a test, not the LHS.

Similar Threads

  1. programming jumping game
    By bokken in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th February 2012, 06:40
  2. Simon Game
    By flotulopex in forum Code Examples
    Replies: 1
    Last Post: - 4th November 2010, 06:25
  3. EEPROM life expectancy?
    By muddy0409 in forum General
    Replies: 3
    Last Post: - 1st May 2007, 12:44
  4. home brew game console W interface
    By PICMAN in forum General
    Replies: 1
    Last Post: - 15th March 2005, 22:25
  5. Game port to USB adaptor
    By Squibcakes in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 24th September 2004, 03:16

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts