Progress on initializing population in sbcl

This commit is contained in:
vandomej 2023-03-21 01:08:02 -07:00
parent dbe97f0df7
commit e8d373d4f9
5 changed files with 26 additions and 1 deletions

2
.gitignore vendored
View file

@ -12,3 +12,5 @@ Cargo.lock
settings.json
.DS_Store
.vscode/alive

1
carp_spike/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
out/

10
carp_spike/main.carp Normal file
View file

@ -0,0 +1,10 @@
(use Random)
(Project.config "title" "gemla")
(deftype SimulationNode [population-size Int, population-cutoff Int])
;; (let [test (SimulationNode.init 10 3)]
;; (do
;; (SimulationNode.set-population-size test 20)
;; (SimulationNode.population-size &test)
;; ))

0
sbcl_spike/.gitignore vendored Normal file
View file

12
sbcl_spike/main.lisp Normal file
View file

@ -0,0 +1,12 @@
;; Define a type that contains a population size and a population cutoff
(defclass simulation-node () ((population-size :initarg :population-size :accessor population-size)
(population-cutoff :initarg :population-cutoff :accessor population-cutoff)
(population :initform () :accessor population)))
;; Define a method that initializes population-size number of children in a population each with a random value
(defmethod initialize-instance :after ((node simulation-node) &key)
(setf (population node) (make-list (population-size node) :initial-element (random 100))))
(let ((node (make-instance 'simulation-node :population-size 100 :population-cutoff 10)))
(print (population-size node))
(population node))