Fix early blossom loophole
authorJoachim Breitner <mail@joachim-breitner.de>
Fri, 26 Jun 2009 22:30:52 +0000 (00:30 +0200)
committerJoachim Breitner <mail@joachim-breitner.de>
Fri, 26 Jun 2009 22:30:52 +0000 (00:30 +0200)
src/Lseed/Constants.hs
src/Lseed/Logic.hs

index 55c071d..47c07c3 100644 (file)
@@ -48,7 +48,7 @@ lightFalloff = 0.4
 
 -- | Length of one day, in seconds
 dayLength :: Double
-dayLength = 30
+dayLength = 2
 
 -- | ε
 eps = 1e-9
index 4ae126a..8add303 100644 (file)
@@ -79,7 +79,7 @@ growPlanted planted light =
        in  if remainingLength > eps
             then let sizeOfPlant = plantLength (phenotype planted)
                      lightAvailable = light - costPerLength * sizeOfPlant^2
-                    lowerBound = if sizeOfPlant < smallPlantBoostSize
+                    lowerBound = if sizeOfPlant < smallPlantBoostSize && not (doesBlossom (phenotype planted))
                                  then (1 - sizeOfPlant / smallPlantBoostSize) * smallPlantBoostLength
                                  else 0
                      allowedGrowths = max lowerBound $
@@ -90,6 +90,9 @@ growPlanted planted light =
                 in \tickDiff -> applyGrowth (tickDiff * growthFraction) planted
            else const planted
 
+doesBlossom (Plant { pData = (GrowingSeed _) }) = True
+doesBlossom (Plant { pBranches = ps }) = any doesBlossom ps
+
 -- | Applies Growth at given fraction, leaving the target length in place
 applyGrowth :: Double -> GrowingPlanted -> GrowingPlanted
 applyGrowth r = mapPlanted (applyGrowth' (\a b -> a * (1-r) + b * r))