Conway's Game Of Life


Results 1 to 40 of 46

Threaded View

  1. #29


    Did you find this post helpful? Yes | No

    Default Re: Conway's Game Of Life

    For the big evaluation routine we currently have this giving about 15hz

    Code:
    '----------------------- Also creating a newled data array to be displayed on next generation -------------
    
    FOR counter = 0 TO 1023
    
    	population = 0 :topedge	= 0 :botedge = 0 :lefedge = 0 :rigedge = 0
    
    'Grid Edge Detection
    	
    	IF counter < 32 THEN botedge = 1
    
    	IF counter > 991 THEN topedge = 1
    	
    '*******************************************************************************	  	
    	
        TempCount = Counter & 31
        If TempCount = 0 THEN
        lefedge = 1
        ENDIF
    
    
        IF TempCount = 31 THEN
        rigedge = 1
        ENDIF	
    	
    '*******************************************************************************		
    
    'Grid Evaluation	 
    
    
    CntPlus33 = Counter + 33
    CntPlus32 = Counter + 32
    CntPlus31 = Counter + 31
    CntPlus1 = Counter +1
    
    CntMinus33 = Counter - 33
    CntMinus32 = Counter - 32
    CntMinus31 = Counter - 31
    CntMinus1 = Counter - 1	        	
    	
    	IF led[CntMinus1] > 0 THEN
          IF counter > 0 THEN
    	    Colour[population] = led[CntMinus1]
    		population = population + 1
    	  ENDIF
    	ENDIF
    	
    	IF led[CntPlus1] > 0 THEN
          IF counter < 1023 THEN
    	    Colour[population] = led[CntPlus1]
    		population = population + 1  		
           ENDIF
        ENDIF
    	
    	IF botedge = 0 THEN
    		IF led [CntMinus31] > 0 THEN
    		    Colour[population] = led[CntMinus31]
    			population = population + 1			
    		ENDIF
    		IF led [CntMinus32] > 0 THEN
    		    Colour[population] = led[CntMinus32]  
    			population = population + 1
    		ENDIF
    		IF  rigedge = 0 then
                if led [CntMinus33] > 0 THEN
    		    Colour[population] = led[CntMinus33]
    			population = population + 1
    			endif
    		ENDIF
    	ENDIF
    	
    	IF topedge = 0 THEN
    		IF led [CntPlus31] > 0 THEN
    		    Colour[population] = led[CntPlus31]
    			population = population + 1
    		ENDIF
    		IF led [CntPlus32] > 0 THEN
    		    Colour[population] = led[CntPlus32]
    			population = population + 1
    		ENDIF
    		IF  rigedge = 0 then 
                if led [CntPlus33] > 0 THEN 
    		    Colour[population] = led[CntPlus33]
    			population = population + 1
    			endif
    		ENDIF
    	ENDIF       
    
        lednew[counter] = led[counter]
    	
    	IF led[counter] = 0 THEN
    		IF population = 3 THEN
    		
    		    if Colour[0] = Colour[1] then
    		    lednew[counter] = Colour[0]
    		    
    		    elseif Colour[0] = Colour[2] then
                lednew[counter] = Colour[0]
                
                elseif Colour[1] = Colour[2] then
                lednew[counter] = Colour[1]
                
        	    endif   	
    			
    		ENDIF
    	else   	
    		IF population > 3 OR population < 2 THEN
    			lednew[counter] = 0
    		ENDIF
    			
    	ENDIF
    
    NEXT counter
    Last edited by retepsnikrep; - 23rd May 2020 at 15:20.

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 : 3

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