private bool[,,,] IncreaseConfiguration4D(bool[,,,] configuration) { var xLength = configuration.GetLength(0); var yLength = configuration.GetLength(1); var zLength = configuration.GetLength(2); var wLength = configuration.GetLength(3); var increasedConfiguration = new bool[xLength + 2, yLength + 2, zLength + 2, wLength + 2]; for (int x = 0; x < xLength; x++) { for (int y = 0; y < yLength; y++) { for (int z = 0; z < zLength; z++) { for (int w = 0; w < wLength; w++) { if (configuration[x, y, z, w] == true) { increasedConfiguration[x + 1, y + 1, z + 1, w + 1] = true; } } } } } return(increasedConfiguration); }
private bool[,,,] ProcessChanges4D(bool[,,,] changes, bool[,,,] configuration) { var xLength = configuration.GetLength(0); var yLength = configuration.GetLength(1); var zLength = configuration.GetLength(2); var wLength = configuration.GetLength(3); for (int x = 0; x < xLength; x++) { for (int y = 0; y < yLength; y++) { for (int z = 0; z < zLength; z++) { for (int w = 0; w < wLength; w++) { if (changes[x, y, z, w] == true) { if (configuration[x, y, z, w] == true) { configuration[x, y, z, w] = false; } else { configuration[x, y, z, w] = true; } } } } } } return(configuration); }
public override void write(Object obj1, BOutput bout1, long version) { BOutputBin bout = (BOutputBin)bout1; BBufferBin bbuf = bout.bbuf; bool[,,,] arr = (bool[, , , ])obj1; // lengths int n3 = arr.GetLength(0); int n2 = arr.GetLength(1); int n1 = arr.GetLength(2); int n0 = arr.GetLength(3); bbuf.putLength(n3); bbuf.putLength(n2); bbuf.putLength(n1); bbuf.putLength(n0); // write for (int i3 = 0; i3 < n3; i3++) { for (int i2 = 0; i2 < n2; i2++) { for (int i1 = 0; i1 < n1; i1++) { for (int i0 = 0; i0 < n0; i0++) { bbuf.putBoolean(arr[i3, i2, i1, i0]); } } } } }
private int CountActiveCubes4D(bool[,,,] configuration) { var xLength = configuration.GetLength(0); var yLength = configuration.GetLength(1); var zLength = configuration.GetLength(2); var wLength = configuration.GetLength(3); var activeCubes = 0; for (int x = 0; x < xLength; x++) { for (int y = 0; y < yLength; y++) { for (int z = 0; z < zLength; z++) { for (int w = 0; w < wLength; w++) { if (configuration[x, y, z, w] == true) { activeCubes++; } } } } } return(activeCubes); }
private int ActiveNeighbors(bool[,,,] space, int x, int y, int z, int w) { int size = space.GetLength(0); int activeneighbors = 0; for (int dx = -1; dx <= 1; dx++) { for (int dy = -1; dy <= 1; dy++) { for (int dz = -1; dz <= 1; dz++) { for (int dw = -1; dw <= 1; dw++) { int x2 = x + dx, y2 = y + dy, z2 = z + dz, w2 = w + dw; if (x2 >= 0 && x2 < size && y2 >= 0 && y2 < size && z2 >= 0 && z2 < size && w2 >= 0 && w2 < size && !(x2 == x && y2 == y && z2 == z && w2 == w) && space[x2, y2, z2, w2]) { activeneighbors++; } } } } } return(activeneighbors); }
private void RunCycle(ref bool[,,,] space) { int size = space.GetLength(0); bool[,,,] nextspace = new bool[size, size, size, size]; for (int x = 0; x < size; x++) { for (int y = 0; y < size; y++) { for (int z = 0; z < size; z++) { for (int w = 0; w < size; w++) { int activeneighbors = ActiveNeighbors(space, x, y, z, w); if (space[x, y, z, w]) { nextspace[x, y, z, w] = activeneighbors == 2 || activeneighbors == 3; } else { nextspace[x, y, z, w] = activeneighbors == 3; } } } } } space = nextspace; }
private static bool[,,,] SimulateCycle(bool[,,,] cube) { var length = cube.GetLength(1); var newCube = new bool[length, length, length, length]; // Don't consider outer dimensions of cube. for (var x = 0; x < length; x++) { for (var y = 0; y < length; y++) { for (var z = 0; z < length; z++) { for (var w = 0; w < length; w++) { var currentlyActive = cube[x, y, z, w]; var activeNeighbours = ActiveNeighbours(cube, x, y, z, w); if (currentlyActive) { newCube[x, y, z, w] = (activeNeighbours == 2 || activeNeighbours == 3); } else { newCube[x, y, z, w] = activeNeighbours == 3; } } } } } return(newCube); }
private void RunCycle() { var newState = new bool[ _state.GetLength(0) + 2, _state.GetLength(1) + 2, _state.GetLength(2) + 2, _state.GetLength(3) + 2 ]; for (var x = 0; x < newState.GetLength(0); x++) { for (var y = 0; y < newState.GetLength(1); y++) { for (var z = 0; z < newState.GetLength(2); z++) { for (var w = 0; w < newState.GetLength(3); w++) { var neighbours = GetNeighbours(x, y, z, w); if (IsActive(x, y, z, w)) { newState[x, y, z, w] = (neighbours == 2 || neighbours == 3); } else { newState[x, y, z, w] = neighbours == 3; } } } } } _state = newState; }
private bool[,,,] StateChanges4D(bool[,,,] configuration) { var xLength = configuration.GetLength(0); var yLength = configuration.GetLength(1); var zLength = configuration.GetLength(2); var wLength = configuration.GetLength(3); var changes = new bool[xLength, yLength, zLength, wLength]; for (int x = 0; x < xLength; x++) { for (int y = 0; y < yLength; y++) { for (int z = 0; z < zLength; z++) { for (int w = 0; w < wLength; w++) { var activeNeighbors = GetActiveNeighbors4D(x, y, z, w, configuration); if (configuration[x, y, z, w] == true) { if (activeNeighbors != 3 && activeNeighbors != 4) { changes[x, y, z, w] = true; } } if (configuration[x, y, z, w] == false) { if (activeNeighbors == 3) { changes[x, y, z, w] = true; } } } } } } return(changes); }
private int GetActiveNeighbors4D(int xLocation, int yLocation, int zLocation, int wLocation, bool[,,,] configuration) { var xLength = configuration.GetLength(0); var yLength = configuration.GetLength(1); var zLength = configuration.GetLength(2); var wLength = configuration.GetLength(3); var activeNeighbors = 0; var xValues = new List <int>(); var yValues = new List <int>(); var zValues = new List <int>(); var wValues = new List <int>(); xValues = GetValues(xLocation, xLength); yValues = GetValues(yLocation, yLength); zValues = GetValues(zLocation, zLength); wValues = GetValues(wLocation, wLength); for (int x = xValues.Min(); x <= xValues.Max(); x++) { for (int y = yValues.Min(); y <= yValues.Max(); y++) { for (int z = zValues.Min(); z <= zValues.Max(); z++) { for (int w = wValues.Min(); w <= wValues.Max(); w++) { if (configuration[x, y, z, w] == true) { activeNeighbors++; } } } } } return(activeNeighbors); }
/// <summary> /// Chnage bool[,,] to bool[] /// </summary> /// <param name="input"></param> /// <returns></returns> public static bool[] ChangeArray4dimTo1dim(bool[,,,] input) { int row = input.GetLength(0); int colmun = input.GetLength(1); int depth = input.GetLength(2); int dim4 = input.GetLength(3); bool[] result = new bool[row * colmun * depth * dim4]; for (int i = 0; i < row; i++) { for (int j = 0; j < colmun; j++) { for (int k = 0; k < depth; k++) { for (int l = 0; l < dim4; l++) { result[i * colmun * depth * dim4 + j * depth * dim4 + k * dim4 + l] = input[i, j, k, l]; } } } } return(result); }
private static int ActiveNeighbours(bool[,,,] cube, int x, int y, int z, int w) { var activeNeighbours = 0; var max = cube.GetLength(1); foreach (var xDelta in Enumerable.Range(-1, 3)) { foreach (var yDelta in Enumerable.Range(-1, 3)) { foreach (var zDelta in Enumerable.Range(-1, 3)) { foreach (var wDelta in Enumerable.Range(-1, 3)) { if (xDelta == 0 && yDelta == 0 && zDelta == 0 && wDelta == 0) { continue; } if (x + xDelta < 0 || x + xDelta >= max) { continue; } if (y + yDelta < 0 || y + yDelta >= max) { continue; } if (z + zDelta < 0 || z + zDelta >= max) { continue; } if (w + wDelta < 0 || w + wDelta >= max) { continue; } if (cube[x + xDelta, y + yDelta, z + zDelta, w + wDelta]) { activeNeighbours++; } } } } } return(activeNeighbours); }
/// <summary> /// Change bool[,,,] to string[,,] /// </summary> /// <param name="input"></param> /// <returns></returns> public static string[,,,] NumberToString(bool[,,,] input) { string[,,,] result = new string[input.GetLength(0), input.GetLength(1), input.GetLength(2), input.GetLength(3)]; for (int i = 0; i < input.GetLength(0); i++) { for (int j = 0; j < input.GetLength(1); j++) { for (int k = 0; k < input.GetLength(2); k++) { for (int L = 0; L < input.GetLength(3); L++) { result[i, j, k, L] = input[i, j, k, L].ToString(); } } } } return(result); }
private static int CountActiveCubes(bool[,,,] cube) { var active = 0; var length = cube.GetLength(1); for (var z = 0; z < length; z++) { for (var y = 0; y < length; y++) { for (var x = 0; x < length; x++) { for (var w = 0; w < length; w++) { if (cube[x, y, z, w]) { active++; } } } } } return(active); }
private static void PrintCube(bool[,,,] cube) { var length = cube.GetLength(1); for (var w = 0; w < length; w++) { Console.WriteLine($"w={w - (length / 2)}"); for (var z = 0; z < length; z++) { Console.WriteLine($"z={z - (length / 2)}"); for (var y = 0; y < length; y++) { for (var x = 0; x < length; x++) { var active = cube[x, y, z, w]; Console.Write(active ? "#" : "."); } Console.WriteLine(); } Console.WriteLine(); } } }
private static bool[,,,] Cycle4D(bool[,,,] nodes) { bool[,,,] nodes2 = (bool[, , , ])nodes.Clone(); int maxx = nodes.GetLength(0); int maxy = nodes.GetLength(1); int maxz = nodes.GetLength(2); int maxw = nodes.GetLength(2); for (int x = 1; x < maxx - 1; x++) { for (int y = 1; y < maxy - 1; y++) { for (int z = 1; z < maxz - 1; z++) { for (int w = 1; w < maxw - 1; w++) { int count = 0; if (nodes[x - 1, y - 1, z - 1, w - 1]) { count++; } if (nodes[x - 1, y - 1, z - 1, w + 0]) { count++; } if (nodes[x - 1, y - 1, z - 1, w + 1]) { count++; } if (nodes[x - 1, y - 1, z + 0, w - 1]) { count++; } if (nodes[x - 1, y - 1, z + 0, w + 0]) { count++; } if (nodes[x - 1, y - 1, z + 0, w + 1]) { count++; } if (nodes[x - 1, y - 1, z + 1, w - 1]) { count++; } if (nodes[x - 1, y - 1, z + 1, w + 0]) { count++; } if (nodes[x - 1, y - 1, z + 1, w + 1]) { count++; } if (nodes[x - 1, y + 0, z - 1, w - 1]) { count++; } if (nodes[x - 1, y + 0, z - 1, w + 0]) { count++; } if (nodes[x - 1, y + 0, z - 1, w + 1]) { count++; } if (nodes[x - 1, y + 0, z + 0, w - 1]) { count++; } if (nodes[x - 1, y + 0, z + 0, w + 0]) { count++; } if (nodes[x - 1, y + 0, z + 0, w + 1]) { count++; } if (nodes[x - 1, y + 0, z + 1, w - 1]) { count++; } if (nodes[x - 1, y + 0, z + 1, w + 0]) { count++; } if (nodes[x - 1, y + 0, z + 1, w + 1]) { count++; } if (nodes[x - 1, y + 1, z - 1, w - 1]) { count++; } if (nodes[x - 1, y + 1, z - 1, w + 0]) { count++; } if (nodes[x - 1, y + 1, z - 1, w + 1]) { count++; } if (nodes[x - 1, y + 1, z + 0, w - 1]) { count++; } if (nodes[x - 1, y + 1, z + 0, w + 0]) { count++; } if (nodes[x - 1, y + 1, z + 0, w + 1]) { count++; } if (nodes[x - 1, y + 1, z + 1, w - 1]) { count++; } if (nodes[x - 1, y + 1, z + 1, w + 0]) { count++; } if (nodes[x - 1, y + 1, z + 1, w + 1]) { count++; } if (nodes[x + 0, y - 1, z - 1, w - 1]) { count++; } if (nodes[x + 0, y - 1, z - 1, w + 0]) { count++; } if (nodes[x + 0, y - 1, z - 1, w + 1]) { count++; } if (nodes[x + 0, y - 1, z + 0, w - 1]) { count++; } if (nodes[x + 0, y - 1, z + 0, w + 0]) { count++; } if (nodes[x + 0, y - 1, z + 0, w + 1]) { count++; } if (nodes[x + 0, y - 1, z + 1, w - 1]) { count++; } if (nodes[x + 0, y - 1, z + 1, w + 0]) { count++; } if (nodes[x + 0, y - 1, z + 1, w + 1]) { count++; } if (nodes[x + 0, y + 0, z - 1, w - 1]) { count++; } if (nodes[x + 0, y + 0, z - 1, w + 0]) { count++; } if (nodes[x + 0, y + 0, z - 1, w + 1]) { count++; } if (nodes[x + 0, y + 0, z + 0, w - 1]) { count++; } if (nodes[x + 0, y + 0, z + 0, w + 0]) { count++; } if (nodes[x + 0, y + 0, z + 0, w + 1]) { count++; } if (nodes[x + 0, y + 0, z + 1, w - 1]) { count++; } if (nodes[x + 0, y + 0, z + 1, w + 0]) { count++; } if (nodes[x + 0, y + 0, z + 1, w + 1]) { count++; } if (nodes[x + 0, y + 1, z - 1, w - 1]) { count++; } if (nodes[x + 0, y + 1, z - 1, w + 0]) { count++; } if (nodes[x + 0, y + 1, z - 1, w + 1]) { count++; } if (nodes[x + 0, y + 1, z + 0, w - 1]) { count++; } if (nodes[x + 0, y + 1, z + 0, w + 0]) { count++; } if (nodes[x + 0, y + 1, z + 0, w + 1]) { count++; } if (nodes[x + 0, y + 1, z + 1, w - 1]) { count++; } if (nodes[x + 0, y + 1, z + 1, w + 0]) { count++; } if (nodes[x + 0, y + 1, z + 1, w + 1]) { count++; } if (nodes[x + 1, y - 1, z - 1, w - 1]) { count++; } if (nodes[x + 1, y - 1, z - 1, w + 0]) { count++; } if (nodes[x + 1, y - 1, z - 1, w + 1]) { count++; } if (nodes[x + 1, y - 1, z + 0, w - 1]) { count++; } if (nodes[x + 1, y - 1, z + 0, w + 0]) { count++; } if (nodes[x + 1, y - 1, z + 0, w + 1]) { count++; } if (nodes[x + 1, y - 1, z + 1, w - 1]) { count++; } if (nodes[x + 1, y - 1, z + 1, w + 0]) { count++; } if (nodes[x + 1, y - 1, z + 1, w + 1]) { count++; } if (nodes[x + 1, y + 0, z - 1, w - 1]) { count++; } if (nodes[x + 1, y + 0, z - 1, w + 0]) { count++; } if (nodes[x + 1, y + 0, z - 1, w + 1]) { count++; } if (nodes[x + 1, y + 0, z + 0, w - 1]) { count++; } if (nodes[x + 1, y + 0, z + 0, w + 0]) { count++; } if (nodes[x + 1, y + 0, z + 0, w + 1]) { count++; } if (nodes[x + 1, y + 0, z + 1, w - 1]) { count++; } if (nodes[x + 1, y + 0, z + 1, w + 0]) { count++; } if (nodes[x + 1, y + 0, z + 1, w + 1]) { count++; } if (nodes[x + 1, y + 1, z - 1, w - 1]) { count++; } if (nodes[x + 1, y + 1, z - 1, w + 0]) { count++; } if (nodes[x + 1, y + 1, z - 1, w + 1]) { count++; } if (nodes[x + 1, y + 1, z + 0, w - 1]) { count++; } if (nodes[x + 1, y + 1, z + 0, w + 0]) { count++; } if (nodes[x + 1, y + 1, z + 0, w + 1]) { count++; } if (nodes[x + 1, y + 1, z + 1, w - 1]) { count++; } if (nodes[x + 1, y + 1, z + 1, w + 0]) { count++; } if (nodes[x + 1, y + 1, z + 1, w + 1]) { count++; } if (nodes[x, y, z, w]) { nodes2[x, y, z, w] = (count == 2 + 1 || count == 3 + 1); // we count ourselves when active } else { nodes2[x, y, z, w] = (count == 3); } } } } } return(nodes2); }
void draw() { for (int i = 0; i < world.GetLength(0); i++) { for (int j = 0; j < world.GetLength(1); j++) { for (int k = 0; k < world.GetLength(2); k++) { for (int l = 0; l < world.GetLength(3); l++) { if (world[i, j, k, l]) { if (l == 0) { GameObject myCube = Instantiate(cube0, new Vector3(i, j, k), Quaternion.identity); Destroy(myCube, .09f); } else if (l == 1) { GameObject myCube = Instantiate(cube1, new Vector3(i, j, k), Quaternion.identity); Destroy(myCube, .09f); } else if (l == 2) { GameObject myCube = Instantiate(cube2, new Vector3(i, j, k), Quaternion.identity); Destroy(myCube, .09f); } else if (l == 3) { GameObject myCube = Instantiate(cube3, new Vector3(i, j, k), Quaternion.identity); Destroy(myCube, .09f); } else if (l == 4) { GameObject myCube = Instantiate(cube4, new Vector3(i, j, k), Quaternion.identity); Destroy(myCube, .09f); } else if (l == 5) { GameObject myCube = Instantiate(cube5, new Vector3(i, j, k), Quaternion.identity); Destroy(myCube, .09f); } else if (l == 6) { GameObject myCube = Instantiate(cube6, new Vector3(i, j, k), Quaternion.identity); Destroy(myCube, .09f); } else if (l == 7) { GameObject myCube = Instantiate(cube7, new Vector3(i, j, k), Quaternion.identity); Destroy(myCube, .09f); } else if (l == 8) { GameObject myCube = Instantiate(cube8, new Vector3(i, j, k), Quaternion.identity); Destroy(myCube, .09f); } else if (l == 9) { GameObject myCube = Instantiate(cube9, new Vector3(i, j, k), Quaternion.identity); Destroy(myCube, .09f); } } } } } } }
void Update4D() { var newGalaxy4D = new bool[size, size, size, size]; for (var x = 0; x < galaxy4D.GetLength(0); x++) { for (var y = 0; y < galaxy4D.GetLength(1); y++) { for (var z = 0; z < galaxy4D.GetLength(2); z++) { for (var w = 0; w < galaxy4D.GetLength(3); w++) { var neighbours = CountNeighbours4D(x, y, z, w); if (galaxy4D[x, y, z, w]) { newGalaxy4D[x, y, z, w] = neighbours is 2 or 3; } else { newGalaxy4D[x, y, z, w] = neighbours is 3; } } } } } galaxy4D = newGalaxy4D; }
public void TestBool() { Console.WriteLine("Boolの型変換などに関するテストメソッドです。"); Console.WriteLine("bool -> string はありますが、string -> bool はありません。"); Console.WriteLine("string -> bool? -> bool の順番にする必要があります。\n"); Console.WriteLine("次のbool[8]をstring[8]に変換します"); bool[] testArray = new bool[8] { true, true, false, true, false, true, true, true }; Console.WriteLine("要素番号" + "\t" + "文字列"); for (int i = 0; i < testArray.GetLength(0); i++) { Console.WriteLine("[" + i + "]" + "\t\t" + testArray[i]); } Console.WriteLine("\n" + "string[8]に戻します。"); string[] convertBack = IOTypeChange.NumberToString(testArray); Console.WriteLine("要素番号" + "\t" + "文字列"); for (int i = 0; i < convertBack.GetLength(0); i++) { Console.WriteLine("[" + i + "]" + "\t\t" + convertBack[i]); } Console.WriteLine("\n\n\n" + "bool[8]をbool[2,4]に変換します"); bool[,] array2Dimension = IOTypeChange.ChangeArray1dimTo2dim(testArray, 2, 4); for (int i = 0; i < array2Dimension.GetLength(0); i++) { for (int j = 0; j < array2Dimension.GetLength(1); j++) { Console.Write(array2Dimension[i, j] + "\t"); } Console.WriteLine(""); } Console.WriteLine("\n" + "多次元への拡張を意識して、要素番号とともにbool[2,4]を記載します。"); Console.WriteLine("要素番号" + "\t" + "値"); for (int i = 0; i < array2Dimension.GetLength(0); i++) { for (int j = 0; j < array2Dimension.GetLength(1); j++) { Console.WriteLine("[" + i + "," + j + "]" + "\t\t" + array2Dimension[i, j]); } } Console.WriteLine("\n" + "元のbool[8]に戻せることを確認します。"); bool[] array1Dimension = IOTypeChange.ChangeArray2dimTo1dim(array2Dimension); Console.WriteLine("要素番号" + "\t" + "値"); for (int i = 0; i < array1Dimension.GetLength(0); i++) { Console.WriteLine("[" + i + "]" + "\t\t" + array1Dimension[i]); } Console.WriteLine("\n" + "bool[8]をbool[2,2,2]に変換します"); bool[,,] array3Dimension = IOTypeChange.ChangeArray1dimTo3dim(testArray, 2, 2, 2); Console.WriteLine("要素番号" + "\t" + "値"); for (int i = 0; i < array3Dimension.GetLength(0); i++) { for (int j = 0; j < array3Dimension.GetLength(1); j++) { for (int k = 0; k < array3Dimension.GetLength(2); k++) { Console.WriteLine("[" + i + "," + j + "," + k + "]" + "\t\t" + array3Dimension[i, j, k]); } } } Console.WriteLine("\n" + "元のbool[8]に戻せることを確認します。"); array1Dimension = IOTypeChange.ChangeArray3dimTo1dim(array3Dimension); Console.WriteLine("要素番号" + "\t" + "値"); for (int i = 0; i < array1Dimension.GetLength(0); i++) { Console.WriteLine("[" + i + "]" + "\t\t" + array1Dimension[i]); } Console.WriteLine("\n" + "bool[8]をbool[2,2,2,1]に変換します"); bool[,,,] array4Dimension = IOTypeChange.ChangeArray1dimTo4dim(testArray, 2, 2, 2, 1); Console.WriteLine("要素番号" + "\t" + "値"); for (int i = 0; i < array4Dimension.GetLength(0); i++) { for (int j = 0; j < array4Dimension.GetLength(1); j++) { for (int k = 0; k < array4Dimension.GetLength(2); k++) { for (int dim4 = 0; dim4 < array4Dimension.GetLength(3); dim4++) { Console.WriteLine("[" + i + "," + j + "," + k + "," + dim4 + "]" + "\t\t" + array4Dimension[i, j, k, dim4]); } } } } Console.WriteLine("\n" + "元のbool[8]に戻せることを確認します。"); array1Dimension = IOTypeChange.ChangeArray4dimTo1dim(array4Dimension); Console.WriteLine("要素番号" + "\t" + "値"); for (int i = 0; i < array1Dimension.GetLength(0); i++) { Console.WriteLine("[" + i + "]" + "\t" + array1Dimension[i]); } Console.WriteLine("\n\n\n" + "次のstring[2,4]をbool[2,4]に変換します"); bool[,] testArray2 = new bool[2, 4] { { true, true, false, true }, { false, true, true, true } }; Console.WriteLine("要素番号" + "\t" + "文字列"); for (int i = 0; i < testArray2.GetLength(0); i++) { for (int j = 0; j < testArray2.GetLength(1); j++) { Console.WriteLine("[" + i + "," + j + "]" + "\t\t" + testArray2[i, j]); } } Console.WriteLine("\n" + "string[2,4]に変換します"); string[,] convertBack2 = IOTypeChange.NumberToString(testArray2); Console.WriteLine("要素番号" + "\t" + "文字列"); for (int i = 0; i < convertBack2.GetLength(0); i++) { for (int j = 0; j < convertBack2.GetLength(1); j++) { Console.WriteLine("[" + i + "," + j + "]" + "\t\t" + convertBack2[i, j]); } } Console.WriteLine("\n\n\n" + "次のstring[2,2,2]をbool[2,2,2]に変換します"); bool[,,] testArray3 = new bool[2, 2, 2] { { { true, true }, { false, true } }, { { false, true }, { true, true } } }; Console.WriteLine("要素番号" + "\t" + "文字列"); for (int i = 0; i < testArray3.GetLength(0); i++) { for (int j = 0; j < testArray3.GetLength(1); j++) { for (int k = 0; k < testArray3.GetLength(2); k++) { Console.WriteLine("[" + i + "," + j + "," + k + "]" + "\t\t" + testArray3[i, j, k]); } } } Console.WriteLine("\n" + "string[2,2,2]に変換します"); string[,,] convertBack3 = IOTypeChange.NumberToString(testArray3); Console.WriteLine("要素番号" + "\t" + "文字列"); for (int i = 0; i < convertBack3.GetLength(0); i++) { for (int j = 0; j < convertBack3.GetLength(1); j++) { for (int k = 0; k < convertBack3.GetLength(2); k++) { Console.WriteLine("[" + i + "," + j + "," + k + "]" + "\t\t" + convertBack3[i, j, k]); } } } Console.WriteLine("\n\n\n" + "次のstring[2,2,2,1]をbool[2,2,2,1]に変換します"); bool[,,,] testArray4 = new bool[2, 2, 2, 1] { { { { true }, { true } }, { { false }, { true } } }, { { { false }, { true } }, { { true }, { true } } } }; Console.WriteLine("要素番号" + "\t" + "文字列"); for (int i = 0; i < testArray4.GetLength(0); i++) { for (int j = 0; j < testArray4.GetLength(1); j++) { for (int k = 0; k < testArray4.GetLength(2); k++) { for (int dim4 = 0; dim4 < testArray4.GetLength(3); dim4++) { Console.WriteLine("[" + i + "," + j + "," + k + "," + dim4 + "]" + "\t\t" + testArray4[i, j, k, dim4]); } } } } Console.WriteLine("\n" + "string[2,2,2,1]に変換します。"); string[,,,] convertBack4 = IOTypeChange.NumberToString(testArray4); Console.WriteLine("要素番号" + "\t" + "文字列"); for (int i = 0; i < convertBack4.GetLength(0); i++) { for (int j = 0; j < convertBack4.GetLength(1); j++) { for (int k = 0; k < convertBack4.GetLength(2); k++) { for (int dim4 = 0; dim4 < convertBack4.GetLength(3); dim4++) { Console.WriteLine("[" + i + "," + j + "," + k + "," + dim4 + "]" + "\t\t" + convertBack4[i, j, k, dim4]); } } } } }