//ULAM neighbourhood for the mesh OCTOGON_SQUARE //Calculates neighbourhood number of one cell override public int neightbours_number(ModuloIndexableList <ModuloIndexableList <int> > matrix, int i, int j) { int l = 0; if ((i + j) % 2 == 0) { for (int ii = i - 1; ii < i + 2; ii++) { for (int jj = j - 1; jj < j + 2; jj++) { if ((ii != i) || (jj != j)) { l = l + matrix[ii][jj]; } } } } else if ((i + j) % 2 == 1) { l = l + matrix[i - 1][j]; l = l + matrix[i + 1][j]; l = l + matrix[i][j - 1]; l = l + matrix[i][j + 1]; } return(l); }
//ULAM neighbourhood for the mesh RECTANGLE_SQUARE override public int neightbours_number(ModuloIndexableList <ModuloIndexableList <int> > matrix, int i, int j) { int l = 0; if (j % 3 == 0) { l = l + matrix[i][j - 1]; l = l + matrix[i][j - 2]; l = l + matrix[i][j + 1]; l = l + matrix[i][j + 2]; l = l + matrix[i - 1][j + 4]; l = l + matrix[i - 1][j + 1]; } else if (j % 3 == 1) { l = l + matrix[i][j - 1]; l = l + matrix[i][j + 1]; l = l + matrix[i][j + 2]; l = l + matrix[i + 1][j - 2]; l = l + matrix[i + 1][j - 1]; l = l + matrix[i + 1][j - 4]; } else if (j % 3 == 2) { l = l + matrix[i][j - 2]; l = l + matrix[i][j - 1]; l = l + matrix[i][j + 1]; l = l + matrix[i - 1][j + 2]; } else { System.Console.WriteLine("False."); } return(l); }
//Is the state of given cell living (1) or dead (0) //The program can display age of cells, hence the numbers public int live(ModuloIndexableList <ModuloIndexableList <int> > matrix, List <List <int> > rule, int i, int j) { //Rows of rule correspond the states int n = neightbours_number(matrix, i, j); if (matrix[i][j] > 0) { if (rule[1].Contains(n)) { return(1); } else { return(0); } } else if (matrix[i][j] == 0) { if (rule[0].Contains(n)) { return(1); } else { return(0); } } else { return(0); } }
override public int neightbours_number(ModuloIndexableList <ModuloIndexableList <int> > matrix, int i, int j) { //A koordinátákat azért kell felxcserélni, hogy összhangban legyünk a rajzolással int l = phc.neightbours_number(matrix, i, j); if (j % 4 == 0) { l = l + matrix[i - 1][j - 1]; l = l + matrix[i + 1][j - 1]; } else if (j % 4 == 1) { l = l + matrix[i - 1][j + 1]; l = l + matrix[i + 1][j + 1]; } else if (j % 4 == 2) { l = l + matrix[i - 1][j - 1]; l = l + matrix[i - 1][j + 3]; } else if (j % 4 == 3) { l = l + matrix[i + 1][j - 3]; l = l + matrix[i + 1][j + 1]; } else { System.Console.WriteLine("False."); } return(l); }
//ULAM neighbourhood for the mesh TRIANGLE override public int neightbours_number(ModuloIndexableList <ModuloIndexableList <int> > matrix, int i, int j) { int l = 0; if (i % 4 == 0) { l = l + matrix[i - 1][j]; l = l + matrix[i + 1][j - 1]; l = l + matrix[i + 1][j]; } else if (i % 4 == 1) { l = l + matrix[i - 1][j]; l = l + matrix[i + 1][j]; l = l + matrix[i - 1][j + 1]; } else if (i % 4 == 2) { l = l + matrix[i - 1][j]; l = l + matrix[i + 1][j]; l = l + matrix[i + 1][j + 1]; } else if (i % 4 == 3) { l = l + matrix[i - 1][j - 1]; l = l + matrix[i + 1][j]; l = l + matrix[i - 1][j]; } return(l); }
override public int neightbours_number(ModuloIndexableList <ModuloIndexableList <int> > matrix, int i, int j) { int l = phc.neightbours_number(matrix, i, j); if (i % 4 == 0) { if (j % 2 == 0) { l = l + matrix[i + 1][j + 1]; } else if (j % 2 == 1) { ; } } else if (i % 4 == 1) { if (j % 2 == 0) { l = l + matrix[i + 1][j + 1]; } else if (j % 2 == 1) { l = l + matrix[i + 1][j - 1]; } } else if (i % 4 == 2) { if (j % 2 == 0) { l = l + matrix[i + 1][j + 1]; l = l + matrix[i + 1][j + 2]; } else if (j % 2 == 1) { ; } } else if (i % 4 == 3) { if (j % 2 == 0) { l = l + matrix[i - 1][j + 1]; l = l + matrix[i + 1][j - 1]; } else if (j % 2 == 1) { ; } } else { System.Console.WriteLine("False."); } return(l); }
//ULAM neighbourhood for the mesh SQUARE //Calculates neighbourhood number of one cell override public int neightbours_number(ModuloIndexableList <ModuloIndexableList <int> > matrix, int i, int j) { int l = 0; l = l + matrix[i - 1][j]; l = l + matrix[i + 1][j]; l = l + matrix[i][j - 1]; l = l + matrix[i][j + 1]; return(l); }
//ULAM neighbourhood for the mesh SQUARE_TRIANGLE1 //Calculates neighbourhood number of one cell override public int neightbours_number(ModuloIndexableList <ModuloIndexableList <int> > matrix, int i, int j) { int l = 0; if (i % 2 == 0) { if (j % 3 == 0) { l = l + matrix[i - 1][j - 1]; l = l + matrix[i - 1][j + 2]; l = l + matrix[i][j + 1]; } else if (j % 3 == 1) { l = l + matrix[i][j - 1]; l = l + matrix[i][j + 3]; l = l + matrix[i][j + 1]; l = l + matrix[i][j - 3]; } else if (j % 3 == 2) { l = l + matrix[i][j - 1]; l = l + matrix[i + 1][j - 2]; l = l + matrix[i + 1][j - 5]; } } else if (i % 2 == 1) { if (j % 3 == 0) { l = l + matrix[i - 1][j + 2]; l = l + matrix[i - 1][j + 5]; l = l + matrix[i][j + 1]; } else if (j % 3 == 1) { l = l + matrix[i][j - 1]; l = l + matrix[i][j + 3]; l = l + matrix[i][j + 1]; l = l + matrix[i][j - 3]; } else if (j % 3 == 2) { l = l + matrix[i][j - 1]; l = l + matrix[i + 1][j + 1]; l = l + matrix[i + 1][j - 2]; } } return(l); }
//KNIGHT neighbourhood for the mesh TRIANGLE //Calculates neighbourhood number of one cell override public int neightbours_number(ModuloIndexableList <ModuloIndexableList <int> > matrix, int i, int j) { TriangleUlamNeightbourHandler thc = new TriangleUlamNeightbourHandler(); int l = thc.neightbours_number(matrix, i, j); if (i % 4 == 0) { l = l + matrix[i - 3][j - 1]; l = l + matrix[i - 3][j]; l = l + matrix[i + 1][j + 1]; l = l + matrix[i + 3][j + 1]; l = l + matrix[i + 1][j - 2]; l = l + matrix[i + 3][j - 1]; } else if (i % 4 == 1) { l = l + matrix[i - 3][j - 1]; l = l + matrix[i - 1][j - 1]; l = l + matrix[i + 3][j]; l = l + matrix[i + 3][j + 1]; l = l + matrix[i - 3][j + 1]; l = l + matrix[i - 1][j + 2]; } else if (i % 4 == 2) { l = l + matrix[i - 3][j + 1]; l = l + matrix[i - 3][j]; l = l + matrix[i + 1][j + 2]; l = l + matrix[i + 3][j + 1]; l = l + matrix[i + 1][j - 1]; l = l + matrix[i + 3][j - 1]; } else if (i % 4 == 3) { l = l + matrix[i - 3][j - 1]; l = l + matrix[i - 1][j - 2]; l = l + matrix[i + 3][j]; l = l + matrix[i + 3][j - 1]; l = l + matrix[i - 3][j + 1]; l = l + matrix[i - 1][j + 1]; } return(l); }
override public int neightbours_number(ModuloIndexableList <ModuloIndexableList <int> > matrix, int i, int j) { int l = phc.neightbours_number(matrix, i, j); if (j % 6 == 0) { l = l + matrix[i][j + 2]; l = l + matrix[i][j + 3]; l = l + matrix[i][j + 4]; } else if (j % 6 == 1) { l = l + matrix[i][j + 2]; l = l + matrix[i][j + 3]; l = l + matrix[i][j + 4]; } else if (j % 6 == 2) { l = l + matrix[i][j + 2]; l = l + matrix[i][j + 3]; l = l + matrix[i][j - 2]; } else if (j % 6 == 3) { l = l + matrix[i][j + 2]; l = l + matrix[i][j - 3]; l = l + matrix[i][j - 2]; } else if (j % 6 == 4) { l = l + matrix[i][j - 4]; l = l + matrix[i][j - 3]; l = l + matrix[i][j - 2]; } else if (j % 6 == 5) { l = l + matrix[i][j - 4]; l = l + matrix[i][j - 3]; l = l + matrix[i][j - 2]; } else { System.Console.WriteLine("False."); } return(l); }
//ULAM neighbourhood for the mesh RECTANGLE2 //Calculates neighbourhood number of one cell override public int neightbours_number(ModuloIndexableList <ModuloIndexableList <int> > matrix, int i, int j) { int l = 0; //A koordinátákat azért kell felcserélni, hogy összhangban legyünk a rajzolással if (j % 4 == 0) { l = l + matrix[i - 1][j + 1]; l = l + matrix[i][j + 1]; l = l + matrix[i + 1][j + 1]; l = l + matrix[i][j - 1]; l = l + matrix[i][j - 2]; } else if (j % 4 == 1) { l = l + matrix[i - 1][j]; l = l + matrix[i][j - 1]; l = l + matrix[i + 1][j - 1]; l = l + matrix[i][j + 2]; l = l + matrix[i][j - 1]; } else if (j % 4 == 2) { l = l + matrix[i - 1][j]; l = l + matrix[i - 1][j + 1]; l = l + matrix[i][j + 2]; l = l + matrix[i][j + 1]; l = l + matrix[i][j - 1]; } else if (j % 4 == 3) { l = l + matrix[i][j - 1]; l = l + matrix[i][j + 1]; l = l + matrix[i + 1][j]; l = l + matrix[i + 1][j - 1]; l = l + matrix[i][j - 2]; } return(l); }
//Calculates neighbourhood number of one cell abstract public int neightbours_number(ModuloIndexableList <ModuloIndexableList <int> > matrix, int i, int j);
//Calculates neighbourhood number of one cell override public int neightbours_number(ModuloIndexableList <ModuloIndexableList <int> > matrix, int i, int j) { int l = phc.neightbours_number(matrix, i, j); if (i % 3 == 0) { if (j % 9 == 0) { l = l + matrix[i][j - 1]; l = l + matrix[i][j - 2]; l = l + matrix[i + 1][j - 4]; l = l + matrix[i + 1][j - 1]; l = l + matrix[i + 1][j + 6]; l = l + matrix[i + 1][j + 7]; l = l + matrix[i][j + 10]; l = l + matrix[i][j + 8]; l = l + matrix[i - 1][j + 11]; l = l + matrix[i - 1][j + 7]; l = l + matrix[i - 1][j + 3]; l = l + matrix[i][j - 5]; } else if (j % 9 == 1) { l = l + matrix[i][j - 10]; l = l + matrix[i][j - 7]; l = l + matrix[i + 1][j - 5]; l = l + matrix[i][j + 1]; l = l + matrix[i][j + 5]; l = l + matrix[i][j - 2]; } else if (j % 9 == 2) { l = l + matrix[i][j - 1]; l = l + matrix[i][j - 4]; l = l + matrix[i + 1][j - 11]; l = l + matrix[i + 1][j + 4]; l = l + matrix[i + 1][j - 7]; l = l + matrix[i][j + 1]; } else if (j % 9 == 3) { l = l + matrix[i][j - 1]; l = l + matrix[i + 1][j - 4]; l = l + matrix[i + 1][j - 3]; l = l + matrix[i + 1][j + 2]; l = l + matrix[i][j + 7]; l = l + matrix[i][j + 1]; } else if (j % 9 == 4) { l = l + matrix[i][j - 1]; l = l + matrix[i + 1][j + 3]; l = l + matrix[i][j + 5]; l = l + matrix[i][j + 11]; l = l + matrix[i - 1][j + 7]; l = l + matrix[i][j + 1]; } else if (j % 9 == 5) { l = l + matrix[i - 1][j - 2]; l = l + matrix[i][j + 1]; l = l + matrix[i - 1][j + 4]; l = l + matrix[i][j + 3]; l = l + matrix[i][j - 1]; l = l + matrix[i - 1][j + 5]; } else if (j % 9 == 6) { l = l + matrix[i - 1][j - 6]; l = l + matrix[i - 1][j - 4]; l = l + matrix[i][j - 11]; l = l + matrix[i][j - 5]; l = l + matrix[i - 1][j + 1]; l = l + matrix[i][j - 1]; } else if (j % 9 == 7) { l = l + matrix[i][j - 7]; l = l + matrix[i][j + 2]; l = l + matrix[i + 1][j - 7]; l = l + matrix[i + 1][j - 1]; l = l + matrix[i][j + 4]; l = l + matrix[i][j - 3]; } else if (j % 9 == 8) { l = l + matrix[i][j - 8]; l = l + matrix[i - 1][j + 1]; l = l + matrix[i][j + 1]; l = l + matrix[i][j - 3]; l = l + matrix[i][j + 2]; l = l + matrix[i - 1][j + 4]; } } else if (i % 3 == 1) { if (j % 9 == 0) { l = l + matrix[i][j - 1]; l = l + matrix[i][j - 2]; l = l + matrix[i][j - 5]; l = l + matrix[i + 1][j + 5]; l = l + matrix[i + 1][j + 8]; l = l + matrix[i + 1][j + 15]; l = l + matrix[i][j + 7]; l = l + matrix[i][j + 10]; l = l + matrix[i][j + 8]; l = l + matrix[i - 1][j + 11]; l = l + matrix[i - 1][j + 7]; l = l + matrix[i - 1][j + 3]; } else if (j % 9 == 1) { l = l + matrix[i][j - 10]; l = l + matrix[i][j - 7]; l = l + matrix[i + 1][j + 4]; l = l + matrix[i][j + 1]; l = l + matrix[i][j + 5]; l = l + matrix[i][j - 2]; } else if (j % 9 == 2) { l = l + matrix[i][j - 1]; l = l + matrix[i][j - 4]; l = l + matrix[i + 1][j - 2]; l = l + matrix[i + 1][j + 4]; l = l + matrix[i + 1][j - 7]; l = l + matrix[i + 1][j + 1]; } else if (j % 9 == 3) { l = l + matrix[i][j - 1]; l = l + matrix[i + 1][j - 4]; l = l + matrix[i + 1][j - 3]; l = l + matrix[i + 1][j + 2]; l = l + matrix[i + 1][j + 7]; l = l + matrix[i + 1][j + 1]; } else if (j % 9 == 4) { l = l + matrix[i][j - 1]; l = l + matrix[i][j + 3]; l = l + matrix[i][j + 5]; l = l + matrix[i][j + 11]; l = l + matrix[i - 1][j + 7]; l = l + matrix[i][j + 1]; } else if (j % 9 == 5) { l = l + matrix[i][j - 1]; l = l + matrix[i][j + 3]; l = l + matrix[i - 1][j + 4]; l = l + matrix[i - 1][j + 5]; l = l + matrix[i - 1][j - 2]; l = l + matrix[i][j + 1]; } else if (j % 9 == 6) { l = l + matrix[i - 1][j - 6]; l = l + matrix[i - 1][j - 3]; l = l + matrix[i][j - 11]; l = l + matrix[i][j - 5]; l = l + matrix[i - 1][j + 1]; l = l + matrix[i - 1][j + 6]; } else if (j % 9 == 7) { l = l + matrix[i + 1][j + 8]; l = l + matrix[i + 1][j + 2]; l = l + matrix[i][j - 7]; l = l + matrix[i][j - 3]; l = l + matrix[i][j + 2]; l = l + matrix[i][j + 4]; } else if (j % 9 == 8) { l = l + matrix[i - 1][j + 1]; l = l + matrix[i][j - 8]; l = l + matrix[i][j + 1]; l = l + matrix[i][j + 2]; l = l + matrix[i][j + 4]; l = l + matrix[i][j - 3]; } } if (i % 3 == 2) { if (j % 9 == 0) { l = l + matrix[i][j - 1]; l = l + matrix[i][j - 2]; l = l + matrix[i][j - 5]; l = l + matrix[i + 1][j - 4]; l = l + matrix[i + 1][j - 1]; l = l + matrix[i + 1][j + 6]; l = l + matrix[i][j + 7]; l = l + matrix[i][j + 10]; l = l + matrix[i][j + 8]; l = l + matrix[i - 1][j + 2]; l = l + matrix[i - 1][j - 2]; l = l + matrix[i - 1][j - 6]; } else if (j % 9 == 1) { l = l + matrix[i][j - 10]; l = l + matrix[i][j - 7]; l = l + matrix[i + 1][j - 5]; l = l + matrix[i][j + 1]; l = l + matrix[i][j + 5]; l = l + matrix[i][j - 2]; } else if (j % 9 == 2) { l = l + matrix[i][j - 4]; l = l + matrix[i][j - 1]; l = l + matrix[i + 1][j - 3]; l = l + matrix[i + 1][j + 4]; l = l + matrix[i][j + 1]; l = l + matrix[i + 1][j - 11]; } else if (j % 9 == 3) { l = l + matrix[i][j - 1]; l = l + matrix[i + 1][j - 4]; l = l + matrix[i + 1][j - 3]; l = l + matrix[i + 1][j + 4]; l = l + matrix[i][j + 1]; l = l + matrix[i][j - 11]; } else if (j % 9 == 4) { l = l + matrix[i][j - 1]; l = l + matrix[i][j + 3]; l = l + matrix[i][j + 5]; l = l + matrix[i][j + 11]; l = l + matrix[i - 1][j - 2]; l = l + matrix[i][j + 1]; } else if (j % 9 == 5) { l = l + matrix[i][j + 3]; l = l + matrix[i][j - 1]; l = l + matrix[i - 1][j - 5]; l = l + matrix[i - 1][j - 4]; l = l + matrix[i][j - 11]; l = l + matrix[i][j + 1]; } else if (j % 9 == 6) { l = l + matrix[i][j - 11]; l = l + matrix[i][j - 5]; l = l + matrix[i][j - 1]; l = l + matrix[i][j - 8]; l = l + matrix[i - 1][j - 13]; l = l + matrix[i - 1][j - 15]; } else if (j % 9 == 7) { l = l + matrix[i][j - 7]; l = l + matrix[i + 1][j - 7]; l = l + matrix[i][j + 2]; l = l + matrix[i + 1][j - 1]; l = l + matrix[i][j + 4]; l = l + matrix[i][j - 3]; } else if (j % 9 == 8) { l = l + matrix[i][j - 3]; l = l + matrix[i][j - 8]; l = l + matrix[i][j + 1]; l = l + matrix[i][j + 7]; l = l + matrix[i - 1][j - 8]; l = l + matrix[i - 1][j - 5]; } } return(l); }
//ULAM neighbourhood for the mesh PENTAGON12 //Calculates neighbourhood number of one cell override public int neightbours_number(ModuloIndexableList <ModuloIndexableList <int> > matrix, int i, int j) { int l = 0; //Rectangle1-et kell felosztani if (i % 2 == 0) { if (j % 8 == 0) { l = l + matrix[i - 1][j + 3]; l = l + matrix[i][j + 1]; l = l + matrix[i][j - 4]; l = l + matrix[i][j - 2]; } else if (j % 8 == 1) { l = l + matrix[i][j - 1]; l = l + matrix[i][j + 1]; l = l + matrix[i + 1][j - 1]; } else if (j % 8 == 2) { l = l + matrix[i - 1][j + 1]; l = l + matrix[i][j + 1]; l = l + matrix[i][j - 1]; } else if (j % 8 == 3) { l = l + matrix[i][j - 1]; l = l + matrix[i][j + 2]; l = l + matrix[i][j + 4]; l = l + matrix[i + 1][j - 3]; } else if (j % 8 == 4) { l = l + matrix[i - 1][j + 1]; l = l + matrix[i - 1][j + 3]; l = l + matrix[i][j + 4]; l = l + matrix[i][j + 1]; } else if (j % 8 == 5) { l = l + matrix[i][j - 1]; l = l + matrix[i][j + 1]; l = l + matrix[i + 1][j - 2]; } else if (j % 8 == 6) { l = l + matrix[i][j - 1]; l = l + matrix[i][j + 1]; l = l + matrix[i][j + 2]; } else if (j % 8 == 7) { l = l + matrix[i][j - 1]; l = l + matrix[i][j - 4]; l = l + matrix[i + 1][j - 3]; l = l + matrix[i + 1][j - 1]; } } else if (i % 2 == 1) { if (j % 8 == 0) { l = l + matrix[i - 1][j + 1]; l = l + matrix[i - 1][j + 3]; l = l + matrix[i][j + 4]; l = l + matrix[i][j + 1]; } else if (j % 8 == 1) { l = l + matrix[i][j - 1]; l = l + matrix[i][j + 1]; l = l + matrix[i + 1][j - 2]; } else if (j % 8 == 2) { l = l + matrix[i][j - 1]; l = l + matrix[i][j + 1]; l = l + matrix[i][j + 2]; } else if (j % 8 == 3) { l = l + matrix[i][j - 1]; l = l + matrix[i][j - 4]; l = l + matrix[i + 1][j - 3]; l = l + matrix[i + 1][j - 1]; } else if (j % 8 == 4) { l = l + matrix[i - 1][j + 3]; l = l + matrix[i][j + 1]; l = l + matrix[i][j - 4]; l = l + matrix[i][j - 2]; } else if (j % 8 == 5) { l = l + matrix[i][j - 1]; l = l + matrix[i][j + 1]; l = l + matrix[i + 1][j - 1]; } else if (j % 8 == 6) { l = l + matrix[i - 1][j + 1]; l = l + matrix[i][j + 1]; l = l + matrix[i][j - 1]; } else if (j % 8 == 7) { l = l + matrix[i][j - 1]; l = l + matrix[i][j - 4]; l = l + matrix[i + 1][j - 3]; l = l + matrix[i + 1][j - 1]; } } return(l); }
//ULAM neighbourhood for the mesh PENTAGON11 //Calculates neighbourhood number of one cell override public int neightbours_number(ModuloIndexableList <ModuloIndexableList <int> > matrix, int i, int j) { int l = 0; //Pentagon4-et kell felosztani if (j % 8 == 0) { l = l + matrix[i][j - 5]; l = l + matrix[i][j + 1]; l = l + matrix[i][j - 4]; l = l + matrix[i][j + 7]; } else if (j % 8 == 1) { l = l + matrix[i][j - 6]; l = l + matrix[i - 1][j + 6]; l = l + matrix[i - 1][j + 5]; l = l + matrix[i][j + 1]; l = l + matrix[i][j - 1]; } else if (j % 8 == 2) { l = l + matrix[i][j - 1]; l = l + matrix[i][j + 5]; l = l + matrix[i + 1][j - 1]; l = l + matrix[i + 1][j - 2]; } else if (j % 8 == 3) { l = l + matrix[i][j - 1]; l = l + matrix[i - 1][j + 2]; l = l + matrix[i][j + 6]; l = l + matrix[i][j + 5]; l = l + matrix[i][j + 11]; } else if (j % 8 == 4) { l = l + matrix[i][j - 1]; l = l + matrix[i][j + 4]; l = l + matrix[i][j + 11]; l = l + matrix[i][j + 1]; } else if (j % 8 == 5) { l = l + matrix[i][j - 1]; l = l + matrix[i][j + 10]; l = l + matrix[i + 1][j - 2]; l = l + matrix[i + 1][j - 3]; l = l + matrix[i][j + 1]; } else if (j % 8 == 6) { l = l + matrix[i][j - 1]; l = l + matrix[i + 1][j - 4]; l = l + matrix[i + 1][j - 5]; l = l + matrix[i][j + 1]; } else if (j % 8 == 7) { l = l + matrix[i][j - 1]; l = l + matrix[i + 1][j - 6]; l = l + matrix[i][j - 10]; l = l + matrix[i][j - 11]; l = l + matrix[i][j - 7]; } return(l); }