Esempio n. 1
0
        public void HexaLeft(ref Cell cell)
        {
            int count = 0;
            int maks = 0;
            int id = 0;
            MyColor c = new MyColor();

            for (int k = 0; k < 6; ++k)
            {
                count = 0;

                for (int l = 0; l < 6; l++)
                {
                    if (cell.neighbors[k].state != 0 && cell.neighbors[l].state != 0 && cell.neighbors[k].state == cell.neighbors[l].state && cell.neighbors[k].blocked == false && cell.neighbors[l].blocked == false && cell.neighbors[k].state != -1 && cell.neighbors[l].state != -1)
                    {
                        count++;
                    }
                }

                if (count > maks)
                {
                    maks = count;
                    id = cell.neighbors[k].state;
                    c = cell.neighbors[k].color;
                }

                cell.state = id;
                cell.color = c;

            }

        }
Esempio n. 2
0
        public void createGrid()
        {
            firstGrid = new Cell[this.gridSizeX][];
            secondGrid = new Cell[this.gridSizeX][];

            for (int i = 0; i < this.gridSizeX; i++)
            {
                firstGrid[i] = new Cell[gridSizeY];
                secondGrid[i] = new Cell[gridSizeY];

                for (int j = 0; j < this.gridSizeY; j++)
                {
                    firstGrid[i][j] = new Cell();
                    secondGrid[i][j] = new Cell();
                }
            }

        }
Esempio n. 3
0
        public bool Rule3(ref Cell cell)
        {
            int count = 0;

            MyColor c = new MyColor();


            for (int k = 0; k < 2; ++k)
            {
                count = 0;

                for (int l = 0; l < 2; l++)
                {
                    if (cell.neighbors[k].state != 0 && cell.neighbors[l].state != 0 && cell.neighbors[k].state == cell.neighbors[l].state)
                    {
                        count++;
                    }
                }

                for (int l = 6; l < 8; l++)
                {
                    if (cell.neighbors[k].state != 0 && cell.neighbors[l].state != 0 && cell.neighbors[k].state == cell.neighbors[l].state)
                    {
                        count++;
                    }
                }

                if (count == 3)
                {
                    cell.state = cell.neighbors[k].state;
                    cell.color = cell.neighbors[k].color;
                    return true;
                }
            }

            return false;
        }
Esempio n. 4
0
        public bool Rule4(ref Cell cell, int globalProbability)
        {
            int count = 0;
            int maks = 0;
            int id = 0;
            MyColor c = new MyColor();

            for (int k = 0; k < 8; ++k)
            {
                count = 0;

                for (int l = 0; l < 8; l++)
                {
                    if (cell.neighbors[k].state != 0 && cell.neighbors[l].state != 0 && cell.neighbors[k].state == cell.neighbors[l].state)
                    {
                        count++;
                    }
                }

                if (count > maks)
                {
                    maks = count;
                    id = cell.neighbors[k].state;
                    c = cell.neighbors[k].color;
                }              
            }

            if (cell.probability < globalProbability)
            {
                cell.state = id;
                cell.color = c;
                return true;
            }

            return false;
        }
Esempio n. 5
0
        public void PentaLeft(ref Cell cell)
        {
            int count = 0;
            int maks = 0;
            int id = 0;
            MyColor c = new MyColor();

            for (int k = 1; k < 8; ++k)
            {
                if (k == 2 || k == 6)
                    continue;

                count = 0;

                for (int l = 1; l < 8; l++)
                {
                    if (l == 2 || l == 6)
                        continue;

                    if (cell.neighbors[k].state != 0 && cell.neighbors[l].state != 0 && cell.neighbors[k].state == cell.neighbors[l].state && cell.neighbors[k].blocked == false && cell.neighbors[l].blocked == false && cell.neighbors[k].state != -1 && cell.neighbors[l].state != -1)
                    {
                        count++;
                    }
                }

                if (count > maks)
                {
                    maks = count;
                    id = cell.neighbors[k].state;
                    c = cell.neighbors[k].color;
                }
            }

            cell.state = id;
            cell.color = c;
        }