From f9e80eaedcefce51304d1ba2bc15a11ab2ded3ec Mon Sep 17 00:00:00 2001 From: Brian Fertig Date: Sat, 23 May 2026 17:44:55 -0600 Subject: [PATCH] fix(catan): improve AI resource management by prioritizing settlements over roads The AI now waits to build a road until no settlement spots are immediately reachable. This prevents wasting resources on roads when a settlement could be built, ensuring more efficient resource accumulation for higher-cost structures. --- public/src/games/catan/CatanAI.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/public/src/games/catan/CatanAI.js b/public/src/games/catan/CatanAI.js index 2cf943f..6a78575 100644 --- a/public/src/games/catan/CatanAI.js +++ b/public/src/games/catan/CatanAI.js @@ -177,8 +177,9 @@ export function chooseAction(state, seat) { return { type: 'buildSettlement', nodeId: settleSpots[0] }; } - // 4. Build a road that opens a new settlement spot or extends longest road. - if (canAfford(p, COSTS.road)) { + // 4. Build a road only when no settlement spot is already reachable. + // If a spot exists, hold resources and save up for the settlement instead. + if (canAfford(p, COSTS.road) && settleSpots.length === 0) { const road = chooseExpansionRoad(state, seat); if (road != null) return { type: 'buildRoad', edgeId: road }; }