# Modifying Game of Life code so that the lattice can be seeded with life forms

I want to modify Game of Life code so that the lattice can be seeded with one or two new life forms like:

glider[x_, y_] := {{x, y}, {x+1, y}, {x+2, y}, {x+2, y+1}, {x+1, y+2}}

snake[x_, y_] := {{x, y}, {x, y+1}, {x+1, y}, {x+2, y+1}, {x+3, y+1}, {x+3, y}}


I don't know how to modify my code to put above code! I'd be grateful if you could help.

Here is my code:

Life[n_, t_] :=
Module[{initConfig, Moore, update, LiveConfigs, DieConfigs},

initConfig = Table[Random[Integer], {n}, {n}];

LiveConfigs =
Join[Map[Join[{0}, #] &, Permutations[{1, 1, 1, 0, 0, 0, 0, 0}]],
Map[Join[{1}, #] &, Permutations[{1, 1, 1, 0, 0, 0, 0, 0}]],
Map[Join[{1}, #] &, Permutations[{1, 1, 0, 0, 0, 0, 0, 0}]]];

DieConfigs =
Complement[Flatten[Map[Permutations,
Map[Join[Table[1, {#}], Table[0, {(9 - #)}]] &, Range[0, 9]]], 1], LiveConfigs];

Apply[(update[##] = 1) &, LiveConfigs, 1];
Apply[(update[##] = 0) &, DieConfigs, 1];

Moore[func__, lat_] :=
Map[RotateRight[lat, #] &, {{0, 0}, {1, 0}, {0, -1}, {-1, 0}, {0, 1},
{1, -1}, {-1, -1}, {-1, 1}, {1, 1}}], 2];

FixedPointList[Moore[update, #] &, initConfig, t]]

• Hi ! Please, refer to the help centre and read more about proper code formatting practices. Commented Feb 7, 2015 at 11:00
• It's utterly strange to ignore how to modify your own code. Commented Feb 7, 2015 at 12:26
• @belisarius: I don't think "be ignorant of" is one of the meanings of the verb "ignore"...
– user484
Commented Feb 7, 2015 at 23:50
• @Rahul One of these days I'll have to return to my English class ... Commented Feb 9, 2015 at 4:41

Here's a way to seed the game of life with a glider, using the built-in game of life CellularAutomaton and the OPs glider (starting at 10,10).
glider[x_, y_] := {{x, y}, {x + 1, y}, {x + 2, y}, {x + 2, y + 1}, {x + 1, y + 2}};