<commit_before>package mapgen

import (
	"buildblast/lib/coords"
)

type FlatWorld struct{}

// Take seed to be consistent with all the other world types
func NewFlatWorld(seed float64) *FlatWorld {
	_ = seed
	return new(FlatWorld)
}

func (fw *FlatWorld) Block(bc coords.Block) Block {
	if bc.X == 0 && bc.Y == 16 && bc.Z == 0 {
		return BLOCK_SPAWN
	}
	if bc.Y < 16 {
		return BLOCK_DIRT
	}
	if bc.X%4 == 0 && bc.Z%4 == 0 && bc.Y < 17 {
		return BLOCK_STONE
	}
	return BLOCK_AIR
}

func (fw *FlatWorld) Chunk(cc coords.Chunk) *Chunk {
	return generateChunk(fw, cc)
}<commit_msg>Update the flat world to generate random blocks.<commit_after>package mapgen

import (
	"math/rand"

	"buildblast/lib/coords"
)

type FlatWorld struct {
	seed float64
}

// Take seed to be consistent with all the other world types
func NewFlatWorld(seed float64) *FlatWorld {
	fw := new(FlatWorld)
	fw.seed = seed
	return fw
}

func (fw *FlatWorld) Block(bc coords.Block) Block {
	fw.seedRand(bc)

	if bc.X == 0 && bc.Y == 16 && bc.Z == 0 {
		return BLOCK_SPAWN
	}
	if bc.Y < 15 {
		return BLOCK_DIRT
	}
	if bc.Y == 15 {
		return BLOCK_GRASS
	}
	if bc.X%4 == 0 && bc.Z%4 == 0 && bc.Y < 17 {
		randBlock := 5 + rand.Int() % 9;
		return Block(randBlock)
	}
	return BLOCK_AIR
}

func (fw *FlatWorld) Chunk(cc coords.Chunk) *Chunk {
	return generateChunk(fw, cc)
}

func (fw *FlatWorld) seedRand(bc coords.Block) {
	result := int64(bc.X)
	result += int64(bc.Y) << 32
	result += int64(bc.Z) << 16
	result += int64(fw.seed)
	rand.Seed(result)
}
{'fraction_non_alphanumeric': 0.13965744400527008, 'fraction_numerical': 0.030303030303030304, 'mean_word_length': 3.4676470588235295, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1955579', 'n_tokens_mistral': 671, 'n_tokens_neox': 610, 'n_words': 169}