Commit 47dccc9d authored by Jorn W. Janneck's avatar Jorn W. Janneck

and more comments...

parent 77585188
......@@ -3,7 +3,7 @@
)
(def Default-RGB-Map
(def Default-RGB-Map ;; a few default species, named for the color that represents them
{
:red [255 0 0]
:blue [0 0 255]
......@@ -19,6 +19,7 @@
(defn step-all-and-set
"make a step, return stats (and modify the references containing the world state)"
[worldref popref]
(let
......@@ -42,11 +43,12 @@
;;
(defn tournament
"create a tournament function, based on a genesis spec"
(
[genesis rgb-map]
(fn [n flags]
(fn [n flags] ;; this is the tournament function
(let
[
world (create-world MaxCellEnergy)
......
......@@ -7,14 +7,19 @@
'(java.awt.image BufferedImage)
'(javax.swing JPanel JFrame))
;;
;; this namespace contains stuff to create a simple graphic display of the state of an amoebas simulation
;;
(def CellSize 4)
(def CellSize 4) ;; visual size of a cell, in pixels
(def FuelRGB [0 255 0 255] )
(def FuelRGB [0 255 0] ) ;; color value of a fully fueled cell; it's green.
(defn scale-rgb
"scale RGB triple by a number from 0.0 to 1.0"
[r rgb]
(vec (for [c rgb] (bound 0 (int (* r c)) 255)))
......@@ -22,6 +27,7 @@
(defn fill-cell
"fill cell with specified RGB value"
[#^Graphics g x y rgb]
(doto g
......@@ -31,6 +37,8 @@
)
(defn draw-world
"draw the world: scaled FuelRGB for empty cells, the color corresponding to the species
for those that contain an amoeba"
[#^Graphics g world population species-rgb]
(doseq [x (range WorldSize) y (range WorldSize)]
......@@ -42,8 +50,7 @@
)
)
(defn render-world
[g world population species-rgb]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment