Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
Terrain-aware procedural castles and independent culture regions for Minecraft.
Original idea: Emre's brother. Concept and project direction: Emre (`badmon61`).

## Status: 0.2.0-alpha.1 — opt-in terraced architecture
## Status: 0.2.1-alpha.1 — identity and architectural diagnostics

**New in 0.2.1:** Seed-stable, culture-dependent castle names and regional dynasties, symbolic heraldry, age, chronological construction milestones, and a condition-derived *planned* occupancy category. These are narrative metadata only: **no NPCs, loot, actual banners or timeline simulation are spawned**. The two existing castle shapes and culture map remain unchanged. Different regions may coincidentally share generated names; uniqueness is not promised.

The terraced preview now includes a quick dimensional/material/access summary. Use `/castleforge inspect` after `/castleforge preview terraced` (or classic preview) to read the current design report. Preview and inspect are read-only. Reports expire with the preview (120 seconds), and are cleared by build confirmation.

Small visible facade improvement: culture-sensitive accent blocks for trim and timber. This changes palette appearance, **not** the geometry generator, region borders or world settings. Refer to [identity and diagnostic contract](docs/IDENTITY_AND_DIAGNOSTICS.md).

## Previously: 0.2.0-alpha.1 — opt-in terraced architecture

**Disposable test worlds only. No automatic world generation and no completed in-game acceptance test.**

Expand Down Expand Up @@ -32,13 +40,14 @@ Automatic exploration-time generation; automatically measured biome scaling; arb
Target remains **Minecraft Java 26.1.2**, **Java 25**, **Fabric Loader 0.19.5+**, **Fabric API 0.155.3+26.1.2**.

1. Use a separate Prism/Fabric instance and a new disposable Creative world with commands enabled.
2. Install `castleforge-fabric-0.2.0-alpha.1.jar` from a successful branch Actions build plus the matching Fabric API. Replace the old CastleForge JAR; do not install two versions or a `-sources.jar`.
2. Install `castleforge-fabric-0.2.1-alpha.1.jar` from a successful branch Actions build plus the matching Fabric API. Replace the old CastleForge JAR; do not install two versions or a `-sources.jar`.
3. Start on superflat to verify the build workflow, then test a second disposable world with open, gradual slopes. The new survey is 105 × 105 blocks; the whole site must already be loaded.
4. Execute separately:

```mcfunction
/castleforge region
/castleforge preview terraced
/castleforge inspect
/castleforge build confirm
/castleforge status
```
Expand Down Expand Up @@ -75,7 +84,7 @@ The CI uses pinned Gradle; a Gradle wrapper is not yet checked in. Pure generato
bash scripts/verify-core.sh
```

The classic suite checks 50 seeds. The new suite checks **32 seeds × 5 synthetic terrains = 160 combinations**, all eight culture profiles, all four rotations, roofs and condition states, determinism, navigation, bounded supports, rejection cases, negative/world-edge coordinates and concurrent planning. A golden geometry digest detects unintended generator drift. Repeated per-voxel assertions are not millions of different test scenarios.
The classic suite checks 50 seeds. A third suite checks narrative identities across 100 seeds and eight cultures, coherent chronology, region-level dynasties, diagnostic counts and reporting. The new suite checks **32 seeds × 5 synthetic terrains = 160 combinations**, all eight culture profiles, all four rotations, roofs and condition states, determinism, navigation, bounded supports, rejection cases, negative/world-edge coordinates and concurrent planning. A golden geometry digest detects unintended generator drift. Repeated per-voxel assertions are not millions of different test scenarios.

Passing these checks is **not a Minecraft launch, entity-pathfinding, block-physics or visual test**. See [terraced architecture and acceptance checklist](docs/TERRACED_ARCHITECTURE.md), [original architecture](docs/ARCHITECTURE.md), [classic test checklist](docs/TESTING.md), [initial alpha validation](docs/VALIDATION.md), and [long-term roadmap](docs/ROADMAP.md).

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}
allprojects {
group = 'dev.castleforge'
version = '0.2.0-alpha.1'
version = '0.2.1-alpha.1'
repositories { mavenCentral() }
}
tasks.named('build') { dependsOn ':core:build', ':fabric:build' }
9 changes: 8 additions & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@ tasks.register('verifyTerraces', JavaExec) {
maxHeapSize = '512m'
mustRunAfter verifyCore
}
tasks.named('check') { dependsOn verifyCore, verifyTerraces }
tasks.register('verifyIdentity', JavaExec) {
dependsOn testClasses
classpath = sourceSets.test.runtimeClasspath
mainClass = 'dev.castleforge.core.IdentityVerification'
maxHeapSize = '512m'
mustRunAfter verifyTerraces
}
tasks.named('check') { dependsOn verifyCore, verifyTerraces, verifyIdentity }
79 changes: 79 additions & 0 deletions core/src/main/java/dev/castleforge/core/CastleIdentity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package dev.castleforge.core;

import java.util.*;
import static dev.castleforge.core.CastlePlanner.Condition;

/**
* Versioned narrative identity for a hypothetical castle site.
* Pure data: it neither spawns inhabitants nor edits, loads or samples terrain.
* Names are project-authored syllable combinations, not imported schematics.
*/
public final class CastleIdentity {
public static final int VERSION = 1;
public enum Occupancy { INHABITED, SPARSE, ABANDONED }
public record Event(int yearsAgo, String key, String description) {}
public record Identity(String name, String dynasty, String heraldry, String culture,
String cultureRegionId, int ageYears, Condition condition,
Occupancy expectedOccupancy, List<Event> events) {
public Identity { events = List.copyOf(events); }
public String oneLine() {
return name + " / " + dynasty + " / " + ageYears + " years / " + condition
+ " / planned population: " + expectedOccupancy;
}
}
private record Names(String title, String housePrefix, String[] roots, String[] suffixes) {}
private static Names names(String style) {
return switch (style) {
case "nordic" -> new Names("Hold", "Clan", new String[]{"Frost","Storm","Raven","Skald","Winter","Iron"}, new String[]{"holm","gard","fjell","vik","heim","havn"});
case "mediterranean" -> new Names("Castello", "House", new String[]{"Monte","Vela","Rosa","Luna","Bel","Porto"}, new String[]{"vento","mar","fiore","castro","verde","alto"});
case "desert_citadel" -> new Names("Citadel", "House", new String[]{"Qasr","Sahar","Nur","Rimal","Zafir","Miraj"}, new String[]{"ara","edin","amir","sahir","nura","zan"});
case "east_asian" -> new Names("Fortress", "House", new String[]{"Kiri","Hoshi","Mizu","Kaze","Taka","Yama"}, new String[]{"yama","kawa","mori","shima","sora","tani"});
case "gothic" -> new Names("Bastion", "House", new String[]{"Schatten","Nebel","Raben","Nacht","Dorn","Aschen"}, new String[]{"fels","wacht","turm","krone","stein","hain"});
case "high_fantasy" -> new Names("Spire", "House", new String[]{"Aether","Elden","Lumi","Valen","Caeli","Solis"}, new String[]{"dorn","spire","myr","thal","ria","wyn"});
case "maritime" -> new Names("Fort", "House", new String[]{"Sturm","Wellen","Tiden","Wind","Salz","Falken"}, new String[]{"klippe","hafen","wacht","fels","werft","holm"});
default -> new Names("Castle", "House", new String[]{"Falken","Hohen","Eichen","Greifen","Rosen","Silber"}, new String[]{"fels","wacht","burg","stein","hain","krone"});
};
}
private static final String[] HERALDRY = {
"silver falcon on blue", "golden sun on black", "white stag on green", "red tower on ivory",
"black raven on silver", "golden lion on crimson", "three stars on purple", "silver wave on teal"
};
private static int pick(long value, int size) { return Math.floorMod(value, size); }

public static Identity generate(long worldSeed, int x, int z, CultureMap.Region region, Condition condition) {
Objects.requireNonNull(region, "region");
Objects.requireNonNull(condition, "condition");
Names n = names(region.style());
long site = CultureMap.hash(worldSeed ^ 0x434153544c454944L, x, z);
long kingdom = CultureMap.mix(worldSeed ^ 0x4b494e47444f4d31L ^ CultureMap.mix(region.id().hashCode()));
String name = n.title + " " + n.roots[pick(site,n.roots.length)]
+ n.suffixes[pick(CultureMap.mix(site^17L),n.suffixes.length)];
String dynasty = n.housePrefix + " " + n.roots[pick(kingdom,n.roots.length)]
+ n.suffixes[pick(CultureMap.mix(kingdom^19L),n.suffixes.length)];
String heraldry = HERALDRY[pick(CultureMap.mix(kingdom^23L),HERALDRY.length)];
int age = 120 + pick(CultureMap.mix(site^29L),681);
Occupancy occupancy = switch(condition) {
case RESTORED -> Occupancy.INHABITED;
case WEATHERED -> Occupancy.SPARSE;
case RUINED -> Occupancy.ABANDONED;
};
List<Event> events = new ArrayList<>();
events.add(new Event(age, "founded", "A fortified watchpost was established."));
int extension = age * (47 + pick(CultureMap.mix(site^31L),16)) / 100;
events.add(new Event(extension, "expanded", "The garrison was enlarged with halls and additional defenses."));
if (condition == Condition.RESTORED) {
events.add(new Event(Math.max(5, age/9), "restored", "Recent repairs renewed the roofs, gate and inhabited quarters."));
} else if (condition == Condition.WEATHERED) {
events.add(new Event(Math.max(10, age/7), "decline", "The household dwindled and maintenance gradually ceased."));
} else {
int siege = Math.max(25, age/4);
events.add(new Event(siege, "siege", "An old siege damaged the defenses and several residential wings."));
events.add(new Event(Math.max(2, siege/4), "abandoned", "The remaining residents finally left the fortress."));
}
for (int i=1;i<events.size();i++)
if (events.get(i).yearsAgo() >= events.get(i-1).yearsAgo())
throw new IllegalStateException("History chronology invalid");
return new Identity(name, dynasty, heraldry, region.style(), region.id(), age, condition, occupancy, events);
}
private CastleIdentity() {}
}
49 changes: 49 additions & 0 deletions core/src/main/java/dev/castleforge/core/PlanDiagnostics.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package dev.castleforge.core;

import java.util.*;
import static dev.castleforge.core.TerracedCastlePlanner.*;

/** Bounded, immutable summary for operator previews and architecture regression checks. */
public final class PlanDiagnostics {
public record Report(int width, int length, int height, int surveyedCells,
int plannedCells, int solids, int emptyCells, int foundationCells,
int weatheredCells, int stairs, int bridges, int modules,
int storeys, int navigationTargets, int terraceRelief) {
public String compact() {
return width + "x" + length + "x" + height + " blocks; "
+ modules + " buildings / " + storeys + " floors; "
+ bridges + " bridge links; " + stairs + " stairs; "
+ navigationTargets + " walkable targets; "
+ foundationCells + " foundation blocks";
}
}
public static Report analyze(Plan plan) {
Objects.requireNonNull(plan);
int minX=Integer.MAX_VALUE,minY=Integer.MAX_VALUE,minZ=Integer.MAX_VALUE;
int maxX=Integer.MIN_VALUE,maxY=Integer.MIN_VALUE,maxZ=Integer.MIN_VALUE;
int air=0, foundations=0, weathered=0, stairs=0;
Set<CastlePlanner.Pos> coordinates = new HashSet<>();
for (Block b : plan.blocks()) {
var p=b.pos();
if(!coordinates.add(p)) throw new IllegalArgumentException("Duplicate architecture position");
minX=Math.min(minX,p.x()); maxX=Math.max(maxX,p.x());
minY=Math.min(minY,p.y()); maxY=Math.max(maxY,p.y());
minZ=Math.min(minZ,p.z()); maxZ=Math.max(maxZ,p.z());
switch (b.kind()) {
case AIR -> air++;
case FOUNDATION -> foundations++;
case WEATHERED -> weathered++;
case STAIR, ROOF_STAIR -> stairs++;
default -> {}
}
}
if (coordinates.isEmpty()) throw new IllegalArgumentException("No building geometry");
int storeys=plan.rooms().stream().mapToInt(Room::storeys).sum();
int bridges=(int)plan.links().stream().filter(Link::bridge).count();
return new Report(maxX-minX+1,maxZ-minZ+1,maxY-minY+1,
(2*TerracedCastlePlanner.RADIUS+1)*(2*TerracedCastlePlanner.RADIUS+1),
plan.blocks().size(),plan.blocks().size()-air,air,foundations,weathered,
stairs,bridges,plan.rooms().size(),storeys,plan.targets().size(),plan.relief());
}
private PlanDiagnostics() {}
}
59 changes: 59 additions & 0 deletions core/src/test/java/dev/castleforge/core/IdentityVerification.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package dev.castleforge.core;

import java.util.*;
import static dev.castleforge.core.CastlePlanner.Condition;

/** Independent identity/telemetry checks; pure Java 21, no Minecraft runtime. */
public final class IdentityVerification {
private static int assertions;
private static void check(boolean pass, String text) {
assertions++;
if(!pass) throw new AssertionError(text);
}
public static void main(String[] args) {
String[] styles={"central_european","nordic","mediterranean","desert_citadel","east_asian",
"gothic","high_fantasy","maritime"};
Set<String> names=new HashSet<>(), emblems=new HashSet<>(), dynasties=new HashSet<>();
for(int seed=0;seed<100;seed++) for(String style:styles) {
var region=new CultureMap.Region("kingdom-"+seed+"-"+style,style,style,0,0,0,7168);
for(Condition condition:Condition.values()) {
var a=CastleIdentity.generate(seed,seed*100,-seed*37,region,condition);
var b=CastleIdentity.generate(seed,seed*100,-seed*37,region,condition);
check(a.equals(b),"stable site identity");
check(a.ageYears()>=120 && a.ageYears()<=800,"plausible age range");
check(a.events().size()>=3,"historical milestones");
check(a.events().getFirst().yearsAgo()==a.ageYears(),"foundation starts chronology");
for(int i=1;i<a.events().size();i++)
check(a.events().get(i).yearsAgo()<a.events().get(i-1).yearsAgo(),"history sorted oldest first");
check(a.name().length()>7,"name produced");
check(a.culture().equals(style),"original culture retained");
check(a.expectedOccupancy()==switch(condition) {
case RESTORED -> CastleIdentity.Occupancy.INHABITED;
case WEATHERED -> CastleIdentity.Occupancy.SPARSE;
case RUINED -> CastleIdentity.Occupancy.ABANDONED;
}, "intended population follows maintenance");
names.add(a.name()); dynasties.add(a.dynasty()); emblems.add(a.heraldry());
}
var a=CastleIdentity.generate(seed,0,0,region,Condition.RESTORED);
var b=CastleIdentity.generate(seed,10000,5000,region,Condition.RUINED);
check(a.dynasty().equals(b.dynasty()) && a.heraldry().equals(b.heraldry()),
"same region shares lineage across castle sites");
}
check(names.size()>120,"names differ across culture and seed");
check(dynasties.size()>40,"kingdoms get distinct dynasties");
check(emblems.size()==8,"all heraldic combinations represented");
var region=new CultureMap.Region("special","gothic","nordic",0,0,0,7168);
check(!CastleIdentity.generate(1,0,0,region,Condition.RUINED)
.equals(CastleIdentity.generate(2,0,0,region,Condition.RUINED)),"seed changes identity");
var plan=TerracedCastlePlanner.plan(42,0,0,(x,z)->64,region);
var report=PlanDiagnostics.analyze(plan);
check(report.width()>=35 && report.width()<=105 && report.length()>=70 && report.height()>=18, "bounded elongated multi-court layout");
check(report.modules()==8 && report.navigationTargets()==plan.targets().size(),"module/target counts");
check(report.plannedCells()==report.solids()+report.emptyCells(),"every voxel classified");
check(report.storeys()>=13 && report.foundationCells()>=0,"room floors tracked");
check(report.terraceRelief()==plan.relief(),"terrace relief unchanged");
check(report.compact().contains("bridge links"),"plain text debug report");
System.out.println("PASS identity/diagnostics: "+assertions+" assertions across 100 seeds and 8 cultures.");
}
private IdentityVerification() {}
}
28 changes: 28 additions & 0 deletions docs/IDENTITY_AND_DIAGNOSTICS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Castle identities and architectural reports (0.2.1 alpha)

## What is implemented

`CastleIdentity.generate(seed, x, z, region, condition)` is a stateless, independent core function:
- Site name and regional dynasty are derived from seed and culture and can be recreated without a save-file database.
- Regional heraldry is a **textual motif**; Minecraft banner/block entities have not been generated.
- Ages range from 120 to 800 fictional years. Construction events are sorted from oldest to newest and depend on restoration status.
- Intended population level is `INHABITED`, `SPARSE`, or `ABANDONED`, but **does not spawn entities**.
- All returned collections are immutable. `CastleIdentity.VERSION = 1` is the metadata algorithm version. It is independent from world geography and geometry versions.

`PlanDiagnostics.analyze(plan)` counts planned cells, foundation/weathered/stair blocks, module storeys, bridge links and navigation target declarations, plus a 3D bounding box. It reports the *plan* rather than measured FPS, actual height-map validation or proven Minecraft pathfinding.

The Fabric bridge exposes metadata in the existing preview summary and an additional read-only `/castleforge inspect` command. This command reads the most recent, still-valid preview **for the current operator**. It performs no extra chunk generation or block placement. It cannot inspect already-placed castles or discover existing structures.

Facades use a culturally more suitable decorative trim and timber block where possible. Existing geometry is unchanged. Material changes only affect future manually placed castles, not existing world blocks.

## Test and acceptance

- `gradle --no-daemon build` must run all three core suites and compile the Fabric adapter.
- `bash scripts/verify-core.sh` can verify the pure Java core with JDK 21+.
- Verify the metadata suite covers all eight culture IDs, 100 seeds, three preservation states, chronology, reproducibility, population intentions and dynasty consistency.
- In Minecraft test `/castleforge preview terraced`, then `/castleforge inspect`; confirm no world blocks changed.
- Inspect both classic and terraced plans; compare the preview report to the actual built result.
- Test aged/ruined castles' trim/wood combinations under all cultural palettes and watch for unsupported block states.
- Keep `main` and the previously compiled terraced alpha intact until in-game feedback validates the new build.

This metadata release intentionally does **not** alter `CultureMap`, `CastlePlanner`, `TerracedCastlePlanner` or `PlanNavigation`. It does not solve large monuments, natural generation, automatic biome measurement or Bedrock.
Loading
Loading