Documentation
¶
Index ¶
- Variables
- func CreateGameLevel(id int, name, difficulty string, width, height int, verbose bool, seed int64, ...) *common.Level
- func FastScoreBlocking(vines []common.Vine, gridSize [2]int) (float64, int)
- func GrowFromSeed(seed common.Point, occupied map[string]bool, gridSize [2]int, targetLen int, ...) (common.Vine, map[string]bool, error)
- func SweepParams(difficulty string, iters int) (float64, common.GeneratorConfig, common.VarietyProfile, int64)
- func TileGridIntoVines(gridSize [2]int, constraints common.DifficultySpec, ...) ([]common.Vine, error)
- type GenerationResult
Constants ¶
This section is empty.
Variables ¶
var LevelGenerateCmd = &cobra.Command{ Use: "level-generate", Short: "Generate a new game level", Long: `Generate a new game level for the Parable Bloom project. This command creates solvable levels with the required structure and metadata.`, Run: func(cmd *cobra.Command, _args []string) { isVerbose := utils.IsVerbose(cmd) log.Start("Generating game levels") name, _ := cmd.Flags().GetString("name") moduleID, _ := cmd.Flags().GetInt("module") width, _ := cmd.Flags().GetInt("grid-width") height, _ := cmd.Flags().GetInt("grid-height") output, _ := cmd.Flags().GetString("output") stdout, _ := cmd.Flags().GetBool("stdout") overwrite, _ := cmd.Flags().GetBool("overwrite") count, _ := cmd.Flags().GetInt("count") seed, _ := cmd.Flags().GetInt64("seed") randomize, _ := cmd.Flags().GetBool("randomize") render, _ := cmd.Flags().GetBool("render") renderStyle, _ := cmd.Flags().GetString("render-style") renderCoords, _ := cmd.Flags().GetBool("render-coords") if output == "" { output = "assets/levels" } modules, err := common.LoadModules("") if err != nil { log.Error("Failed to load modules: %v", err) os.Exit(1) } if count > 1 { generateBatch( modules, moduleID, count, output, overwrite, isVerbose, seed, randomize, render, renderStyle, renderCoords, ) } else { generateSingle( name, width, height, output, stdout, overwrite, modules, isVerbose, seed, randomize, render, renderStyle, renderCoords, ) } }, }
LevelGenerateCmd represents the 'parable-bloom level-generate' command for generating new game levels. It provides tools to scaffold and generate new level files for the Parable Bloom game.
Functions ¶
func CreateGameLevel ¶ added in v0.30.1
func FastScoreBlocking ¶
FastScoreBlocking computes a simple blocking score and maximum blocking depth for a set of vines on a grid. It mutates vine.Blocks via calculateBlocking.
func GrowFromSeed ¶
func GrowFromSeed( seed common.Point, occupied map[string]bool, gridSize [2]int, targetLen int, profile common.VarietyProfile, _ common.GeneratorConfig, rng *rand.Rand, ) (common.Vine, map[string]bool, error)
GrowFromSeed attempts to grow a vine starting from seed, avoiding occupied cells. It returns the vine and the updated occupancy map on success.
func SweepParams ¶
func SweepParams(difficulty string, iters int) (float64, common.GeneratorConfig, common.VarietyProfile, int64)
SweepParams runs the parameter sweep and returns the best results.
func TileGridIntoVines ¶
func TileGridIntoVines( gridSize [2]int, constraints common.DifficultySpec, profile common.VarietyProfile, cfg common.GeneratorConfig, rng *rand.Rand, ) ([]common.Vine, error)
TileGridIntoVines partitions the grid into vines according to the provided difficulty constraints and a variety profile. It returns a full-coverage set of vines (no overlaps, each cell assigned exactly once) or an error.
Types ¶
type GenerationResult ¶
type GenerationResult struct {
Vines []common.Vine
Score float64
MaxBlockingDepth int
GreedySolvable bool
BFSSolvable bool
Attempts int
SeedUsed int64 // seed used for the successful variant
ElapsedMS int64 // generation time in milliseconds
}
GenerationResult contains metadata about a generation attempt.
func CreateLevelWithProfile ¶ added in v0.30.1
func CreateLevelWithProfile( gridSize [2]int, constraints common.DifficultySpec, profile common.VarietyProfile, cfg common.GeneratorConfig, seed int64, strictMode bool, rng *rand.Rand, ) GenerationResult
CreateLevelWithProfile tries to create a tiled level using the given profile and config. It runs fast pre-validation and greedy solver gating; optionally runs BFS for final verification if strictMode is true. It returns a GenerationResult containing score and solvability flags.