From fb7c1ada24ab9f6e998c35174af3482c19a0aa82 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 11 Sep 2026 21:32:23 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20Remove=20backup=20file=20src/Gam?= =?UTF-8?q?eUtils/Procedural/Diamond.cs.orig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: johnstrand <11484777+johnstrand@users.noreply.github.com> --- src/GameUtils/Procedural/Diamond.cs.orig | 73 ------------------------ 1 file changed, 73 deletions(-) delete mode 100644 src/GameUtils/Procedural/Diamond.cs.orig diff --git a/src/GameUtils/Procedural/Diamond.cs.orig b/src/GameUtils/Procedural/Diamond.cs.orig deleted file mode 100644 index 05bfd97..0000000 --- a/src/GameUtils/Procedural/Diamond.cs.orig +++ /dev/null @@ -1,73 +0,0 @@ -using GameUtils.Types.Collections; - -namespace GameUtils.Procedural; - -/// -/// Generates a diamond-square map -/// -public static class Diamond -{ - /// - /// Creates a new diamond-square map from the specified parameters. - /// - /// Height and width. Must be a power-of-two plus one (e.g. 129, 257, 513). - /// Min value of the initial seed - /// Max value of the initial seed - /// The initial range for the next step - /// A method that will be passed the current range and is expected to return the range for the next iteration - /// A method that will be passed an average value and a range, and is expected to return an integer map value - /// Optional random seed for reproducible generation. Uses a thread-safe shared instance when null. - /// Thrown when is not a power-of-two plus one. - public static Grid Create(int size, int min, int max, float range, Func nextRange, Func valueFactory, int? seed = null) - { - var n = size - 1; - if (n < 1 || (n & (n - 1)) != 0) - { - throw new ArgumentException("Size must be a power-of-two plus one (e.g. 3, 5, 9, 17, 33, ...).", nameof(size)); - } - - var r = seed.HasValue ? new Random(seed.Value) : Random.Shared; - var map = new Grid(size, size); - map[0, 0] = r.Next(min, max); - map[0, size - 1] = r.Next(min, max); - map[size - 1, 0] = r.Next(min, max); - map[size - 1, size - 1] = r.Next(min, max); - - var step = size - 1; - - while (step > 1) - { - var halfStep = step / 2; - for (var y = 0; y < size - 1; y += step) - { - for (var x = 0; x < size - 1; x += step) - { - var mx = x + halfStep; - var my = y + halfStep; - - map[mx, my] = valueFactory(AverageInt(map, x, y, x + step, y, x, y + step, x + step, y + step), range); - map[mx, y] = valueFactory(AverageInt(map, x, y, x + step, y, mx, my, mx, y - step), range); - map[x, my] = valueFactory(AverageInt(map, x, y, x, y + step, mx, my, x - step, my), range); - map[x + step, my] = valueFactory(AverageInt(map, x + step, y, x + step, y + step, mx, my, x + step + step, my), range); - map[mx, y + step] = valueFactory(AverageInt(map, x, y + step, x + step, y + step, mx, my, mx, y + step + step), range); - } - } - - range = nextRange(range); - step = halfStep; - } - - return map; - } - - private static float AverageInt(Grid map, int ax, int ay, int bx, int by, int cx, int cy, int dx, int dy) - { - var sum = 0f; - var count = 0; - if (ax >= 0 && ax < map.Width && ay >= 0 && ay < map.Height) { sum += map[ax, ay]; count++; } - if (bx >= 0 && bx < map.Width && by >= 0 && by < map.Height) { sum += map[bx, by]; count++; } - if (cx >= 0 && cx < map.Width && cy >= 0 && cy < map.Height) { sum += map[cx, cy]; count++; } - if (dx >= 0 && dx < map.Width && dy >= 0 && dy < map.Height) { sum += map[dx, dy]; count++; } - return count == 0 ? 0f : sum / count; - } -}