2020-05-24 14:31:32 +02:00
|
|
|
|
#lang racket/base
|
|
|
|
|
|
|
|
|
|
; Daily island updater
|
|
|
|
|
; This scripts generates islands
|
|
|
|
|
; It should be called once a day to create the daily island for the following day
|
|
|
|
|
|
|
|
|
|
(module+ main
|
|
|
|
|
(require
|
|
|
|
|
racket/date
|
|
|
|
|
racket/file
|
|
|
|
|
"src/generators/island.rkt"
|
|
|
|
|
"src/generators/island/renderer.rkt")
|
|
|
|
|
; Reseed the generator
|
|
|
|
|
(define seed (current-seconds))
|
|
|
|
|
(random-seed seed)
|
|
|
|
|
; Generate an island (200×200)
|
|
|
|
|
(define island (island-generate 200))
|
|
|
|
|
; Create the output directory if is does not exist yet
|
|
|
|
|
; Directory name
|
|
|
|
|
(define tomorrow
|
|
|
|
|
(parameterize ((date-display-format 'iso-8601))
|
|
|
|
|
(date->string
|
|
|
|
|
(seconds->date (+ (* 24 60 60) (* 0.001 (current-inexact-milliseconds))))
|
|
|
|
|
)))
|
|
|
|
|
(define directory-base "static/islands")
|
|
|
|
|
(define directory-name (string-append directory-base "/" tomorrow))
|
|
|
|
|
; Create the directory
|
|
|
|
|
(make-directory* directory-name)
|
|
|
|
|
; Save the island
|
2020-07-19 19:19:19 +02:00
|
|
|
|
(island-render island directory-name))
|