Hi, i need help in building a program about automata cellular.
So, there is 4 state of cells, 0 = space, 1 = ".", 2 = "+", 3 = "#"
This state is continuous from 0 - 3, after 3, it will be back to 0.

we need to compare each cell to the cell on their left and right.
So for example, i already generate random number and representated as this cells..

012345
#.   +

This is the rules, if either one of the neighbouring cells has a state equal to the next state of the cell, then the cell is changed to the next state.
So, in the example, the result will be.

012345
#..  #

So this rules is applied to cell 2 and 5

i have dificulties in finding the right algorithm.

namespace coba2
{
    class scramble
    {
        private const int ARRAYSIZE = 20;
        private Cell[] Cells;

        public scramble()
        {
            Cells = new Cell[ARRAYSIZE];
            for (int i = 0; i < ARRAYSIZE; i++)
            {
                Cells[i] = new Cell();
            }
        }

        /// <summary>
        /// Generates random number and assign the symbol to each number
        /// </summary>
        public void scrambles(int seed)
        {
            int rand;

            // set up random object and initialise with seed
            Random r = new Random(seed);
            for (int i = 0; i < ARRAYSIZE; i++)
            {
                rand = r.Next(4);
                //Console.Write("{0}", Cells[i]);

                // applying symbol to generated number
                if (rand == 0)  Cells[i].DefaultCell = CellState.SPACE;
                else if (rand == 1) Cells[i].DefaultCell = CellState.DOT;
                else if (rand == 2) Cells[i].DefaultCell = CellState.PLUS;
                else Cells[i].DefaultCell = CellState.HASH;
            }
        }

        /// <summary>
        /// Print out the cells using symbol
        /// </summary>
        public void PrintCell()
        {
            // print the cells in the row
            for (int i = 0; i < ARRAYSIZE; i++)
            {
                if (Cells[i].DefaultCell == CellState.SPACE)
                    Console.Write(" ");
                else if (Cells[i].DefaultCell == CellState.DOT)
                    Console.Write(".");
                else if (Cells[i].DefaultCell == CellState.PLUS)
                    Console.Write("+");
                else
                    Console.Write("#");
            }
            Console.WriteLine();
        }

        public void operation1()
        {
            for (int i = 0; i < 19; i++)
            {
                else if (Cells[i].DefaultCell == Cells[i + 1].DefaultCell &&  Cells[i].DefaultCell == Cells[i - 1].DefaultCell)
                {
                    Cells[i].ChangeState();
                }
            PrintCell();
        }
    }
}

the void operation1 didn't work well, i want to put the algorithm here..
i already have another class that apply the ChangeState() to change the cell state to the next state..
can anyone help me? thanks

What is the definition of object Cell ?

Inside method operation1() :
1) You hardcoded 19 in your loop when you should use ARRAYSIZE-1 2) Where is the beginning of the else if clause?
3) Since you already have a method to change the state ChangeState() , what exactly is the purpose of operation1() method?

Also, try using the "preview" button when posting so you can see if your code tags are correct.;)

oh sorry about that..
i will fix this

by the way, operation1() method is where i put the rules to the automata. ChangeState() method is to change the cell to the next state.
So in this case, if the rule in operation1() is met, than the ChangeState() method will change the associated cell to the next stage.

namespace coba2
{
    class scramble
    {
        private const int ARRAYSIZE = 20;
        private Cell[] Cells;

        public scramble()
        {
            Cells = new Cell[ARRAYSIZE];
            for (int i = 0; i < ARRAYSIZE; i++)
            {
                Cells[i] = new Cell();
            }
        }

        /// <summary>
        /// Generates random number and assign the symbol to each number
        /// </summary>
        public void scrambles(int seed)
        {
            int rand;

            // set up random object and initialise with seed
            Random r = new Random(seed);
            for (int i = 0; i < ARRAYSIZE; i++)
            {
                rand = r.Next(4);
                //Console.Write("{0}", Cells[i]);

                // applying symbol to generated number
                if (rand == 0)  Cells[i].DefaultCell = CellState.SPACE;
                else if (rand == 1) Cells[i].DefaultCell = CellState.DOT;
                else if (rand == 2) Cells[i].DefaultCell = CellState.PLUS;
                else Cells[i].DefaultCell = CellState.HASH;
            }
        }

        /// <summary>
        /// Print out the cells using symbol
        /// </summary>
        public void PrintCell()
        {
            // print the cells in the row
            for (int i = 0; i < ARRAYSIZE; i++)
            {
                if (Cells[i].DefaultCell == CellState.SPACE)
                    Console.Write(" ");
                else if (Cells[i].DefaultCell == CellState.DOT)
                    Console.Write(".");
                else if (Cells[i].DefaultCell == CellState.PLUS)
                    Console.Write("+");
                else
                    Console.Write("#");
            }
            Console.WriteLine();
        }

        public void operation1()
        {
            for (int i = 0; i < ARRAYSIZE; i++)
            {
                if (Cells[i].DefaultCell == Cells[i + 1].DefaultCell && Cells[i].DefaultCell == Cells[i - 1].DefaultCell)
                {
                    Cells[i].ChangeState();
                }
            }
            PrintCell();
        }
    }
}

and this is the class Cell

namespace coba2
{
    enum CellState
    {
        SPACE,
        DOT,
        PLUS,
        HASH
    }

    class Cell
    {
        private CellState defaultCell;

        public Cell()
        {
            defaultCell = CellState.SPACE;
        }

        public CellState DefaultCell
        {
            get { return defaultCell; }
            set { defaultCell = value; }
        }
        
        /// <summary>
        /// Change the cell state to the next state
        /// </summary>
        public void ChangeState()
        {
            if (defaultCell == CellState.SPACE)
                defaultCell = CellState.DOT;
            else if (defaultCell == CellState.DOT)
                defaultCell = CellState.PLUS;
            else if (defaultCell == CellState.PLUS)
                defaultCell = CellState.HASH;
            else
                defaultCell = CellState.SPACE;
        }
    }
}

I think this is what you want, but you need to compare your random generated cells to see if you are getting the ChangeState on the proper cell because I modified the index on that too.

public void operation1()
            {
                for (int i = 0; i < ARRAYSIZE-1; i++)
                {
                    if (Cells[i].DefaultCell == Cells[i + 1].DefaultCell && 
                        Cells[i].DefaultCell == Cells[i].DefaultCell)
                    {
                        Cells[i + 1].ChangeState();
                    }
                } 
                PrintCell();

            }

thanks for the reply.
But i already check, it is not the answer.

the problem is i need to change the cell state(that i want to compare) to the next state first.
after that compare it to the left and right, if either one of it is the same, then the current cell will be changed too..

012345
#. +

here it is..
cell 2 is "space", and the next state is "."
cell 1 state is ".", so it has the same state with the next state of cell 2.
So cell 2 will be changed to "."

i still don't know how to assuming that the cell is changing state first before i compare it to the neighbouring cells.


thanks.

thanks for the reply.
But i already check, it is not the answer.

the problem is i need to change the cell state(that i want to compare) to the next state first.
after that compare it to the left and right, if either one of it is the same, then the current cell will be changed too..

012345
#. +

here it is..
cell 2 is "space", and the next state is "."
cell 1 state is ".", so it has the same state with the next state of cell 2.
So cell 2 will be changed to "."

i still don't know how to assuming that the cell is changing state first before i compare it to the neighbouring cells.


thanks.

Yep, just noticed that after rereading and was about to tell you what to do. Also, you can remove that unnecessary line that compares the cell to itself because I forgot too.

When comparing those two cells (left cell and right cell), if you change the left cell instead of the right, you have the possibility of still having same adjacent cell values, which I was not sure if was allowed scenario. If that is OK, then you need only change ChangeState at cell. If remaining same adjacent cells must be done, you will need a nested loop, or additional logic to compare three cells at a time.

What I'm trying to say is that if you are only allowed to change each cell once, and the completed array must not have any adjacent cells contain the same value, and, you must change the left hand cell side of the comparison (reading left to right), then let me know that all of these rules are true and I will show you what to do. I just don't want to begin without knowing the exact requirements.

What I'm trying to say is that if you are only allowed to change each cell once, and the completed array must not have any adjacent cells contain the same value, and, you must change the left hand cell side of the comparison (reading left to right), then let me know that all of these rules are true and I will show you what to do. I just don't want to begin without knowing the exact requirements.

Oh... here is what I mean:

for (int i = 0; i < ARRAYSIZE-1; i++)
                {
                    if (Cells[i].DefaultCell == Cells[i + 1].DefaultCell)
                    {
                        do
                        {
                            Cells[i].ChangeState();
                        }
                        while (i > 0 && Cells[i].DefaultCell == Cells[i - 1].DefaultCell);
                        System.Diagnostics.Debug.Assert(Cells[i].DefaultCell != Cells[i + 1].DefaultCell);
                    }
                }

thanks for the reply..

i am not quite sure about what you mean.
but i can give more explanation and example.

Yes, i only need to change changeState at cell .
the rule goes through each cell from left to right.
If the rule is not applied to the cell, then the cell remains unchanged.

this is the example (i won't use the "space" (ignore the space) because it is hard to see in here, so let say we have 3 state, ".", "+", "#" --> "#" will go to "." as the next state)

example 13 cells in a row:
the first row: ##+#++#..#+.#
the result: ######. ... #+.

sorry if it is not clear

example 13 cells in a row:
the first row: ##+#++#..#+.#
the result: ######. ... #+.

OK, now I'm confused, so let's just stick to the input/output. Let's use underscore for the space character. In the above, I would expect for output to be: "#_+#+##.+#+.#". I don't understand how you started the output with "###", because I would think you be changing the second cell to be "_" or space given your ChangeState() method and that it is equal to the adjacent cell's "#". Where am I confused?

thanks for the reply..

i am not quite sure about what you mean.
but i can give more explanation and example.

Yes, i only need to change changeState at cell .
the rule goes through each cell from left to right.
If the rule is not applied to the cell, then the cell remains unchanged.

this is the example (i won't use the "space" (ignore the space) because it is hard to see in here, so let say we have 3 state, ".", "+", "#" --> "#" will go to "." as the next state)

example 13 cells in a row:
the first row: ##+#++#..#+.#
the result: ######. ... #+.

sorry if it is not clear

I am not sure why this reply got posted twice, but see my other comment on it. Also, here are two short examples I would like you to explain if the output is wrong (use underscore for space):

INPUT: "####"
OUTPUT: "#_#_"

INPUT: "++++"
OUTPUT: "+#+#"

thanks for the reply..

i am not quite sure about what you mean.
but i can give more explanation and example.

Yes, i only need to change changeState at cell .
the rule goes through each cell from left to right.
If the rule is not applied to the cell, then the cell remains unchanged.

this is the example (i won't use the "space" (ignore the space) because it is hard to see in here, so let say we have 3 state, ".", "+", "#" --> "#" will go to "." as the next state)

example 13 cells in a row:
the first row: ##+#++#..#+.#
the result: ######. ... #+.

sorry if it is not clear

INPUT: "####"
OUTPUT: "#_#_"

INPUT: "++++"
OUTPUT: "+#+#"

Sorry, I meant:

INPUT: "####"
OUTPUT: "_#_#"

INPUT: "++++"
OUTPUT: "#+#+"

Here is an even shorter way to begin clarifying what I don't seem to understand. Sorry about changing the second cells earlier--the coffee speeds up my typing, but apparently not my brain so much.;)

INPUT: "##" AND "__" AND ".."
OUTPUT: "_#" AND "._" AND "+."

Right?

sorry, my mistake, maybe it makes u confused.
but your output didn;t match
lets change the space to "_"
so --> "_" "." "+" "#" (this is the order)
i will make another example

input: ##+._+_#.#+.#
output will be: ###+.+_ _.##+#

each cell is compared to the left and right of the original cell (the input)
Now, there is no mistake in it.

lets change the space to "_"
so --> "_" "." "+" "#" (this is the order)
i will make another example

input: ##+._+_#.#+.#
output will be: ###+.+_ _.##+#

each cell is compared to the left and right of the original cell (the input)
Now, there is no mistake in it.

This doesn't make sense to me, because you said:

This is the rules, if either one of the neighbouring cells has a state equal to the next state of the cell, then the cell is changed to the next state.

but, the input, and the output you say it should be both begins with "##", which is equal to the next state--is it not? How can your output be correct?

nah, u get it wrong hehe..
"This is the rules, if either one of the neighbouring cells has a state equal to the next state of the cell, then the cell is changed to the next state."

what i meant by "equal to the next state of the cell" is, equal to the next transformation of the cell which i want to compare. if i want to compare cell 2, it will be compared to cell 1 and 3.
So first i need to work out cell 2 next state(transformation) first, and then compared it to cell 1 and 3.

input:
1 2 3 4
# _ + .

let say i want to compare cell 1 with cell 2. The next state of cell 1 ("#") is ("_"). It is the same with cell 2 ("_"). So, change Cell 1 to the next state.
The rule also apply to cell 4 ("."), which has ("+") as the next transformation state. and cell 3 has ("+"). Cell 4 transformation has the same state with cell 3 which is ("+")
so, Cell 4 will be changed to ("+")

output will be:
1 2 3 4
_ _ + +

Ooooh... Try this:

// In class Cell:
            public static CellState NextCellState(Cell cell)
            {
                if (cell.DefaultCell == CellState.SPACE)
                    return CellState.DOT;
                else if (cell.DefaultCell == CellState.DOT)
                    return CellState.PLUS;
                else if (cell.DefaultCell == CellState.PLUS)
                    return CellState.HASH;
                else
                    return CellState.SPACE;
            }

// then in operation1 method; you might need to rearrange
            public void operation1()
            {
                // NOTE: if you only need to evaluate from left to right one time,
                // then you can omit this loop. Otherwise, this loop will continue
                // changing the cell states until the conditions are not longer true.
                    for (int i = 0; i < ARRAYSIZE; i++)
                    {
                        bool bHasChanged = true;
                        while (bHasChanged)
                        {
                            bHasChanged = false;


                            // ** check next cell
                            if (i < ARRAYSIZE - 1 && Cell.NextCellState(Cells[i]) == Cells[i + 1].DefaultCell)
                            {
                                Cells[i].ChangeState();
                                bHasChanged = true;
                            }
                            // ** check previous cell
                            else if (i > 0 && Cell.NextCellState(Cells[i]) == Cells[i - 1].DefaultCell)
                            {
                                Cells[i].ChangeState();
                                bHasChanged = true;
                            }

                        }
                }
#if false
                // NOTE: if you only need to evaluate from left to right one time,
                // then you can omit this loop. Otherwise, this loop will continue
                // changing the cell states until the conditions are not longer true.
                bool bHasChanged = true;
                while (bHasChanged)
                {
                    bHasChanged = false;

                    for (int i = 0; i < ARRAYSIZE; i++)
                    {
                        // ** check previous cell
                        if (i > 0 && Cell.NextCellState(Cells[i]) == Cells[i - 1].DefaultCell)
                        {
                            Cells[i].ChangeState();
                            //bHasChanged = true;
                        }
                        
                        // ** check next cell
                        if (i < ARRAYSIZE - 1 && Cell.NextCellState(Cells[i]) == Cells[i + 1].DefaultCell)
                        {
                            Cells[i].ChangeState();
                            //bHasChanged = true;
                        }
                    }
                }
#endif
                PrintCell();
            }

NOTE: look at the comments I made because I fear there could be another specification not here or that I misunderstood because I tried every variation I could think of to get the output you suggested using one of your examples, and I could not get the answer/result you said. I reversed the checks, added and removed else clause, moved the loop in and out of the for loop too, etc...

Example I used to try to produce the output you said:

public void HardCode()
            {
                ARRAYSIZE = 13;

                //##+._+_#.#+.#
                Cells[0].DefaultCell = CellState.HASH;
                Cells[0].DefaultCell = CellState.HASH;
                Cells[0].DefaultCell = CellState.PLUS;
                Cells[0].DefaultCell = CellState.DOT;
                Cells[0].DefaultCell = CellState.SPACE;
                Cells[0].DefaultCell = CellState.PLUS;
                Cells[0].DefaultCell = CellState.SPACE;
                Cells[0].DefaultCell = CellState.HASH;
                Cells[0].DefaultCell = CellState.DOT;
                Cells[0].DefaultCell = CellState.HASH;
                Cells[0].DefaultCell = CellState.PLUS;
                Cells[0].DefaultCell = CellState.DOT;
                Cells[0].DefaultCell = CellState.HASH;

But, the good news is that you should, by now, have all of the code and logic you need to pull this off.

Cheers!

Hi, it really helps.
it's true, i get the code and logic that i want.
Thanks you very much :)

cheers

:sweat:....Kewl!!!!:)

I'd like to recommend combining the functionality in the ChangeState method to incorporate the NextChangedState method's return value instead of having two identical sets of logic.

Cheers!

hm.. i just tried it.
maybe it sounds lame.
but i really am not good in C#, and it didn't work.

i tried to change one of the Cells.ChangeState() to Cell.NextCellState(Cells) and it doesn't work


if (i < ARRAYSIZE - 1 && Cell.NextCellState(Cells[i]) == Cells[i + 1].DefaultCell)
{
Cell.NextCellState(Cells[i]);
bHasChanged = true;
}

hm.. i just tried it.
maybe it sounds lame.
but i really am not good in C#, and it didn't work.

i tried to change one of the Cells.ChangeState() to Cell.NextCellState(Cells) and it doesn't work


if (i < ARRAYSIZE - 1 && Cell.NextCellState(Cells[i]) == Cells[i + 1].DefaultCell)
{
Cell.NextCellState(Cells[i]);
bHasChanged = true;
}

No, change the ChangeState method is what I meant:

public void ChangeState()
            {
                this.defaultCell = NextCellState(this);
#if false
                if (defaultCell == CellState.SPACE)
                    defaultCell = CellState.DOT;
                else if (defaultCell == CellState.DOT)
                    defaultCell = CellState.PLUS;
                else if (defaultCell == CellState.PLUS)
                    defaultCell = CellState.HASH;
                else
                    defaultCell = CellState.SPACE;
#endif
              }

oh, one more thing.
Actually, i am not quite understand why you use bool and while loop.
But, I already use your logic and code and put it into a simple line of code (thanks for your help).

this is the code for operation1:

public void operation1()
        {
            for (int i = 0; i < ARRAYSIZE - 1; i++)
            {
                if (Cell.NextCellState(Cells[i]) == Cells[i + 1].DefaultCell || Cell.NextCellState(Cells[i]) == Cells[i - 1].DefaultCell)
                {
                    Cells[i].ChangeState();
                }
            }
            PrintCell();
        }

This is to check either one of the right and left cell.
However, a problem arise.

This is the input and output:
(let's say i change the "space" to "0" --> easier to read)

WRONG
V
input: ##+#+0000+#.0.0#+.0#
output: #####0000##....##..#

this output already correct except the last three cell --> the DOT between PLUS and SPACE
The output for this DOT should be PLUS (+), because the left cell is PLUS (same with the DOT nextState).

So, i find this problem, the cell compare itself with the cell in the left which has already turn.
This mean, the DOT cell(last 3 cell) not compared with the PLUS(last 4 cell), instead, it is compared with the output (PLUS that has already changed to HASH)(left cell).

i hope you understand :)

i am thinking about putting the cell that has already changed to temp array or something like that. Is it true that way?

I am so glad you marked this thread as solved, because most people never bother to that even once they have a complete answer...:D and ;)

Do you just want to do the checks from left to right one time, and do you need to make the changes based only on the original data, and not any of the changed data?

It is important to know this, because if this is true, then you do need a temporary or separate array to perform all checks on the original array, and without performing checks against previous cells that may have already been changed.

Let me know.

that's alright. you have helped me a lot.
thanks :)

oh yeah, i think i forget to say something about how to compare.
The last array should be compared to the array on the left and the right array(in this case, first array). Also, first array is compared with second array and last array(assume it is on the right side of first array).

So if there are 20 elements.
Cell 1 will be compared to cell 2 and cell 20.
But i alredy solved this problem anyway :p


"Do you just want to do the checks from left to right one time, and do you need to make the changes based only on the original data, and not any of the changed data?"
--> yes, it's true, just from the left to right. and I need to make the change based on the original data, not any of the changed data..

Actually in this program, I need to make 20 generation.
So let say, so far i have this 2 rows. First is original row, and the second is the one that has been changed.
I need to make it until 20 rows. So, the third row is changed base on row 2, the 4 row is changed based on row 3, etc.
Hmm... I generate this 20 row using for loop :p

and actually, the rules that i gave you is not the only rule. But i can make the other rules on my own, so i just give you the one that I can't do :p
but everything is under control, with your help, i can combine all the rules together. Thanks.

Anyway, the problem is as I stated above, and as you already mentioned, I need to change the cell state based on the original row.
And my program always compare the cell with the one that have been changed :(

Whew :confused:, for a minute there I thought you were making this up as we went along. Anyway, glad you are comfortable with where you are with this project.

Cheers! ;)

haha, of course not. why i make this up. It is already 5 o clock in the morning here, and i still struggling in this project
I won't make this up mate :p

I am not too good with programming.
I guess I shouldn't take this subject :p
But, you help me a lot. it improves my understanding.
thanks

I think i need to get some sleep..
Thanks for your help.
I will be online in several hours and continuing with my project AGAIN?? :p

Hi mate, can you help me?? I can't finish this project.
I have generate 20 row, but the correct one only until row 2, after row 3 everything gone wrong. I already use the temp array and the rules are all correct.
I think the problem is in the temp array.
It can't be used after row 3

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

/*******************************************************************\
       Program that generates a simple 1 dimendional automata.
          The automata is described by a line of cells that
	   can have 4 possible states; space,".", "+", "#".
       Each cell examines the cell on either side of it.
       The following rules are then applied to each cell:
1. If either one of the neighbouring cells has a state equal to 
    the next state then the cell is changed to the next stage.
2. If both neighours have the same state as the cell then the 
    cell is changed to the next state.
3. If neither rurle 1 or 2 applies then the cell remains unchanged.
\*******************************************************************/

namespace cell_autom
{
    class Automata
    {
        private const int CELLSIZE = 64;
        private const int GENERATION = 20;
        private Cell[] Cells;
        private Cell[] tempCells;

        public Automata()
        {
            Cells = new Cell[CELLSIZE];
            tempCells = new Cell[CELLSIZE];
            for (int i = 0; i < CELLSIZE; i++)
            {
                Cells[i] = new Cell();
                tempCells[i] = new Cell();
            }
        }

        /// <summary>
        /// Generates random number and assign the symbol to each number
        /// </summary>
        public void GenerateCell(int seed)
        {
            int rand;

            // set up random object and initialise with seed
            Random r = new Random(seed);
            for (int i = 0; i < CELLSIZE; i++)
            {
                rand = r.Next(4);

                // applying symbol to generated number
                if (rand == 0)
                {
                    Cells[i].DefaultCell = CellState.SPACE;
                    tempCells[i].DefaultCell = CellState.SPACE;
                }
                else if (rand == 1)
                {
                    Cells[i].DefaultCell = CellState.DOT;
                    tempCells[i].DefaultCell = CellState.DOT;
                }
                else if (rand == 2)
                {
                    Cells[i].DefaultCell = CellState.PLUS;
                    tempCells[i].DefaultCell = CellState.PLUS;
                }
                else
                {
                    Cells[i].DefaultCell = CellState.HASH;
                    tempCells[i].DefaultCell = CellState.HASH;
                }
            }
            Console.Write("Gen   1  ");
        }

        /// <summary>
        /// Print out the cells using symbol
        /// </summary>
        public void PrintCell()
        {
            // print the cells in the row
            for (int i = 0; i < CELLSIZE; i++)
            {
                if (Cells[i].DefaultCell == CellState.SPACE)
                    Console.Write(" ");
                else if (Cells[i].DefaultCell == CellState.DOT)
                    Console.Write(".");
                else if (Cells[i].DefaultCell == CellState.PLUS)
                    Console.Write("+");
                else
                    Console.Write("#");
            }
            Console.WriteLine();
        }

        /// <summary>
        /// Create a copy array
        /// </summary>
        public void CopyArray()
        {
            for (int i = 0; i < CELLSIZE; i++)
            {
                tempCells[i] = Cells[i];
            }
        }

        public void OperateCell()
        {
            for (int j = 0; j < GENERATION - 1; j++)
            {
                Console.Write("Gen {0,3}  ", j + 2);
                for (int i = 0; i < CELLSIZE; i++)
                {
                    if (i == 0)
                    {
                        if (Cell.NextCellState(tempCells[i]) == tempCells[i + 1].DefaultCell || Cell.NextCellState(tempCells[i]) == tempCells[63].DefaultCell)
                            Cells[i].ChangeState();
                        if (tempCells[i].DefaultCell == tempCells[i + 1].DefaultCell && tempCells[i].DefaultCell == tempCells[63].DefaultCell)
                            Cells[i].ChangeState();
                    }
                    else if (i == 63)
                    {
                        if (Cell.NextCellState(tempCells[i]) == tempCells[0].DefaultCell || Cell.NextCellState(tempCells[i]) == tempCells[i - 1].DefaultCell)
                            Cells[i].ChangeState();
                        if (tempCells[i].DefaultCell == tempCells[0].DefaultCell && tempCells[i].DefaultCell == tempCells[i - 1].DefaultCell)
                            Cells[i].ChangeState();
                    }
                    else if (Cell.NextCellState(tempCells[i]) == tempCells[i + 1].DefaultCell || Cell.NextCellState(tempCells[i]) == tempCells[i - 1].DefaultCell)
                    {
                        Cells[i].ChangeState();
                    }
                    else
                    {
                        if (tempCells[i].DefaultCell == tempCells[i + 1].DefaultCell && tempCells[i].DefaultCell == tempCells[i - 1].DefaultCell)
                            Cells[i].ChangeState();
                    }
                }
                CopyArray();
                PrintCell();
            }
        }
    }
}

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.