Limit growth by cost of size^2
authorJoachim Breitner <mail@joachim-breitner.de>
Mon, 2 Mar 2009 19:29:45 +0000 (20:29 +0100)
committerJoachim Breitner <mail@joachim-breitner.de>
Mon, 2 Mar 2009 19:30:07 +0000 (20:30 +0100)
src/Lseed/Constants.hs
src/main.hs

index 2be4e6e..0a81200 100644 (file)
@@ -17,6 +17,9 @@ growthPerDayAndLight = 15.0
 -- | Default growth (for plants without light)
 growthPerDay = 0.5
 
+-- | Cost (in light units) per (length for maintaining the plant)^2, to limit the growth of the plants
+costPerLength = 0.002
+
 -- | Length of one day, in seconds
 dayLength = 10 
 
index 194e93e..0f14c7f 100644 (file)
@@ -80,7 +80,10 @@ growPlanted rgen planted light =
                        else planted
            remainingLength = remainingGrowth planted'
        in  if remainingLength > eps
-            then let allowedGrowths = (growthPerDayAndLight * light + growthPerDay) /
+            then let sizeOfPlant = extractOutmost $ plantSubpieceLength (phenotype planted)
+                     lightAvailable = light - costPerLength * sizeOfPlant^2
+                     allowedGrowths = max 0 $
+                                      (growthPerDayAndLight * lightAvailable + growthPerDay) /
                                       (fromIntegral ticksPerDay) 
                     growthThisTick = min remainingLength allowedGrowths
                     growthFraction = growthThisTick / remainingLength