A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Map: the dune coast's breakers draw apart offshore, so the surf south of Jaffa is not combed into even lines (refs #716) (#854)
Berid185ada523f5
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 7252dc101..b708c876d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -32,6 +32,11 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIBname their months in Hebrew ("מ־15 במאי 1948 עד 15 ביוני 1948", "באוגוסט 1950") through the `date.*` strings, asthe top bar does since #696 (refs #701). English is unchanged. `info.built` in Hebrew now says "ב{1}" instead of"בשנת {1}", since its value is a month and a year.+- The surf south of Jaffa no longer reads as evenly combed white lines (refs #716, #690). On the dune coasts the+ breakers draw apart offshore, as a shoaling swell's do: 450 m apart at the shore, 1.5 km at the 3 km zone's edge+ (`ScBreakerChirp` in `StatecraftMap.hlsl`). `coast_measure`'s stripe_rows for the south window falls from 0.47 to 0.25+ (promo 03 0.30) on gameplay03 editor renders, with the foam band at 34.7 px (35.6 before) and 2 lace lines. The kurkar+ coast is unchanged. `SeaTests.TheDuneCoastsSurfIsNotCombedIntoEvenLines` measures it.- The loading screen's boot-failure line wraps inside the screen with a side margin (refs #765). In Hebrew at phone widthit ran past both edges, so the player could not read "reload the page"; `.loading-line` had no `white-space: normal`.`UiLayoutTests.TheBootFailureLineWrapsInsideTheScreen` checks English and Hebrew at 390x844, 960x600 and 1280x720.diff --git a/unity/Assets/Shaders/StatecraftMap.hlsl b/unity/Assets/Shaders/StatecraftMap.hlslindex 0a37d1a92..aea6843c5 100644--- a/unity/Assets/Shaders/StatecraftMap.hlsl+++ b/unity/Assets/Shaders/StatecraftMap.hlsl@@ -102,14 +102,14 @@ static const float ScWaveTilt = 0.6; // wave normal// The surf: a swash line along the sand (full to ScSwashM) and breakers rolling shoreward through the surf zone// (ScSurfM), broken along the shore by noise. The breakers are a squared triangle wave in the distance from the shore,// box-filtered over the pixel's footprint in closed form, so they never alias and tend to their mean (1/3) as the pixel-// grows; ScBreakerRate cycles per second roll them in at ScBreakerSpacingM x ScBreakerRate = 22.5 m/s (half a pixel per-// frame at the gameplay pose's ~45 m pixels and 60 fps). coast.png's 94 m levels are interpolated linearly between+// grows; ScBreakerRate cycles per second roll them in at ScBreakerSpacingM x ScBreakerRate = 22.5 m/s (half a pixel a+// second at the gameplay pose's ~45 m pixels). coast.png's 94 m levels are interpolated linearly between// texels, so a crest can sit up to ~47 m off its true place: about one gameplay pixel, under the phase noise.// Sea round 3 (#388): towards promo 03's lace (2-4 broken white lines over the turquoise; SeaTests guarantees the swash// and at least one breaker, the rest waits for #519's grade). The surf zone from 900 to 1800 m (the// promo's 29-52 px foam band at gameplay03's ~45 m pixels; at 1500 m the second crest faded under the foam's white before// it reached the turquoise), the crests from 300 to 450 m apart (about 10 px, so they stand clear of each other;-// ScBreakerRate kept, so they roll in at 22.5 m/s, about half a pixel a frame), and the foam whiter (ScFoamWhite, 0.85+// ScBreakerRate kept, so they roll in at 22.5 m/s, about half a pixel a second), and the foam whiter (ScFoamWhite, 0.85// before: the crests read turquoise-tinted).// The lace (the "foam" toggle, _ScSeaFoam): the constants alone left whole crests out where the 300 m "broken" noise was// low, since one blob of it covers two crests 450 m apart (SeaTests.TheSurfShowsABrokenBreakerBeyondTheSwashAtTheGameplayZoom@@ -233,10 +233,22 @@ float ScDuneWeight(float2 mapM)// up to 2x, so the width comes from the phase itself (review N2). Call it in uniform control flow (outside any [branch]);// pass the result to ScWaterShade.static const float ScBreakerFilterPx = 1.25;+// #716: on the dune coasts (ScDuneWeight) the crests draw apart offshore, as a shoaling swell's do: the spacing grows+// linearly from ScBreakerSpacingM at the shore by ScBreakerChirp metres per metre out (800 m 1 km out, 1.5 km at the+// 3 km zone's edge), so the phase is its integral, log(1 + ScBreakerChirp x) / ScBreakerChirp in shore spacings x. The+// 3.0 km zone had 3 or more evenly spaced white lines in 47% of the south window's rows (coast_measure's stripe_rows,+// gameplay03 editor renders, median of 8 moments; promo 03 0.30); at ScBreakerChirp 0.35 it reads 0.25, foam band+// 34.7 px (35.6 before), 2 lace lines, share 0.55 (promo 03 0.54). Chirp 0.25 read 0.32; 0.5 read 0.21 but pulled+// SeaTests' southern walks in to 39 px, past the north-to-south ratio and the lace share bounds; a constant 800 m spacing+// read 0.27 and kept the lines even. The crests still roll in at ScBreakerRate cycles a second, so the outer ones move+// faster: 75 m/s at the 3 km edge (about 1.7 px a second at gameplay's 45 m pixels), the 22.5 m/s above being the shore's.+static const float ScBreakerChirp = 0.35;float2 ScBreakers(float coast, float2 mapM){float offshoreM = saturate(0.5 - coast) * 2.0 * ScCoastRangeM;- float phase = offshoreM / ScBreakerSpacingM + ScWaterClock() * ScBreakerRate + ScNoise(mapM / 1200.0) * 2.0;+ float x = offshoreM / ScBreakerSpacingM;+ x = lerp(x, log(1.0 + ScBreakerChirp * x) / ScBreakerChirp, ScDuneWeight(mapM));+ float phase = x + ScWaterClock() * ScBreakerRate + ScNoise(mapM / 1200.0) * 2.0;return float2(phase, fwidth(phase) * ScBreakerFilterPx);}diff --git a/unity/Assets/Tests/EditMode/SeaTests.cs b/unity/Assets/Tests/EditMode/SeaTests.csindex 69513b61c..c9b8e5db6 100644--- a/unity/Assets/Tests/EditMode/SeaTests.cs+++ b/unity/Assets/Tests/EditMode/SeaTests.cs@@ -563,6 +563,101 @@ public class SeaTests/// for the whole coast read 0.81 (25.0 / 30.8).</summary>const float NorthToSouthMax = 0.6f;+ /// <summary>#716: the dune coast's surf is not combed into evenly spaced white lines. The measure is+ /// tools/coast_measure.py's stripe_rows on its south window at gameplay03 (rows 690-880 every 2nd, x 380-760 of the+ /// 1920x1080 frame): per row, the shore is the first run of 3 sand or crown pixels after 6 or more water or foam pixels+ /// (rows without a 3-pixel sand run past it are skipped), the foam band is the 80 px before the shore from its farthest+ /// foam pixel, and a line is a run of 2 or more foam pixels in it; stripe_rows is the share of rows with 3 or more+ /// lines. Pixel classes as the tool's (sRGB 0-255): foam luma 0.72 or more and channels within 30, water b > r + 15,+ /// sand luma 0.60 or more and r - b 25 or more, crown any other pixel under luma 0.40. The median over+ /// <see cref="StripeMoments"/> pinned moments of one breaker cycle is at most <see cref="StripeRowsMax"/>, promo 03's+ /// 0.30. Main 8df042a1 reads 0.47 here, as the tool does on MapCapture's web-tier renders (llvmpipe; #838 read 0.58 on+ /// WebGL ?shot captures); the dune coasts' breaker chirp (StatecraftMap.hlsl, ScBreakerChirp 0.35) 0.25.</summary>+ [UnityTest]+ public IEnumerator TheDuneCoastsSurfIsNotCombedIntoEvenLines()+ {+ var map = OpenMap();+ yield return null;+ // The frame as gameplay03 shows it, which is what coast_measure reads: OpenMap turns the tilt-shift, kits and trees+ // off, but the tilt-shift's blur over the bottom band (the south window's rows) merges close lines, and a crown on+ // the waterline marks the tool's shore.+ RenderSample.TiltShift(true);+ foreach (var n in new[] { "kits", "trees" }) if (VisualToggles.Names.Contains(n)) VisualToggles.Set(n, true);+ var cam = Camera.main; var rig = cam.GetComponent<CameraRig>();+ PromoPose.Gameplay03.Apply(rig, map.Frame);+ var reads = new System.Collections.Generic.List<float>();+ var shores = new System.Collections.Generic.List<int>();+ var surfs = new System.Collections.Generic.List<int>();+ int previous = QualitySettings.GetQualityLevel();+ QualitySettings.SetQualityLevel(0, true); // the web tier, as MapCapture.SurfFrames and the WebGL ?shot render it+ try+ {+ for (int k = 0; k < StripeMoments; k++)+ {+ MapShaderGlobals.PinWaterTime(100f + k * 20f / StripeMoments); // one breaker cycle is 1 / ScBreakerRate = 20 s+ var (score, rows, surf) = StripeRows(RenderSample.Render(cam, 1920, 1080));+ reads.Add(score); shores.Add(rows); surfs.Add(surf);+ }+ }+ finally { QualitySettings.SetQualityLevel(previous, true); }+ TestContext.WriteLine($"rows with a shore per moment (of 95): {string.Join(" ", shores)}; with a foam line: {string.Join(" ", surfs)}");+ // Fails closed: a window with no shore (a broken pose, a moved coast) or no foam on it (the water toggle off draws+ // the sea plain, shore still found) would read 0, the best score. coast_measure finds a shore on all 95 rows of+ // main's and the chirp's WebGL frames.+ for (int k = 0; k < StripeMoments; k++)+ {+ Assert.GreaterOrEqual(shores[k], StripeShoreRowsMin, "south of Jaffa: the window shows the sea meeting the sand");+ Assert.GreaterOrEqual(surfs[k], StripeShoreRowsMin, "south of Jaffa: the surf draws foam along the shore");+ }+ reads.Sort();+ float median = 0.5f * (reads[StripeMoments / 2 - 1] + reads[StripeMoments / 2]);+ TestContext.WriteLine($"stripe_rows per moment: {string.Join(" ", reads.Select(v => v.ToString("0.00")))}; median {median:0.00}");+ Assert.LessOrEqual(median, StripeRowsMax, "south of Jaffa: the surf's lines are not evenly combed");+ }++ /// <summary>TheDuneCoastsSurfIsNotCombedIntoEvenLines' moments and bound (promo 03's stripe_rows, #716).</summary>+ const int StripeMoments = 8;+ const float StripeRowsMax = 0.30f;+ /// <summary>The fewest of the south window's 95 rows that must find a shore, and a foam line before it, at each+ /// moment, so a frame with no sea or no surf fails instead of scoring 0 (#854 review).</summary>+ const int StripeShoreRowsMin = 80;++ /// <summary>coast_measure's stripe_rows over its south window, for a 1920x1080 gameplay03 render (row 0 at the bottom),+ /// the number of rows that found a shore, and of those the rows with at least one foam line.</summary>+ static (float score, int rows, int surf) StripeRows(RenderSample r)+ {+ int rows = 0, striped = 0, surf = 0;+ for (int y = 690; y < 880; y += 2)+ {+ var c = new char[380];+ for (int x = 0; x < c.Length; x++)+ {+ var p = r.At(380 + x, r.Height - 1 - y);+ int R = Mathf.RoundToInt(p.r * 255f), G = Mathf.RoundToInt(p.g * 255f), B = Mathf.RoundToInt(p.b * 255f);+ float lum = (0.2126f * R + 0.7152f * G + 0.0722f * B) / 255f;+ c[x] = lum >= 0.72f && Mathf.Max(R, G, B) - Mathf.Min(R, G, B) <= 30 ? 'F' : B > R + 15 ? 'W'+ : lum >= 0.60f && R - B >= 25 ? 'S' : lum < 0.40f ? 'C' : 'L';+ }+ int seen = 0, shore = -1;+ for (int i = 0; i < c.Length - 3 && shore < 0; i++)+ {+ if (c[i] == 'W' || c[i] == 'F') seen++;+ if (seen >= 6 && Enumerable.Range(i, 3).All(j => c[j] == 'S' || c[j] == 'C')) shore = i;+ }+ if (shore < 0 || !Enumerable.Range(shore, c.Length - 3 - shore + 1).Any(i => c[i] == 'S' && c[i + 1] == 'S' && c[i + 2] == 'S')) continue;+ int from = Mathf.Max(0, shore - 80), far = System.Array.IndexOf(c, 'F', from, shore - from), lines = 0, run = 0;+ for (int i = far < 0 ? shore : far; i <= shore; i++)+ {+ if (i < shore && c[i] == 'F') run++;+ else { if (run >= 2) lines++; run = 0; }+ }+ rows++;+ if (lines >= 1) surf++;+ if (lines >= 3) striped++;+ }+ return (rows > 0 ? striped / (float)rows : 0f, rows, surf);+ }+/// <summary>promo-sea review I2 / M5 / N1: the breakers are box-filtered over the pixel, so they never alias. Around/// the surf zone west of Tel Aviv, at the gameplay footprint (30 km at 960x540: about 45 m a pixel, the same as/// gameplay03's 60 km at 1920x1080), where an unfiltered crest is sub-pixel but not yet faded, every water pixel of a