feuforeve.v4/daily-island-updater.rkt

31 lines
939 B
Racket
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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
(island-render island directory-name))