1 (define-module (dungeon-master generators town)
2 #:use-module (dungeon-master geom voronoi)
3 #:use-module (dungeon-master geom point)
9 (define pi 3.141592654)
11 (define (generate patches)
12 "City generator from https://github.com/watabou/TownGeneratorOS/blob/master/Source/com/watabou/towngenerator/building/Model.hx"
13 (set! *random-state* (random-state-from-platform))
14 (when (= patches -1) (set! patches 15))
15 (build-patches patches))
17 (define (build-patches patches)
18 (define* (get-points n seed #:optional (l '()))
20 (let* ((a (+ seed (* (sqrt n) 5)))
23 (+ 10 (* n (+ 2 (random:exp))))))
27 (get-points (- n 1) seed (cons point l))))
31 (let* ((sa (* (random:exp) 2 pi))
32 (points (get-points (* 8 patches) sa))
33 (voronoi (make-voronoi-mesh points)))
34 (format #t "~a~%~%~a~%" (voronoi-mesh-frame voronoi) (voronoi-mesh-points voronoi))))