Skip to content

Problem with the implementation of the game. #1

@zeimusu

Description

@zeimusu

There is a problem with the rules of life implemented here.

I experimented with setting up initial patterns, and they are not evolving as expected.

For example, creating three cells

 cell[5][5].alive, cell[5][5].nextState = true, true
 cell[5][6].alive, cell[5][6].nextState = true, true
 cell[5][7].alive, cell[5][7].nextState = true,true

(and all other cells turned off) should create a "blinker" that has a period 2 oscillation

                    *               
    ***   ->        *       ->    * * *
                    *

I also could not create a "glider".

I suspect there is a mistake with the lines

c.alive = c.nextState
c.nextState = c.alive

It is changing the alive/dead state of the cells at the same time as it is reading them to decide which cells live and which die.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions