Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

Enemy script: the two-source gate counts distinct URLs and any-case wiki hosts (#2804 item 8) (#2867)

Beri67aee524ae2c
diff --git a/changelog.d/2804-8.md b/changelog.d/2804-8.md
new file mode 100644
index 000000000..5822d9e3b
--- /dev/null
+++ b/changelog.d/2804-8.md
@@ -0,0 +1,4 @@
+### Fixed
+
+- Enemy scripts: an anchor's two-source check now counts a URL listed twice as one source, and treats a Wikipedia or
+ Wikidata link in capitals as Wikipedia or Wikidata. No shipped anchor changes.
diff --git a/sim/Statecraft.Sim.Tests/EnemyAITests.cs b/sim/Statecraft.Sim.Tests/EnemyAITests.cs
index ab5677251..e8478d65b 100644
--- a/sim/Statecraft.Sim.Tests/EnemyAITests.cs
+++ b/sim/Statecraft.Sim.Tests/EnemyAITests.cs
@@ -222,10 +222,14 @@ public class EnemyAITests
Assert.All(Real.StartingForces.Where(f => f.Side == Movement.PlayerSide), f => Assert.Empty(f.Script));
}
- // R-ENEMY-002: an 11 June anchor on one non-Wikipedia source (with Wikipedia beside it) is not scripted; two are.
+ // R-ENEMY-002: an 11 June anchor on one non-Wikipedia source (with Wikipedia beside it) is not scripted; two are. One URL
+ // listed twice is one source, and a Wikipedia host in capitals is still Wikipedia (#2804).
[Theory]
[InlineData("['https://example.org/a', 'https://en.wikipedia.org/wiki/Isdud', 'https://www.wikidata.org/wiki/Q1']", false)]
[InlineData("['https://example.org/a', 'https://example.org/b']", true)]
+ [InlineData("['https://example.org/a', 'https://example.org/a']", false)]
+ [InlineData("['https://example.org/a', 'https://EN.WIKIPEDIA.ORG/wiki/Isdud']", false)]
+ [InlineData("['https://example.org/a', 'https://www.WikiData.org/wiki/Q1']", false)]
public void AScriptedAnchorNeedsTwoSources(string urls, bool scripted)
{
var sources = string.Join(", ", urls.Trim('[', ']').Split(", ").Select(u => "{ url: " + u + ", checked: '2026-10-13' }"));
diff --git a/sim/Statecraft.Sim/StartingForces.cs b/sim/Statecraft.Sim/StartingForces.cs
index c9ebf8776..9915ae173 100644
--- a/sim/Statecraft.Sim/StartingForces.cs
+++ b/sim/Statecraft.Sim/StartingForces.cs
@@ -132,9 +132,12 @@ namespace Statecraft.Sim
for (int j = 0; j < anchors.Count; j++)
{
if (!(anchors[j] is Dictionary<object, object> a) || string.CompareOrdinal(Text(a, "from"), EnemyAI.ScriptDate) < 0) continue;
- var sourced = a.TryGetValue("sources", out var so) && so is List<object> sources ? sources.Count(x =>
- x is Dictionary<object, object> m && Text(m, "url") is var url && url != ""
- && !url.Contains("wikipedia.org", StringComparison.Ordinal) && !url.Contains("wikidata.org", StringComparison.Ordinal)) : 0;
+ // Distinct URLs, so one source listed twice counts once; hosts are case-insensitive, so EN.WIKIPEDIA.ORG is Wikipedia.
+ var sourced = a.TryGetValue("sources", out var so) && so is List<object> sources ? sources
+ .Select(x => x is Dictionary<object, object> m ? Text(m, "url") : "")
+ .Where(url => url != "" && !url.Contains("wikipedia.org", StringComparison.OrdinalIgnoreCase)
+ && !url.Contains("wikidata.org", StringComparison.OrdinalIgnoreCase))
+ .Distinct(StringComparer.Ordinal).Count() : 0;
if (sourced < 2) continue;
if (!hexes.TryGetValue((id, j), out var qr))
throw new ContentException(HexesFileName, "anchors", $"no hex for {at}.anchors[{j}] ({FileName}); rerun tools/unit_anchor_hexes.py");