worldgen

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2025 License: MulanPSL-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package worldgen provides core types and interfaces for dynamic world generation.

Package worldgen provides core types and interfaces for dynamic world generation.

Package worldgen provides core types and interfaces for dynamic world generation.

Index

Constants

View Source
const (
	// ChunkSize defines the dimensions of each chunk (32x32 tiles).
	ChunkSize = 32

	// DefaultDifficulty is the default difficulty coefficient.
	DefaultDifficulty = 0.5

	// DefaultSimilarity is the default similarity coefficient.
	DefaultSimilarity = 0.8
)

Variables

This section is empty.

Functions

func BlendEdge

func BlendEdge(chunk ChunkData, neighbors map[ChunkCoord]ChunkData, similarity float64, rng *rand.Rand)

BlendEdge blends the edges of a chunk with its neighbors.

func GetTransitionProbability

func GetTransitionProbability(from, to TileType) float64

GetTransitionProbability returns the natural transition probability between two tile types.

func ShouldTransition

func ShouldTransition(currentTile, neighborTile TileType, similarity float64, rng *rand.Rand) bool

ShouldTransition determines if a tile should transition based on neighbor influence.

Types

type ChunkCoord

type ChunkCoord struct {
	X, Y int
}

ChunkCoord represents the unique coordinates of a map chunk.

type ChunkData

type ChunkData [][]TileType

ChunkData represents the tile data for a single chunk.

type Generator

type Generator interface {
	// GenerateChunk generates chunk data for the given coordinates.
	// neighbors provides adjacent chunk data for seamless transitions.
	GenerateChunk(coord ChunkCoord, difficulty, similarity float64,
		neighbors map[ChunkCoord]ChunkData) (ChunkData, error)
}

Generator is the core interface for world generation algorithms.

type NeighborProvider

type NeighborProvider func(coord ChunkCoord) (ChunkData, error)

NeighborProvider is a function type for querying neighboring chunk data. This allows the generator to remain decoupled from chunk storage.

type TileType

type TileType int

TileType represents the type of a single tile on the map.

const (
	TileTypeEmpty TileType = iota
	TileTypeGrass
	TileTypeWater
	TileTypeForest
	TileTypeMountain
	TileTypeDesert
	TileTypeLava
)

func (TileType) String

func (t TileType) String() string

String returns a human-readable representation of the TileType.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL