This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rescale maxX maxY a =floor (fromIntegral a * ((fromIntegral maxY ::Float) / (fromIntegral maxX ::Float)))
--rescale_ :: Int -> Float -> Int -> Float
rescale_ maxX maxY a =(fromIntegral a)*(maxY /(fromIntegral maxX))
rescale_ maxX maxY a =fromIntegral a * maxY /fromIntegral maxX
start::Int->People
start a =let off = a *3inV.fromList $(take (fromIntegral off) $repeat(Person1 male farmer endorphi 7010 (0,0) (0,0))) ++ [Person0 g prof cult age (toID i) (if i >= a then0else1) (if i >= a then (toID (1+i-a), toID (1+i-a)) else (ID0,ID0)) (mapRange `div`2, mapRange `div`2) | (i,(g,(prof,cult))) <-zip [off+1..off+1+a*2] $zip (cycle [male, female]) $zip (infinitly allProfessions) (infinitly allCultures), let age =fromIntegral$ f (i-off) a]
start a =let off = a *3inV.fromList $replicate (fromIntegral off) (Person1 male farmer endorphi 7010 (0,0) (0,0)) ++ [Person0 g prof cult age (toID i) (if i >= a then0else1) (if i >= a then (toID (1+i-a), toID (1+i-a)) else (ID0,ID0)) (mapRange `div`2, mapRange `div`2) | (i,(g,(prof,cult))) <-zip [off+1..off+1+a*2] $zip (cycle [male, female]) $zip (infinitly allProfessions) (infinitly allCultures), let age =fromIntegral$ f (i-off) a]
where
f::Int->Int->Int
f i max
| i >=floor ((fromIntegralmax::Float) *0.75) =0
| i >=floor ((fromIntegralmax::Float) *0.30) =20
| i >=floor ((fromIntegralmax::Float) *0.10) =40
|otherwise=60
infinitly x =cycle$concat$zipWith (\a b ->a : b :[]) x x
infinitly x =cycle$concat$zipWith (\a b ->[a, b]) x x
scaleConcentrationOfPeople x =if x <-50000then infinity else(0-x)**1.2-- ( (-) 0).((**) 1.5)
scaleConcentrationOfPeople x =if x <-50000then infinity elsenegate x**1.2-- ( (-) 0).((**) 1.5)
scaleCulturalMap::Float->Float
scaleCulturalMap = (*1)
staticTerrainMap::VectorFloat
staticTerrainMap =V.fromList $[base ! ((rescale mapRange 50 x)+(rescale mapRange 50 y)*50) | x <- [0..mapRange-1], y <- [0..mapRange-1]]
where base =V.fromList $map (\x ->if x ==1then-10000else x) $map(\x ->if x ==2then infinity else x)$concat--(V.fromList $ take (mapRange*mapRange) $ repeat 0.0) V.// mountain
staticTerrainMap =V.fromList [base ! (rescale mapRange 50 x + rescale mapRange 50 y *50) | x <- [0..mapRange-1], y <- [0..mapRange-1]]
where base =V.fromList $map ((\x ->if x ==1then-10000else x) .(\x ->if x ==2then infinity else x)) $concat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
populationSquares = gridCat $map ((((sq biggestPopulation ::DV2Double) # phantom) `atop`) . sq . (\x ->if x > biggestPopulation then biggestPopulation else x) .fromIntegral) $VB.toList population
example::DiagramB
example = vsep biggestPopulation $[sq biggestPopulation ||| f (show$floor biggestPopulation), sq (biggestPopulation * (3/4)), sq (biggestPopulation /2), sq (biggestPopulation /4), hsep biggestPopulation [sq 1, f "1"]]
example = vsep biggestPopulation [sq biggestPopulation ||| f (show$floor biggestPopulation), sq (biggestPopulation * (3/4)), sq (biggestPopulation /2), sq (biggestPopulation /4), hsep biggestPopulation [sq 1, f "1"]]
where f s = scale biggestPopulation $ text s <> rect 31# lw n
sq s = square s # fc red # lwG 0
@@ -223,39 +222,36 @@ genPopulationMap n1 n2 = let range = [read n1..read n2] in mapM_ (\(index, name)
| x <10=50
| x <50=50+ x *3
|otherwise=200
let toText :: ((Int32, Int32), Int) ->String; toText ((x, y), a) =(show x)++""++(show y)++""++(show$255- f a) ++""++"0"++""++"0"++""++(show$if a ==0then0else255) ++"\n"
t <-return$concat$maptoText $concat$ positions
let toText :: ((Int32, Int32), Int) ->String; toText ((x, y), a) =show x ++""++show y ++""++show(255- f a) ++""++"0"++""++"0"++""++show(if a ==0then0else255) ++"\n"
let t =concatMaptoText $concat positions
-- forkIO $ do
h <- openBinaryFile name WriteMode
hPutStrLn h t
putStrLn$"Written: "++ name
hClose h)
$zip range $map (\i ->"data/populationMap"++ (show i) ++".txt") range
writeFile name t
putStrLn$"Written: "++ name)
$zip range $map (\i ->"data/populationMap"++show i ++".txt") range
let!positions = [[((x,y), [f p c | c <- allCultures]) | x <- [0..mapRange], let p =V.filter ((\(x',y') -> x == x' && y == y').position) g'] | y <- [0..mapRange]]
-- hPutStrLn h $ concat $ map (foldr (\((x,y),r,g,b) list -> (show x) ++ " " ++ (show y) ++ " " ++ (show r) ++ " " ++ (show g) ++ " " ++ (show b) ++ " " ++ (show $ if r + g + b == 0 then 0 else 255) ++ "\n" ++ list) "") positions))
t <-return$concat$map(foldr (\((x,y),c) list ->(show x)++""++(show y)++""++(setColour c)++"\n"++ list) "") positions
let t =concatMap(foldr (\((x,y),c) list ->show x ++""++show y ++""++ setColour c ++"\n"++ list) "") positions
-- forkIO $ do
h <- openBinaryFile name WriteMode
hPutStrLn h t
putStrLn$"Written: "++ name
hClose h)
$zip range $map (\i ->"data/cultureMap"++ (show i) ++".txt") range
writeFile name t
putStrLn$"Written: "++ name)
$zip range $map (\i ->"data/cultureMap"++show i ++".txt") range
|otherwise=(V.foldr (\x list -> list + ((*)100$professionValue $ profession x)) 0 l)`div`(V.length l)
|otherwise=V.foldr (\x list -> list +(*)100(professionValue $ profession x)) 0 l `div`V.length l
let (g,_,_) = createGeneration index
let!g' =V.filter alive g
let!positions = [[((x,y), f p) | x <- [0..mapRange], let p =V.filter ((\(x',y') -> x == x' && y == y').position) g'] | y <- [0..mapRange]]
t <-return$concat$map(foldr (\((x,y),a) list ->(show x)++""++(show y)++""++(show a)++""++"0"++""++"0"++""++(show$if a ==0then0else255) ++"\n"++ list) "") positions
let t =concatMap(foldr (\((x,y),a) list ->show x ++""++show y ++""++show a ++""++"0"++""++"0"++""++show(if a ==0then0else255) ++"\n"++ list) "") positions
-- forkIO $ do
h <- openBinaryFile name WriteMode
hPutStrLn h t
putStrLn$"Written: "++ name
hClose h)
$zip range $map (\i ->"data/professionMap"++ (show i) ++".txt") range
writeFile name t
putStrLn$"Written: "++ name)
$zip range $map (\i ->"data/professionMap"++show i ++".txt") range
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters