diff --git a/terranostra.lisp b/terranostra.lisp index dc73ebd..d6a1353 100644 --- a/terranostra.lisp +++ b/terranostra.lisp @@ -5,6 +5,8 @@ ;;;; (c) 2018 Daniel Vedder ;;;; +;;(load "util.lisp") ;; I want to avoid using this if possible + (defvar *world* NIL) (defstruct patch @@ -25,3 +27,22 @@ "Return the patch at the given coordinates or NIL if out of bounds" (unless (or (< x 0) (< y 0) (> x (length world)) (> y (length world))) (nth x (nth y world)))) + +(defun save-topography (file-name &optional (world *world*)) + "Save the world topography as a csv file" + (with-open-file (tf file-name :direction :output) + (dolist (row world) + ;; XXX This would be quicker with (string-from-list), but I + ;; don't want to use util.lisp just yet + (do ((x 0 (1+ x)) (xstr "")) + ((= x (length world)) (format tf "~&~S~%" xstr)) + (setf xstr (concatenate 'string xstr (unless (= x 0) ",") + (format NIL "~S" (patch-alt (nth x row))))))))) + +(defun create-mountains (world &optional (montaneity 2)) + "Create mountains and hills. Montaneity determines their number and height." + ) + +(defun create-valleys (world &optional (aqueousness 5)) + "Create valleys through streams. Aqueousness determines their number." + )