public Burrow(CharMap map) { var y0 = 2; // Rooms start at y==2 RoomSize = map.MinMax().Item2.Y - y0; Rooms = new Room[] { new Room(RoomSize, 'A', 2, new int[] { 1, 0 }, new int[] { 3, 5, 7, 9, 10 }), new Room(RoomSize, 'B', 4, new int[] { 3, 1, 0 }, new int[] { 5, 7, 9, 10 }), new Room(RoomSize, 'C', 6, new int[] { 5, 3, 1, 0 }, new int[] { 7, 9, 10 }), new Room(RoomSize, 'D', 8, new int[] { 7, 5, 3, 1, 0 }, new int[] { 9, 10 }), }; // Rooms starts out containing the right pods (AAAA, BBBB, etc) so the // initial state is also the desired final state FinalState = State; // Populate the rooms with the pods from the map foreach (var room in Rooms) { for (var i = 0; i < room.Pods.Length; i++) { room.Pods[i] = map[room.X + 1][y0 + i]; } } }
private static uint BioDiversity(CharMap map) { var(min, max) = map.MinMax(); var width = max.Y - min.Y + 1; uint val = 0; foreach (var pos in map.AllPoints(c => c == '#')) { var position = pos.Y * width + pos.X; val += 1U << position; } return(val); }