Results 1 to 2 of 2

Math Help - Conway's Game of Life: Maple

  1. #1
    Member Haven's Avatar
    Jul 2009

    Conway's Game of Life: Maple

    I'm trying to model Conway's Game of Life and here's my code:

    > f := proc (a, b, c, d, e, f, g, h)
    local alivecount;
    alivecount := b+c+d+e+f+g+h;
    if a = 1 and alivecount < 2 then a := 0
    elif a = 1 and 3 < alivecount then a := 1
    elif a = 0 and alivecount = 3 then a := 1
    end if;
    end proc;
    > run2dca := proc (n::integer, f:: procedure, S0:: (list(list(numeric))), m::integer) local S, x, y, q, i, j;
    S := [S0];
    x := Array(0 .. n-1, 0 .. n-1, S0);
    y := Array(0 .. n-1, 0 .. n-1);
    for q to m do
    for i from 0 to n-1 do
    for j from 0 to n-1 do
    y[i][j] = f(x[i][j], x[i+1 mod n)][j], x[i-1 mod n)][j], x[i][j+1 mod n)], x[i][j-1 mod n], x[i+1 mod n)][j+1 mod n)], x[i+1 mod n)][j-1 mod n)], x[i-1 mod n)][j+1 mod n)], x[i-1 mod n)][j-1 mod n)])
    end do;
    end do;
    S := [op(S), convert(y, list)];
    x, y := y, x
    end do;
    end proc;

    n:= number of rows/columns of the nxn list
    f:= update function
    S0 := 2 dimensional nxn list
    m := number of iterations

    Yet when I try and run my code:
    > BLOCK := [[1,1],[1,1]];
    > run2dca(2,f, BLOCK, 5);

    Error, (in run2dca) bad index into Array
    I get the above error, and I have no idea what it means. Any help would be appreciated

    EDIT: I've narrowed down the error to this line of code, x := Array(0 .. n-1, 0 .. n-1, S0); I have no idea what is wrong thogh
    Last edited by Haven; February 21st 2010 at 11:23 AM.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    May 2010
    I'm also trying to model the Game of Life.
    I've some problems to create a usefull pattern.
    Some ideas:
    -Use of matrixes
    -to create squares and put them in lines and rows

    Has someone some other ideas?
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 0
    Last Post: November 30th 2011, 02:25 PM
  2. Real life problem My life plz help
    Posted in the Math Topics Forum
    Replies: 1
    Last Post: September 30th 2010, 02:44 AM
  3. Help my life is in game
    Posted in the Trigonometry Forum
    Replies: 2
    Last Post: August 18th 2010, 09:59 AM
  4. Sequential-form game (game tree diagram)
    Posted in the Advanced Statistics Forum
    Replies: 0
    Last Post: October 5th 2008, 06:51 PM
  5. THe Conway Polynomial
    Posted in the Advanced Math Topics Forum
    Replies: 4
    Last Post: December 19th 2006, 01:20 PM

Search Tags

/mathhelpforum @mathhelpforum