Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Game of Life

  • 09-11-2008 4:36pm
    #1
    Closed Accounts Posts: 10


    Hi,

    I'm a first year MechEng studet and have an assignment to do based on John Conway's 'Game of Life'. I have to write my own program of 'Game of Life' in Matlab.

    Has anyone done anything like this before? My lecturer is really unclear and i don't know where to start. Any advice, tips, useful links would be really appreciated!

    Thank you


Comments

  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    I don't know anything about matlab but I can give you some general tips that will hopefully apply to matlab as well.

    You will need a 2 dimensional array, this will represent your "grid". Each value in the array will represent an individual cell, 1 if there's a cell there, 0 if there isn't (I'm assuming you'll be using a basic form and not a more complicated one with multiple states).

    You will then need some form of iterative loop (for loop, while loop etc) to loop through each value in the array. Within the loop you need to check the values in cells neighbours, for array(i,j) you would need to check array(i+1,j),array(i+1,j+1),array(i,j+1),array(i-1,j) etc..etc.., compare the results against the rules of the game and update the value of array(i,j) accordingly.

    To do it better again you should use two different arrays, one to hold the current state and then do all your updates against the other one, which becomes the current state in the next run through. This means the values you update don't effect other cells in the same run through.


  • Closed Accounts Posts: 10 Twinkletoes4


    Thank you for your help, that helps :)


Advertisement