Page 2 of 2 FirstFirst 12
Results 21 to 27 of 27
  1. #21
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,662
    Blog Entries
    7
    Rep Power
    21

    Default

    Your logic is incorrect; what happens when col == 0 on line 260? It's the top left edge again.

    kind regards,

    Jos

  2. #22
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  3. #23
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,662
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Fubarable View Post
    Indeed. I guess he ignored my suggestion in post 12?
    I guess the OP did indeed; btw, code like that makes me nauseus; I prefer an extra row at the top and bottom and an extra column both on the left and right that contain 'dead' cells and only test the cells 1 <= r <= rows, and 1 <= c <= cols. That way always all eight neigbours can be tested without those special border cases ...

    kind regards,

    Jos

  4. #24
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Myself, I like borderless but finite grids that are shaped like a torus.
    Last edited by Fubarable; 12-12-2009 at 01:46 PM.

  5. #25
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,662
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Fubarable View Post
    Myself, I like borderless but finite grids that are shaped like a torus.
    Yep and while we're at it, I prefer to stick the living cells in a HashSet (or equivalent) and avoid all the useless calculations in the entire grid. There is an extremely fast "Life" implementation that makes use of this technique plus memoization of (small) sub-configurations. You can never reach that speed with a naive rectangular grid implementation.

    kind regards,

    Jos

  6. #26
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by JosAH View Post
    .... There is an extremely fast "Life" implementation that makes use of this technique plus memoization of (small) sub-configurations.
    Memoization -- a new word for me. And it's not even Dutch. Thanks, Jos.

  7. #27
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,662
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Fubarable View Post
    Memoization -- a new word for me. And it's not even Dutch. Thanks, Jos.
    It's a nice, and quite old, technique where you 'remember' a function value given its parameter value(s); the function has to be 'referential transparent' (look that up ;-) which means that the function should not have side effects and returns the same value given the same parameter values. It can tremendously speed up certain calculations, e.g. a recursive Fibonacci function may take hours to complete but go voooom when memoization is implemented.

    kind regards,

    Jos

Page 2 of 2 FirstFirst 12

Similar Threads

  1. game of life
    By bigskers76 in forum New To Java
    Replies: 10
    Last Post: 12-09-2009, 05:21 AM
  2. 2d array help- Game of Life
    By n3philim in forum New To Java
    Replies: 2
    Last Post: 07-23-2009, 12:01 AM
  3. A more efficient Game of Life
    By unreal4evr in forum New To Java
    Replies: 3
    Last Post: 03-27-2009, 03:08 AM
  4. Game of Life assignment
    By javan00b in forum New To Java
    Replies: 4
    Last Post: 04-28-2008, 05:49 AM

Posting Permissions

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