Programming Game of Life

0 favourites
  • 2 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • Hi everyone, I'm going through the exercise of programming Conway's Game of life.

    My current issue is that I have syntax that makes a lot of sense to me, and seems like it's correct other than no looping prevention, but nothing actually changes in my instance variables when I run the debug.

    My current goal is to be able to add 1 to an instance variable neighbors for every tile that is alive and adjacent to the original tile being checked.

    My code is as following:

    If the tile that is overlapping (original tile position)+n is alive, then add 1 to Original tile Neighbors.

    do this in all directions. (x+32,x-32,y+32, etc.)

    Right now it's setup to only do this for the first tile, but it seems to be doing nothing.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I think the main issue has to do with the picking. The way it works is things are picked from things already picked. So you pick one cell and then try to pick another and it can’t.

    One way to rearrange the logic is to just pick the neighbor cells one by one and adding to a local variable, and then picking the cell itself and setting its neighbors instance variables then.

    function checkNeighbors(x, y)

    {

    Local number count=0

    If Pick cell at (x+32, y) and cell.frame=1

    Then add 1 to count

    If Pick cell at (x-32, y) and cell.frame=1

    Then add 1 to count

    ... so on for the other directions

    If pick cell at (x,y)

    Then set cell.neighbors to count

    }

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)