Progress on initializing population in sbcl
This commit is contained in:
parent
dbe97f0df7
commit
e8d373d4f9
5 changed files with 26 additions and 1 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -11,4 +11,6 @@ Cargo.lock
|
||||||
|
|
||||||
settings.json
|
settings.json
|
||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
.vscode/alive
|
1
carp_spike/.gitignore
vendored
Normal file
1
carp_spike/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
out/
|
10
carp_spike/main.carp
Normal file
10
carp_spike/main.carp
Normal 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
0
sbcl_spike/.gitignore
vendored
Normal file
12
sbcl_spike/main.lisp
Normal file
12
sbcl_spike/main.lisp
Normal 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))
|
Loading…
Add table
Reference in a new issue