Exemple #1
0
func spawn(gen *chunk.Gen, chunks []*chunk.Chunk, pegIdx int, chunkIdx int) {
	for {
		pegs := gen.OpenPegs()
		if len(pegs) == 0 {
			return
		}
		peg := pegs[pegIdx%len(pegs)]
		fits := []chunk.OffsetChunk{}
		// Add the chunks that fit in the lattice
		for _, oc := range gen.FittingChunks(peg, chunks) {
			fits = append(fits, oc)
		}
		if len(fits) == 0 {
			gen.ClosePeg(peg)
			continue
		}
		gen.AddChunk(fits[chunkIdx%len(fits)])
		return
	}
}