public Space4D GetNextGeneration() { var nextGeneration = new Space4D(Generation + 1); for (var x = _minX - 1; x <= _maxX + 1; x++) { for (var y = _minY - 1; y <= _maxY + 1; y++) { for (var z = _minZ - 1; z <= _maxZ + 1; z++) { for (var w = _minW - 1; w <= _maxW + 1; w++) { var active = GetLocation(x, y, z, w); var count = CountNeighbours(x, y, z, w); var newState = GetNewState(active, count); nextGeneration.SetLocation(x, y, z, w, newState); } } } } return(nextGeneration); }
public static ConwayCube LoadFromFile(string filename) { var space = new Space(0); var space4D = new Space4D(0); var lines = File.ReadAllLines(filename); var y = 0; foreach (var line in lines) { var x = 0; foreach (var c in line.ToCharArray()) { space.SetLocation(x, y, 0, c == Active); space4D.SetLocation(x, y, 0, 0, c == Active); x += 1; } y += 1; } return(new ConwayCube(space, space4D)); }
private ConwayCube(Space space, Space4D space4D) { _space = space; _space4D = space4D; }