Another Galaxy utility From: dagibbs@quantum.on.ca (David Gibbs) Date: Sun, 22 Nov 1992 05:12:37 +0000 Somebody else has probably already written a program to do this but I havn't seen it, so... This is a short program that will calculate the mass of ship and the amount of CAP that a planet can produce in one turn given that planets Population, Industry and Resources. A fourth parameter can also be specified, giving the stockpile of resources on the planet and this will be factored in. If not specified it is assumed to be zero. use: produce Population Industry Resource [Stockpile] eg: produce 1000 1000 10 produce 564.3 345.4 .56 15.3 produce 343 24.43 1.1 0 Hope somebody finds this useful, I have. -David Gibbs (dagibbs@quantum.qnx.com) ---------cut here--------------- #include <stdio.h> #include <stdlib.h> #include <math.h> /* takes 3 or 4 floats as arguments, assumes they are: */ /* Population, Industry, Resources, [Stockpile] */ /* and gives: ship mass produceable, capital produceable */ void main( int argc, char **argv ) { float p, i, r, s; float ei, esm, esc; float m, c; if ( (argc < 4) || (argc > 5) ) { printf("takes three or four floats: Pop Ind Res [Stockpile] \n"); exit(-1); } p = atof( argv[1] ); i = atof( argv[2] ); r = atof( argv[3] ); if (argc == 5) s = atof( argv[4] ); else s = 0; ei = i + (p-i)/4.0; esm = (ei < s*10.0) ? ei : s*10.0; esc = (ei < s*5.0) ? ei : s*5.0; m = esm/10.0 + (ei - esm) / (10.0 + 1.0/r ); c = esc/5.0 + (ei -esc) / (5.0 + 1.0/r ); printf("production is: %5.2f mass of ships or %6.2f Capital\n", m,c); } Referenced By Up