feuforeve.v4/src/generators/island/cell.rkt

77 lines
1.5 KiB
Racket

#lang racket/base
; Cell of island generator
; The island generator uses cells to discretely represents the map
(provide
; Constructor
cell
; Accessors
cell-altitude set-cell-altitude
cell-biome set-cell-biome
cell-temperature set-cell-temperature
cell-rainfall set-cell-rainfall
)
; Cell structure
(struct s-cell
(altitude ; number
biome ; symbol or #f is not set
temperature ; number, in °C
rainfall ; number, annual in cm per m²
))
; Cell constructor
(define (cell)
(s-cell
0
#f
0
0))
; Accessors
; Altitude
(define (cell-altitude c)
(s-cell-altitude c))
; Return a new cell copied from a cell with altitude changed
(define (set-cell-altitude c alt)
(s-cell
alt
(s-cell-biome c)
(s-cell-temperature c)
(s-cell-rainfall c)
))
; Biome
(define (cell-biome c)
(s-cell-biome c))
; Return a new cell copied from a cell with biome changed
(define (set-cell-biome c biome)
(s-cell
(s-cell-altitude c)
biome
(s-cell-temperature c)
(s-cell-rainfall c)))
; Temperature
(define (cell-temperature c)
(s-cell-temperature c))
; Return a new cell copied from a cell with temperature changed
(define (set-cell-temperature c temperature)
(s-cell
(s-cell-altitude c)
(s-cell-biome c)
temperature
(s-cell-rainfall c)))
; Rainfall
(define (cell-rainfall c)
(s-cell-rainfall c))
; Return a new cell copied from a cell with rainfall changed
(define (set-cell-rainfall c rainfall)
(s-cell
(s-cell-altitude c)
(s-cell-biome c)
(s-cell-temperature c)
rainfall))