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; } }
public Cell() { state = 0; myNeighbors = new Cell[8]; neighbors = new Cell[8]; color = new MyColor(0,0,0); probability = 0; blocked = false; recrystallized = false; H = 0; border = false; }
public void setCellsFoMC(int amount) { Dictionary<int, MyColor> idAndColor = new Dictionary<int, MyColor>(); for (int i = 1; i <= amount; i++) { idAndColor[i] = new MyColor(); } for (int i = start; i < endX; i++) for (int j = start; j < endY; j++) { int randID = random.Next(1, amount+1); this.firstGrid[i][j].state = randID; this.firstGrid[i][j].color = idAndColor[randID]; } }
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; }
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; }
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; }