Skip to content

Commit

Permalink
Add air as beta
Browse files Browse the repository at this point in the history
  • Loading branch information
charredUtensil committed Jul 10, 2024
1 parent 8011cd6 commit ade36ea
Show file tree
Hide file tree
Showing 19 changed files with 270 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "groundhog",
"version": "0.9.1",
"version": "0.9.2",
"homepage": "https://charredutensil.github.io/groundhog",
"private": true,
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/core/architects/utils/creature_spawners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "../../models/creature";
import { Plan } from "../../models/plan";
import { FencedCavern } from "../../transformers/03_plastic/00_fence";
import { EnscribedCavern } from "../../transformers/04_ephemera/01_enscribe";
import { EnscribedCavern } from "../../transformers/04_ephemera/02_enscribe";
import { getDiscoveryPoint } from "./discovery";
import { eventChain, mkVars, scriptFragment, transformPoint } from "./script";

Expand Down
16 changes: 16 additions & 0 deletions src/core/common/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ export type CavernContext = {
* Does this cavern have slugs in it?
*/
hasSlugs: boolean;
/**
* Does this cavern have limited air?
*/
hasAirLimit: boolean;
/**
* How blobby and jagged caves should be.
* 0 results in perfectly squashed octagons.
Expand Down Expand Up @@ -241,6 +245,14 @@ export type CavernContext = {
* that is out of play on the border of the map.
*/
borderMaxSlope: number;
/**
* GroundHog attempts to calculate how much air is needed to build a Support
* Station by playing perfectly through a (rough) simulation of the level.
* In theory, it should be possible for a very good player to match or beat
* this simulation - but that's not going to be fun. Multiply the estimate by
* the safety factor to get the final air number.
*/
airSafetyFactor: number;
};

enum Die {
Expand All @@ -250,6 +262,7 @@ enum Die {
flood,
heightTargetRange,
hasSlugs,
hasAirLimit,
}

const STANDARD_DEFAULTS = {
Expand Down Expand Up @@ -278,6 +291,7 @@ const STANDARD_DEFAULTS = {
hallHasLandslidesChance: 0.8,
caveLandslideCooldownRange: { min: 15, max: 120 },
hallLandslideCooldownRange: { min: 30, max: 150 },
airSafetyFactor: 2,
crystalGoalRatio: 0.2,
} as const satisfies Partial<CavernContext>;

Expand Down Expand Up @@ -363,6 +377,7 @@ export function inferContextDefaults(
targetSize: dice.init(Die.targetSize).uniformInt({ min: 50, max: 78 }),
...args,
};
const hasAirLimit = false; // dice.init(Die.hasAirLimit).chance(0.75);
const hasSlugs = dice.init(Die.hasSlugs).chance(
{
rock: 0.25,
Expand All @@ -381,6 +396,7 @@ export function inferContextDefaults(
...STANDARD_DEFAULTS,
...DEFAULTS_FOR_BIOME[r.biome],
...getDefaultFlooding(dice, r.biome),
hasAirLimit,
hasSlugs,
heightTargetRange,
...r,
Expand Down
2 changes: 1 addition & 1 deletion src/core/e2e_tests/serialize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { atCenterOfTile, position } from "../models/position";
import { Tile } from "../models/tiles";
import discover from "../transformers/03_plastic/01_discover";
import fence from "../transformers/03_plastic/00_fence";
import serialize from "../transformers/04_ephemera/03_serialize";
import serialize from "../transformers/04_ephemera/04_serialize";
import goldenTest from "./golden";
import strataflux from "../transformers/03_plastic/03_strataflux";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/core/lore/lore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { countLostMiners } from "../architects/lost_miners";
import { DiceBox, PseudorandomStream } from "../common";
import { filterTruthy } from "../common/utils";
import { FluidType, Tile } from "../models/tiles";
import { AdjuredCavern } from "../transformers/04_ephemera/00_adjure";
import { AdjuredCavern } from "../transformers/04_ephemera/01_adjure";
import { GenerateResult } from "./builder";
import { FAILURE, SUCCESS } from "./graphs/conclusions";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/core/models/architect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { EntityPosition } from "./position";
import { Objectives } from "./objectives";
import { DiscoveredCavern } from "../transformers/03_plastic/01_discover";
import { Vehicle, VehicleFactory } from "./vehicle";
import { EnscribedCavern } from "../transformers/04_ephemera/01_enscribe";
import { EnscribedCavern } from "../transformers/04_ephemera/02_enscribe";
import { StrataformedCavern } from "../transformers/03_plastic/02_strataform";
import { CollapseUnion } from "../common/utils";

Expand Down
16 changes: 15 additions & 1 deletion src/core/models/building.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,21 @@ class BuildingTemplate {
readonly id: string;
readonly inspectAbbrev: string;
readonly maxLevel: number;
readonly ore: number;
readonly crystals: number;
readonly footprint: Footprint;
constructor(
id: string,
inspectAbbrev: string,
maxLevel: Level,
ore: number,
crystals: number,
footprint: Footprint,
) {
this.id = id;
this.inspectAbbrev = inspectAbbrev;
this.maxLevel = maxLevel;
this.ore = ore;
this.crystals = crystals;
this.footprint = footprint;
}
Expand Down Expand Up @@ -91,12 +94,14 @@ export const TOOL_STORE = new BuildingTemplate(
"Ts",
3,
0,
0,
F_DEFAULT,
);
export const TELEPORT_PAD = new BuildingTemplate(
"BuildingTeleportPad_C",
"Tp",
2,
8,
0,
F_DEFAULT,
);
Expand All @@ -106,7 +111,8 @@ export const DOCKS = new BuildingTemplate(
"BuildingDocks_C",
"Dk",
1,
1,
8,
0,
F_DEFAULT,
);
// The Canteen is functionally symmetrical, but if you care, the end with
Expand All @@ -115,6 +121,7 @@ export const CANTEEN = new BuildingTemplate(
"BuildingCanteen_C",
"Cn",
1,
10,
1,
F_CANTEEN_REFINERY,
);
Expand All @@ -124,20 +131,23 @@ export const POWER_STATION = new BuildingTemplate(
"BuildingPowerStation_C",
"Ps",
2,
12,
2,
F_POWER_STATION,
);
export const SUPPORT_STATION = new BuildingTemplate(
"BuildingSupportStation_C",
"Ss",
2,
15,
3,
F_DEFAULT,
);
export const UPGRADE_STATION = new BuildingTemplate(
"BuildingUpgradeStation_C",
"Us",
3,
20,
3,
F_DEFAULT,
);
Expand All @@ -146,6 +156,7 @@ export const GEOLOGICAL_CENTER = new BuildingTemplate(
"BuildingGeologicalCenter_C",
"Gc",
5,
20,
2,
F_DEFAULT,
);
Expand All @@ -154,13 +165,15 @@ export const ORE_REFINERY = new BuildingTemplate(
"BuildingOreRefinery_C",
"Or",
4,
20,
3,
F_CANTEEN_REFINERY,
);
export const MINING_LASER = new BuildingTemplate(
"BuildingMiningLaser_C",
"Ml",
1,
10,
1,
F_MINING_LASER,
);
Expand All @@ -169,6 +182,7 @@ export const SUPER_TELEPORT = new BuildingTemplate(
"BuildingSuperTeleport_C",
"St",
2,
20,
4,
F_SUPER_TELEPORT,
);
Expand Down
2 changes: 1 addition & 1 deletion src/core/transformers/03_plastic/00_fence.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EnscribedCavern } from "../04_ephemera/01_enscribe";
import { EnscribedCavern } from "../04_ephemera/02_enscribe";
import fence, { FencedCavern } from "./00_fence";

function bounds({ left, right, bottom, top }: FencedCavern) {
Expand Down
Loading

0 comments on commit ade36ea

Please sign in to comment.