Anyways...
I'm not certain if anyone here has heard of Mathematica, but it is simply a great program.
Stephen Wolfram, founder of Wolfram Research, created Mathematica, a program who's purpose knows no bounds. For a link to this program, please look here:
http://www.wolfram.com/mathematica/
I have recently spent many hours attempting to learn the coding of Mathematica through watching lectures and by creating code for assignments online. Who knew that programming, even as basic as Mathematica, could be so difficult.
At this point, I'm not really sure what the purpose of this blog is, I fear that it is merely to write about useless things and elaborate on them by adding useless details.
I guess I open this blog for people to discuss, if they have heard about Mathematica, and what are their thoughts about it. ^_^
If you want to see something cool, import this line of code into your program!
The code is inside the spoiler and kudos to the person who realizes what this is a reference too, the code that is. Hint: Some of the assigned variable names allude to it.
Also there will be a warning when inputting it into Mathematica, disregard it.
+ Show Spoiler +
http://e.isabio.com/SR100/GameOfLifeStartData.png
Download that then input it's location in the Import line code by Ctrl + C once you click the image in your HDD or wherever it is.
life = Import["C:\\Users\\Alex\\Desktop\\GameOfLifeStartData.png",
"Data"];
Dimensions[life];
boardLength = Dimensions[life][[1]];
boardWidth = Dimensions[life][[2]];
lifeBoardOld = Table["", {i, 1, boardLength}, {j, 1, boardWidth}];
lifeBoardNew = lifeBoardOld;
For[i = 1, i <= boardLength, i++,
tempLength = Length[life[[i]]];
lifeBoardOld[[i, 1 ;; tempLength]] = life[[i]];
For[j = tempLength + 1, j <= boardWidth, j++,
lifeBoardOld[[i, j]] = 1;
]
]
For[i = 2, i <= boardLength - 1, i++,
For[j = 2, j <= boardWidth - 1, j++,
neighbor = 0;
If[lifeBoardOld[[i - 1, j - 1]] == 0, neighbor++, Null];
If[lifeBoardOld[[i - 1, j]] == 0, neighbor++, Null];
If[lifeBoardOld[[i - 1, j + 1]] == 0, neighbor++, Null];
If[lifeBoardOld[[i, j - 1]] == 0, neighbor++, Null];
If[lifeBoardOld[[i, j + 1]] == 0, neighbor++, Null];
If[lifeBoardOld[[i + 1, j - 1]] == 0, neighbor++, Null];
If[lifeBoardOld[[i + 1, j]] == 0, neighbor++, Null];
If[lifeBoardOld[[i + 1, j + 1]] == 0, neighbor++, Null];
lifeBoardNew[[i, j]] = 1;
If[neighbor == 3, lifeBoardNew[[i, j]] = 0, Null];
If[neighbor == 2, lifeBoardNew[[i, j]] = lifeBoardOld[[i, j]], Null];
If[neighbor == 1, lifeBoardNew[[i, j]] == 1, Null];
If[neighbor > 3, lifeBoardNew[[i, j]] = 1, Null];
]
]
i = 1
For[j = 2, j <= boardWidth - 1, j++,
neighbor = 0;
If[lifeBoardOld[[i, j - 1]] == 0, neighbor++, Null];
If[lifeBoardOld[[i, j + 1]] == 0, neighbor++, Null];
If[lifeBoardOld[[i + 1, j - 1]] == 0, neighbor++, Null];
If[lifeBoardOld[[i + 1, j]] == 0, neighbor++, Null];
If[lifeBoardOld[[i + 1, j + 1]] == 0, neighbor++, Null];
lifeBoardNew[[i, j]] = 1;
If[neighbor == 3, lifeBoardNew[[i, j]] = 0, Null];
If[neighbor == 2, lifeBoardNew[[i, j]] = lifeBoardOld[[i, j]], Null];
If[neighbor == 1, lifeBoardNew[[i, j]] == 1, Null];
If[neighbor > 3, lifeBoardNew[[i, j]] = 1, Null];
]
i = boardLength
For[j = 2, j <= boardWidth - 1, j++,
neighbor = 0;
If[lifeBoardOld[[i - 1, j - 1]] == 0, neighbor++, Null];
If[lifeBoardOld[[i - 1, j]] == 0, neighbor++, Null];
If[lifeBoardOld[[i - 1, j + 1]] == 0, neighbor++, Null];
If[lifeBoardOld[[i, j - 1]] == 0, neighbor++, Null];
If[lifeBoardOld[[i, j + 1]] == 0, neighbor++, Null];
lifeBoardNew[[i, j]] = 1;
If[neighbor == 3, lifeBoardNew[[i, j]] = 0, Null];
If[neighbor == 2, lifeBoardNew[[i, j]] = lifeBoardOld[[i, j]], Null];
If[neighbor == 1, lifeBoardNew[[i, j]] == 1, Null];
If[neighbor > 3, lifeBoardNew[[i, j]] = 1, Null];
]
j = 1
For[i = 2, i <= boardLength - 1, i++,
neighbor = 0;
If[lifeBoardOld[[i - 1, j]] == 0, neighbor++, Null];
If[lifeBoardOld[[i - 1, j + 1]] == 0, neighbor++, Null];
If[lifeBoardOld[[i, j + 1]] == 0, neighbor++, Null];
If[lifeBoardOld[[i + 1, j]] == 0, neighbor++, Null];
If[lifeBoardOld[[i + 1, j + 1]] == 0, neighbor++, Null];
lifeBoardNew[[i, j]] = 1;
If[neighbor == 3, lifeBoardNew[[i, j]] = 0, Null];
If[neighbor == 2, lifeBoardNew[[i, j]] = lifeBoardOld[[i, j]], Null];
If[neighbor == 1, lifeBoardNew[[i, j]] == 1, Null];
If[neighbor > 3, lifeBoardNew[[i, j]] = 1, Null];
]
j = boardWidth
For[i = 2, i <= boardLength - 1, i++,
neighbor = 0;
If[lifeBoardOld[[i - 1, j - 1]] == 0, neighbor++, Null];
If[lifeBoardOld[[i - 1, j]] == 0, neighbor++, Null];
If[lifeBoardOld[[i, j - 1]] == 0, neighbor++, Null];
If[lifeBoardOld[[i + 1, j - 1]] == 0, neighbor++, Null];
If[lifeBoardOld[[i + 1, j]] == 0, neighbor++, Null];
lifeBoardNew[[i, j]] = 1;
If[neighbor == 3, lifeBoardNew[[i, j]] = 0, Null];
If[neighbor == 2, lifeBoardNew[[i, j]] = lifeBoardOld[[i, j]], Null];
If[neighbor == 1, lifeBoardNew[[i, j]] == 1, Null];
If[neighbor > 3, lifeBoardNew[[i, j]] = 1, Null];
]
(* top left *)
neighbor = 0;
i = 1; j = 1;
If[lifeBoardOld[[i, j + 1]] == 0, neighbor++, Null];
If[lifeBoardOld[[i + 1, j]] == 0, neighbor++, Null];
If[lifeBoardOld[[i + 1, j + 1]] == 0, neighbor++, Null];
lifeBoardNew[[i, j]] = 1;
If[neighbor == 3, lifeBoardNew[[i, j]] = 0, Null];
If[neighbor == 2, lifeBoardNew[[i, j]] = lifeBoardOld[[i, j]], Null];
If[neighbor == 1, lifeBoardNew[[i, j]] == 1, Null];
If[neighbor > 3, lifeBoardNew[[i, j]] = 1, Null];
(* top right *)
neighbor = 0;
i = 1; j = boardWidth;
If[lifeBoardOld[[i, j - 1]] == 0, neighbor++, Null];
If[lifeBoardOld[[i + 1, j - 1]] == 0, neighbor++, Null];
If[lifeBoardOld[[i + 1, j]] == 0, neighbor++, Null];
lifeBoardNew[[i, j]] = 1;
If[neighbor == 3, lifeBoardNew[[i, j]] = 0, Null];
If[neighbor == 2, lifeBoardNew[[i, j]] = lifeBoardOld[[i, j]], Null];
If[neighbor == 1, lifeBoardNew[[i, j]] == 1, Null];
If[neighbor > 3, lifeBoardNew[[i, j]] = 1, Null];
(* bottom left *)
neighbor = 0;
i = boardLength; j = 1;
If[lifeBoardOld[[i - 1, j]] == 0, neighbor++, Null];
If[lifeBoardOld[[i - 1, j + 1]] == 0, neighbor++, Null];
If[lifeBoardOld[[i, j + 1]] == 0, neighbor++, Null];
lifeBoardNew[[i, j]] = 1;
If[neighbor == 3, lifeBoardNew[[i, j]] = 0, Null];
If[neighbor == 2, lifeBoardNew[[i, j]] = lifeBoardOld[[i, j]], Null];
If[neighbor == 1, lifeBoardNew[[i, j]] == 1, Null];
If[neighbor > 3, lifeBoardNew[[i, j]] = 1, Null];
(* bottom right *)
neighbor = 0;
i = boardLength; j = boardWidth;
If[lifeBoardOld[[i - 1, j - 1]] == 0, neighbor++, Null];
If[lifeBoardOld[[i - 1, j]] == 0, neighbor++, Null];
If[lifeBoardOld[[i, j - 1]] == 0, neighbor++, Null];
lifeBoardNew[[i, j]] = 1;
If[neighbor == 3, lifeBoardNew[[i, j]] = 0, Null];
If[neighbor == 2, lifeBoardNew[[i, j]] = lifeBoardOld[[i, j]], Null];
If[neighbor == 1, lifeBoardNew[[i, j]] == 1, Null];
If[neighbor > 3, lifeBoardNew[[i, j]] = 1, Null];
lifeBoardOld = lifeBoardNew;
ArrayPlot[lifeBoardOld, ColorRules -> {1 -> White, 0 -> Black}]
On July 06 2011 06:31 ninjafetus wrote:
I think the code is for Conway's Game of Life.
I think the code is for Conway's Game of Life.
Congratulations!!