plant-fitness can now depend on multiple plants

This commit is contained in:
Stefan Dresselhaus
2018-05-29 22:20:33 +02:00
parent 3dba2a478b
commit 2b7d0e6682
2 changed files with 24 additions and 23 deletions

View File

@ -86,7 +86,7 @@ loop loopAmount = loop' loopAmount 0
putStrLn ""
putStrLn $ "Generation " ++ show curLoop ++ " of " ++ show loopAmount ++ ":"
newPlants <- flip runReaderT e $ do
! fs <- sequence (fitness <$> plants)
! fs <- fitness plants
let fps = zip plants fs -- gives us plants & their fitness in a tuple
sumFitness = sum fs
pe <- asks possibleEnzymes
@ -114,13 +114,13 @@ main :: IO ()
main = do
hSetBuffering stdin NoBuffering
hSetBuffering stdout NoBuffering
randomCompounds <- makeHead (Substrate Photosynthesis) <$> generateTreeFromList 40 (toEnum <$> [(maxCompoundWithoutGeneric+1)..] :: [Compound]) -- generate roughly x compounds
randomCompounds <- makeHead (Substrate Photosynthesis) <$> generateTreeFromList 50 (toEnum <$> [(maxCompoundWithoutGeneric+1)..] :: [Compound]) -- generate roughly x compounds
ds <- randoms <$> newStdGen
probs <- randomRs (0.2,0.7) <$> newStdGen
let emptyPlants = replicate 100 emptyPlant
let emptyPlants = replicate 50 emptyPlant
poisonedTree = poisonTree ds randomCompounds
poisonCompounds = foldMap (\(a,b) -> [(b,a) | a > 0.5]) poisonedTree
predators <- generatePredators 0.5 poisonedTree
predators <- generatePredators 0.8 poisonedTree
let env = exampleEnvironment (getTreeSize randomCompounds) (generateEnzymeFromTree randomCompounds) (zip predators probs) poisonCompounds
printEnvironment env
writeFile "poison.twopi" $ generateDotFromPoisonTree "poison" 0.5 poisonedTree