Galactic Bloodshed
racegen.h
Go to the documentation of this file.
1 // Copyright 2014 The Galactic Bloodshed Authors. All rights reserved.
2 // Use of this source code is governed by a license that can be
3 // found in the COPYING file.
4 
5 #ifndef RACEGEN_H
6 #define RACEGEN_H
7 
8 #include <cstdio>
9 
10 #define GBVERSION "1.7.3"
11 #ifdef VERSION
12 #undef VERSION
13 #endif
14 #define VERSION ""
15 
16 /**************
17  * This #define is used to compile the code in this program needed for the
18  * enroll program. Unless you are a game-god, you will never need to use it.
19  */
20 #ifdef ENROLL
21 #define IS_PLAYER 0
22 #else
23 #define IS_PLAYER 1
24 #endif
25 
26 /**************
27  * System dependencies. These will likely not change much.
28  */
29 #define MAILER "/usr/lib/sendmail"
30 #define SAVETO "racegen.save"
31 #define TMP "/tmp/racegen.save"
32 
33 /**************
34  * Other stuff.
35  */
36 #define START_RECORD_STRING "<************"
37 #define END_RECORD_STRING "************>"
38 
39 int Dialogue(const char *, ...);
40 
41 /**************
42  * Attributes, attribute names, and parameters for attribute costs.
43  */
44 #define FIRST_ATTRIBUTE 0
45 #define ADVENT FIRST_ATTRIBUTE
46 #define ABSORB (ADVENT + 1)
47 #define BIRTH (ABSORB + 1)
48 #define COL_IQ (BIRTH + 1)
49 #define FERT (COL_IQ + 1)
50 #define A_IQ (FERT + 1)
51 #define FIGHT (A_IQ + 1)
52 #define PODS (FIGHT + 1)
53 #define MASS (PODS + 1)
54 #define SEXES (MASS + 1)
55 #define METAB (SEXES + 1)
56 #define LAST_ATTRIBUTE (METAB)
57 #define N_ATTRIBUTES (LAST_ATTRIBUTE + 1)
58 
59 typedef struct {
60  int number;
61  char print_name[16];
63  double minimum, init, maximum;
64  double cov[N_ATTRIBUTES];
66 } attribute;
67 
68 #define ATTR_RANGE(a) (attr[a].maximum - attr[a].minimum)
69 
70 /* The formula for determining the price of any particular attribute
71  * is as follows:
72  * exp( (e_fudge * (attribute - e_hinge) )) * e_factor
73  * + attribute * l_factor + l_fudge
74  * This allows great flexibility in generating functions for
75  * attribute costs. */
76 
77 /* Increasing an attribute's e_factor will raise the cost of the attribute
78  * everywhere (since exp(x)>0 forall x); however, it raises the cost quite
79  * disproportionately. If a correponding decrease in l_fudge is made, this
80  * will have little effect on the cost to buy an attribute below the hinge
81  * point, but will have a strong effect on the cost above the hinge. */
82 
83 /* Increasing an attribute's e_fudge will have the effect of driving the cost
84  * of attributes below the hinge down (slightly), and driving the cost of
85  * attributes above the hinge significantly higher. */
86 
87 /* An attribute's e_hinge is the point is that the exponential "takes off";
88  * that is, the exponential will have a small effect on the cost for an
89  * attribute below this value, but will have a much larger impact for
90  * those over this value. */
91 
92 /* An attribute's l_factor (linear factor) allows you to increase the
93  * cost over the whole range of the attribute, in a smoothly increasing (or
94  * decreasing) way. */
95 
96 /* The l_fudge value is a constant adjustment to the cost of an attribute.
97  * It is used to get the init value of an attribute to cost zero.
98  * It is set automatically at startup, so don't bother to mess with it. */
99 
100 /**************
101  * Home planet types, names, and costs.
102  */
103 #define FIRST_HOME_PLANET_TYPE 0
104 #define H_EARTH FIRST_HOME_PLANET_TYPE
105 #define H_FOREST (H_EARTH + 1)
106 #define H_DESERT (H_FOREST + 1)
107 #define H_WATER (H_DESERT + 1)
108 #define H_AIRLESS (H_WATER + 1)
109 #define H_ICEBALL (H_AIRLESS + 1)
110 #define H_JOVIAN (H_ICEBALL + 1)
111 #define LAST_HOME_PLANET_TYPE H_JOVIAN
112 #define N_HOME_PLANET_TYPES (LAST_HOME_PLANET_TYPE + 1)
113 
114 extern const char *planet_print_name[N_HOME_PLANET_TYPES];
115 extern const int planet_cost[N_HOME_PLANET_TYPES];
116 
117 /**************
118  * Race types, names, and costs
119  */
120 #define FIRST_RACE_TYPE 0
121 #define R_NORMAL FIRST_RACE_TYPE
122 #define R_METAMORPH (R_NORMAL + 1)
123 #define LAST_RACE_TYPE R_METAMORPH
124 #define N_RACE_TYPES (LAST_RACE_TYPE + 1)
125 
126 extern const char *race_print_name[N_RACE_TYPES];
127 extern const int race_cost[N_RACE_TYPES];
128 
129 /**************
130  * Type of privileges this race will have:
131  */
132 #define FIRST_PRIV_TYPE 0
133 #define P_GOD (FIRST_PRIV_TYPE)
134 #define P_GUEST (P_GOD + 1)
135 #define P_NORMAL (P_GUEST + 1)
136 #define LAST_PRIV_TYPE (P_NORMAL)
137 #define N_PRIV_TYPES (LAST_PRIV_TYPE + 1)
138 
139 extern const char *priv_print_name[N_PRIV_TYPES];
140 
141 /**************
142  * Sector types and names. Sector costs are hardwired in currently.
143  */
144 #define FIRST_SECTOR_TYPE 0
145 #define S_WATER FIRST_SECTOR_TYPE
146 #define S_LAND (S_WATER + 1)
147 #define S_MOUNTAIN (S_LAND + 1)
148 #define S_GAS (S_MOUNTAIN + 1)
149 #define S_ICE (S_GAS + 1)
150 #define S_FOREST (S_ICE + 1)
151 #define S_DESERT (S_FOREST + 1)
152 #define S_PLATED (S_DESERT + 1)
153 #define LAST_SECTOR_TYPE S_PLATED
154 #define N_SECTOR_TYPES (LAST_SECTOR_TYPE + 1)
155 
156 extern const char *sector_print_name[N_SECTOR_TYPES];
157 extern const int n_sector_types_cost[N_SECTOR_TYPES];
158 
159 /*
160  * The covariance between two sectors is:
161  * actual_cost(a1) = base_cost(a1) *
162  * (1 + cov[a1][a2] * (a2 - cov[a1][a2].fudge)) ;
163  */
164 extern const double compat_cov[N_SECTOR_TYPES][N_SECTOR_TYPES];
166 
167 #define STATUS_ENROLLED -2
168 #define STATUS_UNENROLLABLE -1
169 #define STATUS_UNBALANCED 0
170 #define STATUS_BALANCED 1
171 
172 /**************
173  * Structure for holding information about a race.
174  */
175 struct x {
176  char address[64]; /* Person who this is from, or going to. */
177  char filename[64];
178  char name[64];
179  char password[64];
180  char rejection[256]; /* Error if this is non-"" */
181  char status;
182 
189 };
190 
191 /**************
192  * Global variables for this program.
193  */
194 extern struct x race_info, cost_info, last;
195 
196 extern int npoints;
197 extern int last_npoints;
198 extern int altered; /* 1 iff race has been altered since last saved */
199 extern int changed; /* 1 iff race has been changed since last printed */
200 extern int please_quit; /* 1 iff you want to exit ASAP. */
201 
202 int critique_to_file(FILE *f, int rigorous_checking, int is_player_race);
203 void print_to_file(FILE *f, int verbose);
204 int load_from_file(FILE *g);
205 int cost_of_race();
206 void modify_print_loop(int level);
207 
208 #endif // RACEGEN_H
#define ADVENT
Definition: racegen.h:45
#define H_JOVIAN
Definition: racegen.h:110
int altered
Definition: racegen.cc:323
Definition: racegen.h:175
#define MASS
Definition: racegen.h:53
int critique_to_file(FILE *f, int rigorous_checking, int is_player_race)
Definition: racegen.cc:440
int please_quit
Definition: racegen.cc:325
#define P_GUEST
Definition: racegen.h:134
int priv_type
Definition: racegen.h:185
double cov[N_ATTRIBUTES]
Definition: racegen.h:64
#define FIRST_PRIV_TYPE
Definition: racegen.h:132
#define LAST_ATTRIBUTE
Definition: racegen.h:56
#define S_ICE
Definition: racegen.h:149
double compat[N_SECTOR_TYPES]
Definition: racegen.h:188
#define LAST_RACE_TYPE
Definition: racegen.h:123
#define S_PLATED
Definition: racegen.h:152
struct x race_info cost_info last
Definition: racegen.cc:319
const double compat_cov[N_SECTOR_TYPES][N_SECTOR_TYPES]
Definition: racegen.cc:264
#define N_SECTOR_TYPES
Definition: racegen.h:154
const int planet_cost[N_HOME_PLANET_TYPES]
Definition: racegen.cc:252
double attr[N_ATTRIBUTES]
Definition: racegen.h:183
#define PODS
Definition: racegen.h:52
#define P_NORMAL
Definition: racegen.h:135
const char * priv_print_name[N_PRIV_TYPES]
Definition: racegen.cc:257
#define H_EARTH
Definition: racegen.h:104
int cost_of_race()
Definition: racegen.cc:332
#define N_RACE_TYPES
Definition: racegen.h:124
double e_fudge
Definition: racegen.h:62
#define H_AIRLESS
Definition: racegen.h:108
int load_from_file(FILE *g)
Definition: racegen.cc:843
char status
Definition: racegen.h:181
char address[64]
Definition: racegen.h:176
const int race_cost[N_RACE_TYPES]
Definition: racegen.cc:255
#define FIRST_RACE_TYPE
Definition: racegen.h:120
#define FIRST_SECTOR_TYPE
Definition: racegen.h:144
#define FIRST_HOME_PLANET_TYPE
Definition: racegen.h:103
int race_type
Definition: racegen.h:184
#define S_LAND
Definition: racegen.h:146
char print_name[16]
Definition: racegen.h:61
double init
Definition: racegen.h:63
#define COL_IQ
Definition: racegen.h:48
void print_to_file(FILE *f, int verbose)
Definition: racegen.cc:1061
double minimum
Definition: racegen.h:63
#define A_IQ
Definition: racegen.h:50
int number
Definition: racegen.h:60
int last_npoints
Definition: racegen.cc:322
#define N_PRIV_TYPES
Definition: racegen.h:137
const char * planet_print_name[N_HOME_PLANET_TYPES]
Definition: racegen.cc:250
#define LAST_PRIV_TYPE
Definition: racegen.h:136
#define SEXES
Definition: racegen.h:54
double e_factor
Definition: racegen.h:62
#define R_NORMAL
Definition: racegen.h:121
int Dialogue(const char *,...)
Definition: racegen.cc:1213
const double planet_compat_cov[N_HOME_PLANET_TYPES][N_SECTOR_TYPES]
Definition: racegen.cc:299
#define FIRST_ATTRIBUTE
Definition: racegen.h:44
#define S_DESERT
Definition: racegen.h:151
#define LAST_SECTOR_TYPE
Definition: racegen.h:153
#define N_ATTRIBUTES
Definition: racegen.h:57
#define S_GAS
Definition: racegen.h:148
#define P_GOD
Definition: racegen.h:133
int is_integral
Definition: racegen.h:65
int changed
Definition: racegen.cc:324
const char * sector_print_name[N_SECTOR_TYPES]
Definition: racegen.cc:259
char password[64]
Definition: racegen.h:179
double l_fudge
Definition: racegen.h:62
int home_planet_type
Definition: racegen.h:186
double l_factor
Definition: racegen.h:62
#define N_HOME_PLANET_TYPES
Definition: racegen.h:112
#define ABSORB
Definition: racegen.h:46
int n_sector_types
Definition: racegen.h:187
int npoints
Definition: racegen.cc:321
#define METAB
Definition: racegen.h:55
void modify_print_loop(int level)
Definition: racegen.cc:1329
#define R_METAMORPH
Definition: racegen.h:122
char rejection[256]
Definition: racegen.h:180
char name[64]
Definition: racegen.h:178
#define FERT
Definition: racegen.h:49
double e_hinge
Definition: racegen.h:62
#define S_MOUNTAIN
Definition: racegen.h:147
#define H_ICEBALL
Definition: racegen.h:109
#define H_DESERT
Definition: racegen.h:106
#define LAST_HOME_PLANET_TYPE
Definition: racegen.h:111
#define BIRTH
Definition: racegen.h:47
#define H_FOREST
Definition: racegen.h:105
const int n_sector_types_cost[N_SECTOR_TYPES]
double maximum
Definition: racegen.h:63
#define FIGHT
Definition: racegen.h:51
#define H_WATER
Definition: racegen.h:107
char filename[64]
Definition: racegen.h:177
#define S_WATER
Definition: racegen.h:145
#define S_FOREST
Definition: racegen.h:150
const char * race_print_name[N_RACE_TYPES]
Definition: racegen.cc:254