Created
December 24, 2009 07:09
-
-
Save death/263071 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defclass random-world (world) | |
((initial-random-state :initarg :initial-random-state :accessor initial-random-state)) | |
(:default-initargs :initial-random-state (make-random-state t))) | |
(defmethod shared-initialize :after ((world random-world) slot-names &rest initargs &key) | |
(declare (ignore slot-names initargs)) | |
(let ((*random-state* (make-random-state (initial-random-state world)))) | |
;; Add random objects to the world | |
)) | |
(defmethod reinitialize-instance :before ((world random-world) &rest initargs) | |
(declare (ignore initargs)) | |
(clear-objects world)) ; tbd | |
(defun random-worlds-generator (n) | |
(let ((worlds (map-into (make-array n) (lambda () (make-instance 'random-world))))) | |
(lambda (index) | |
(reinitialize-instance (aref worlds (mod index n)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment