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.
This commit is contained in:
parent
58c4edf8fd
commit
f9e80eaedc
|
|
@ -177,8 +177,9 @@ export function chooseAction(state, seat) {
|
||||||
return { type: 'buildSettlement', nodeId: settleSpots[0] };
|
return { type: 'buildSettlement', nodeId: settleSpots[0] };
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Build a road that opens a new settlement spot or extends longest road.
|
// 4. Build a road only when no settlement spot is already reachable.
|
||||||
if (canAfford(p, COSTS.road)) {
|
// 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);
|
const road = chooseExpansionRoad(state, seat);
|
||||||
if (road != null) return { type: 'buildRoad', edgeId: road };
|
if (road != null) return { type: 'buildRoad', edgeId: road };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue