HLint
This commit is contained in:
parent
ee008ba920
commit
3dba2a478b
10
app/Main.hs
10
app/Main.hs
@ -119,11 +119,11 @@ main = do
|
|||||||
probs <- randomRs (0.2,0.7) <$> newStdGen
|
probs <- randomRs (0.2,0.7) <$> newStdGen
|
||||||
let emptyPlants = replicate 100 emptyPlant
|
let emptyPlants = replicate 100 emptyPlant
|
||||||
poisonedTree = poisonTree ds randomCompounds
|
poisonedTree = poisonTree ds randomCompounds
|
||||||
poisonCompounds = foldMap (\(a,b) -> if a > 0.5 then [(b,a)] else []) $ poisonedTree
|
poisonCompounds = foldMap (\(a,b) -> [(b,a) | a > 0.5]) poisonedTree
|
||||||
predators <- generatePredators 0.5 poisonedTree
|
predators <- generatePredators 0.5 poisonedTree
|
||||||
let env = exampleEnvironment (getTreeSize randomCompounds) (generateEnzymeFromTree randomCompounds) (zip predators probs) poisonCompounds
|
let env = exampleEnvironment (getTreeSize randomCompounds) (generateEnzymeFromTree randomCompounds) (zip predators probs) poisonCompounds
|
||||||
printEnvironment env
|
printEnvironment env
|
||||||
writeFile "poison.twopi" $ generateDotFromPoisonTree "poison" 0.5 $ poisonedTree
|
writeFile "poison.twopi" $ generateDotFromPoisonTree "poison" 0.5 poisonedTree
|
||||||
putStr "\ESC[?1049h"
|
putStr "\ESC[?1049h"
|
||||||
loop 200 emptyPlants env
|
loop 200 emptyPlants env
|
||||||
putStrLn "Simulation ended. Press key to exit."
|
putStrLn "Simulation ended. Press key to exit."
|
||||||
@ -143,14 +143,14 @@ generatePredators threshold t = do
|
|||||||
ps <- mapM generatePredators' $ getSubTrees t
|
ps <- mapM generatePredators' $ getSubTrees t
|
||||||
return $ filter ((/= []) . irresistance) $ concat ps -- filter out predators that are resistant to everything because this does not make sense in our model.
|
return $ filter ((/= []) . irresistance) $ concat ps -- filter out predators that are resistant to everything because this does not make sense in our model.
|
||||||
where
|
where
|
||||||
generatePredators' :: (EnzymeTree s (Double, Compound)) -> IO [Predator]
|
generatePredators' :: EnzymeTree s (Double, Compound) -> IO [Predator]
|
||||||
generatePredators' t = do -- not fully resistant to t, but fully resistant to everything in ts
|
generatePredators' t = do -- not fully resistant to t, but fully resistant to everything in ts
|
||||||
let comps = foldMap (\(a,b) -> if a > threshold then [(a,b)] else []) t
|
let comps = foldMap (\(a,b) -> [(a,b) | a > threshold]) t
|
||||||
amount <- randomRIO (0,length comps + 1) :: IO Int
|
amount <- randomRIO (0,length comps + 1) :: IO Int
|
||||||
forM [1..amount] $ \_ -> do
|
forM [1..amount] $ \_ -> do
|
||||||
impact <- randomRIO (0.2,0.7)
|
impact <- randomRIO (0.2,0.7)
|
||||||
rands <- randoms <$> newStdGen
|
rands <- randoms <$> newStdGen
|
||||||
let unresists = foldMap (\((a,b),r) -> if r*2 < a then [b] else []) $ zip comps rands
|
let unresists = foldMap (\((a,b),r) -> [b | r*2 < a]) $ zip comps rands
|
||||||
return $ Predator unresists impact
|
return $ Predator unresists impact
|
||||||
|
|
||||||
printEnvironment :: Environment -> IO ()
|
printEnvironment :: Environment -> IO ()
|
||||||
|
@ -194,7 +194,7 @@ deterPredators cs = do
|
|||||||
appearingPredators = fmap fst . filter (\((_,p),r) -> p > r) $ zip ps ds -- assign one probability to each predator, filter those who appear, throw random data away again.
|
appearingPredators = fmap fst . filter (\((_,p),r) -> p > r) $ zip ps ds -- assign one probability to each predator, filter those who appear, throw random data away again.
|
||||||
-- appearingPredators is now a sublist of ps.
|
-- appearingPredators is now a sublist of ps.
|
||||||
deter :: Predator -> Double
|
deter :: Predator -> Double
|
||||||
-- multiply (toxicity of t with 100% effectiveness at l| for all toxins t | and t not in p's irresistance-list)
|
-- multiply (toxicity of t with 100% effectiveness at l| for all toxins t; and t in p's irresistance-list)
|
||||||
deter p = product [1 - min 1 (cs ! fromEnum t / l) | (t,l) <- ts, t `elem` irresistance p]
|
deter p = product [1 - min 1 (cs ! fromEnum t / l) | (t,l) <- ts, t `elem` irresistance p]
|
||||||
-- multiply (probability of occurence * intensity of destruction / probability to deter predator | for all predators)
|
-- multiply (probability of occurence * intensity of destruction / probability to deter predator | for all predators)
|
||||||
return $ product ([min 1 ((1-prob) * fitnessImpact p / deter p) | (p,prob) <- appearingPredators])
|
return $ product ([min 1 ((1-prob) * fitnessImpact p / deter p) | (p,prob) <- appearingPredators])
|
||||||
|
Loading…
Reference in New Issue
Block a user