]> pd.if.org Git - afpopgen/blob - sim/africa.h
add options hash to json output
[afpopgen] / sim / africa.h
1 #include <stdint.h>
2
3 #ifndef LOCI
4 #define LOCI 1
5 #endif
6
7 struct climate {
8         char code[8];
9         char name[32];
10         int basecap;
11         int cap; /* for this model */
12         unsigned char rgb[3];
13 };
14
15 struct climaterange {
16         int hex;
17         char code[8];
18         char era[16];
19         int variance;
20         int start;
21         int end;
22 };
23
24 extern struct climaterange altclimates[];
25
26 struct afrhex;
27
28 struct climate *climateyear(struct afrhex *hex, int year);
29
30 struct maphex {
31         int64_t hex;
32         char    climate[8];
33         int     nadj;
34         int64_t adjacent[18]; /* though we can calculate adjacents */
35         struct afrhex *adjhex[18]; /* direct pointers */
36         struct maphex *next;
37 };
38 extern struct maphex maphexes[];
39
40 struct afrhex {
41         int64_t hex;
42         unsigned int freq[2]; /* allele frequency count */
43         struct climate *climate;
44
45         /* migrants allele */
46         unsigned int outmigrate[2];
47         unsigned int inmigrate[2];
48
49         /* migration topology */
50         struct maphex *map;
51
52         /* some computed data */
53         int pop, migrants; /* total pop, number of emmigrants, dest attr */
54         int attract; /* how attractive is this as a destination */
55
56         struct afrhex *next;
57 };
58
59 struct climate *find_climate(char *code);
60 struct climate *climateyear(struct afrhex *hex, int year);
61 void nextgen(struct afrhex *hexlist, int year, unsigned int climate);
62 void climate_init(double width, double capfactor);
63 struct afrhex *map_init(struct maphex *maphexes, double width, double divisor);
64 uint64_t total_pop(struct afrhex *map);
65
66 struct afrhex *find_hex(struct afrhex *map, int64_t hex);
67 struct afrhex *search_hex(struct afrhex *map, int64_t hex);