Results 1 to 3 of 3
  1. #1
    andy_d is offline Member
    Join Date
    Oct 2013
    Posts
    4
    Rep Power
    0

    Default Making this code more efficient...

    So I've been reviewing my assignments from last semester and the one thing I wish the TA would have done is provided his solution to the assignments. My program works but it's not clear to me how efficient the code really is. This was the assignment...

    Detail

    And this was is my code...

    https://github.com/andyd0/JavaCode/blob/master/Game

    I understand the code is lengthy so not sure what to expect in terms of help but figured I'd give it a try.

  2. #2
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: Making this code more efficient...

    Hi,

    One thing I saw:
    The borders are always empty so there is no reason to check these when doing a comparison or checking in isempty.

    With Kind regards,

    Konrad

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

    Default Re: Making this code more efficient...

    Also: only living cells and cells next to a living cell have the opportunity to change in the next generation; you only need to check those cells (which is the minority in normal circumstances). A naive implementation that uses (and checks) all cells in a matrix, will be much slower than a set of coordinates of 'living' cells.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Finished Code - More Efficient Way?
    By AlexGraal in forum New To Java
    Replies: 2
    Last Post: 01-07-2014, 05:31 PM
  2. Replies: 14
    Last Post: 06-13-2013, 06:19 PM
  3. Need help making program more efficient
    By cid in forum New To Java
    Replies: 4
    Last Post: 06-30-2010, 07:22 PM
  4. Replies: 1
    Last Post: 03-22-2010, 08:21 AM
  5. How to write efficient maintainable code.
    By Zosden in forum Advanced Java
    Replies: 9
    Last Post: 05-01-2008, 04:48 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
  •