mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-21 05:35:45 +01:00
Tuned Shortest Path contract generation
Now generates about 4/5 puzzles where a path exists and 1/5 with the destination completely blocked off.
This commit is contained in:
parent
fb0cc15794
commit
809f8f6687
@ -838,9 +838,10 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
|
|||||||
if(y == 0 && x == 0) continue; // Don't block start
|
if(y == 0 && x == 0) continue; // Don't block start
|
||||||
if(y == dstY && x == dstX) continue; // Don't block destination
|
if(y == dstY && x == dstX) continue; // Don't block destination
|
||||||
|
|
||||||
// Generate more obstacles the farther a position is from start and destination,
|
// Generate more obstacles the farther a position is from start and destination.
|
||||||
// with minimum obstacle chance of 15%
|
// Raw distance factor peaks at 50% at half-way mark. Rescale to 40% max.
|
||||||
const distanceFactor = Math.min(y + x, dstY - y + dstX - x) / minPathLength;
|
// Obstacle chance range of [15%, 40%] produces ~78% solvable puzzles
|
||||||
|
const distanceFactor = Math.min(y + x, dstY - y + dstX - x) / minPathLength * 0.8;
|
||||||
if (Math.random() < Math.max(0.15, distanceFactor))
|
if (Math.random() < Math.max(0.15, distanceFactor))
|
||||||
grid[y][x] = 1;
|
grid[y][x] = 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user