Skip to main content

Timeline for Conway's Game of Life in JavaScript

Current License: CC BY-SA 3.0

18 events
when toggle format what by license comment
Jan 8, 2014 at 11:45 vote accept SaggingRufus
Jan 8, 2014 at 1:31 comment added Superbest This is a very good answer which touches on several key thing in programming that beginners often end up learning the hard way (I know I did). It might be wroth mentioning that the trick with deferring updates is an example of double buffering, with the issue arising from use of only a single buffer (the buffer here is the array which stores the board). Also, personally I like to use the modulo trick, combined with an if (within_bounds(x, y)) kind of conditional to handle edges and corners.
Jan 8, 2014 at 0:08 comment added David Conrad @rolfl Ah, thanks, and thanks for the link.
Jan 8, 2014 at 0:02 comment added rolfl @David, Google's Javascript style guide recommends against it (not supported in IE).
Jan 8, 2014 at 0:00 comment added David Conrad You might be able to get away with using const DIMENSION, instead of var, but I'm not certain how widespread the support for it is yet.
Jan 7, 2014 at 21:41 comment added Dave Jarvis @rolfl: Ah! I misunderstood the implications of what you wrote. Thanks for the update. :-)
Jan 7, 2014 at 19:19 comment added rolfl @DaveJarvis that is correct, and it is not supposed to. DIMENSION is 30, and since the array index is 0-based, the largest value we ever want is 29. We want to generate values from 0 to 29 inclusive, so Math.floor(Math.random() * 30) is what we want to do (Note DIMENSION is 30, and not 29 like you have in your JFiddle)
Jan 7, 2014 at 18:54 comment added SaggingRufus Thanks! this is by far the most helpful to date. The only reason I made the whole board is so that I could visualise my starting bacteria for the runs where I comment out the auto generate. I also realize that would never hit 29 in the random number generator. I figured that it wouldnt matter becausea full board would just revert to an empty board next turn. I really like the buddy idea! Thanks again!
Jan 7, 2014 at 16:39 comment added rolfl @default.kramer - thanks, and I changed the formatting to make it 'obvious'
Jan 7, 2014 at 16:38 history edited rolfl CC BY-SA 3.0
Incorporate changes suggested by default.kramer, AJMansfield, and Danny
Jan 7, 2014 at 16:34 comment added default.kramer There are some typos in the buddy table, for example [0,-1] appears twice.
Jan 7, 2014 at 16:32 comment added rolfl @AJMansfield - copy-paste from the OP's code. There is no other reason... will edit.
Jan 7, 2014 at 16:31 comment added AJMansfield Also, why is there a +0 in Math.floor((Math.random()*dimension)+0);?
Jan 7, 2014 at 16:29 comment added AJMansfield You don't have to actually process the entire board before writing the values back; There's a way to do it where you store a row's values in an array and use that array to get the old values when computing the next row.
Jan 7, 2014 at 14:38 history edited rolfl CC BY-SA 3.0
Noticed big bug in code.
Jan 7, 2014 at 14:17 history edited rolfl CC BY-SA 3.0
Fix for issues with mis-reading version of CGOL
Jan 7, 2014 at 14:02 history edited rolfl CC BY-SA 3.0
Somehow had index 3 instead of index 1 ... hmmmm
Jan 7, 2014 at 13:52 history answered rolfl CC BY-SA 3.0