Guest User

Untitled

a guest
Apr 26th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. (defclass random-world (world)
  2. ((initial-random-state :initarg :initial-random-state :accessor initial-random-state))
  3. (:default-initargs :initial-random-state (make-random-state t)))
  4.  
  5. (defmethod shared-initialize :after ((world random-world) slot-names &rest initargs &key)
  6. (declare (ignore slot-names initargs))
  7. (let ((*random-state* (make-random-state (initial-random-state world))))
  8. ;; Add random objects to the world
  9. ))
  10.  
  11. (defmethod reinitialize-instance :before ((world random-world) &rest initargs)
  12. (declare (ignore initargs))
  13. (clear-objects world)) ; tbd
  14.  
  15. (defun random-worlds-generator (n)
  16. (let ((worlds (map-into (make-array n) (lambda () (make-instance 'random-world)))))
  17. (lambda (index)
  18. (reinitialize-instance (aref worlds (mod index n))))))
Add Comment
Please, Sign In to add comment