home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / TIERRA40.ZIP / BEAGLE / BEAGLE.H < prev    next >
C/C++ Source or Header  |  1992-09-11  |  10KB  |  308 lines

  1. /* beagle.h  4-8-90  header file for the Beagle Explorer */
  2. /*** Beagle Explorer:  Copyright (c) 1990  University of Delaware ***/
  3.  
  4. #ifndef BEAGLE_H
  5. #define BEAGLE_H
  6.  
  7. #include <graphics.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <stdio.h>
  11. #include <ctype.h>
  12. #include <alloc.h>
  13. #include <math.h>
  14. #include <dos.h>                       /* supports the BIOS call */
  15. #include <dir.h>
  16. #include <dw.h>
  17. #include <dwdata.h>
  18. #include <dwmenu.h>
  19. #include "gif/gif_lib.h"
  20.  
  21. #define INSTBITNUM 5
  22. #define INSTNUM 32         /* INSTNUM = 2 ^ INSTBITNUM */
  23. #define PLOIDY 1
  24. #define INST 1 
  25.  
  26. #define Hp     huge  *
  27. #define Fp     far   *
  28. #define Np     near  *
  29. typedef signed char      I8s;   /*  8 bit integer */
  30. typedef unsigned char    I8u;   /*  8 bit integer */
  31. typedef signed int       I16s;  /* 16 bit integer */
  32. typedef unsigned int     I16u;  /* 16 bit integer */
  33. typedef signed long      I32s;  /* 32 bit integer */
  34. typedef unsigned long    I32u;  /* 32 bit integer */
  35.  
  36. #define ONE (I32u) 1
  37.  
  38. #define IsBit(seed, bit) ((((I32u) seed) & (ONE << ((I32u) bit))) ? 1 : 0)
  39.  
  40. #if INSTBITNUM == 5
  41.  
  42. typedef struct {
  43.     unsigned int inst:5;
  44.     unsigned int exec:1;
  45.     unsigned int write:1;
  46.     unsigned int read:1;
  47. } Inst;
  48.  
  49. #endif /* INSTBITNUM == 5 */
  50.  
  51. #if PLOIDY == 1
  52.  
  53. typedef Inst Instruction;
  54.  
  55. #else 
  56.  
  57. typedef Inst Instruction[PLOIDY];
  58.  
  59. #endif /* PLOIDY == 1 */
  60.  
  61. typedef Instruction Hp HpInst;
  62. typedef Instruction Fp FpInst;
  63. typedef Instruction Np NpInst;
  64. typedef Inst Fp FpIns;
  65.  
  66. #if PLOIDY == 1
  67. typedef I8s GenBits;
  68. #else /* PLOIDY > 1 */
  69. typedef I8s GenBits[PLOIDY];
  70. #endif /* PLOIDY > 1 */
  71.  
  72. typedef GenBits Fp FpGenB;
  73.  
  74. typedef struct g_list     GList;
  75. typedef struct g_list Fp  Pgl;
  76.  
  77. typedef struct { /* structure for instruction set definitions */
  78.     I8s op;         /* op code */
  79.     I8s mn[9];      /* assembler mnemonic */
  80. } ArgInstDef;
  81.  
  82. typedef struct {  /* structure for time measured in executed instructions */
  83.     I32s m;     /* count of millions of instructions */
  84.     I32s i;     /* count of instructions */
  85. } Event;
  86.  
  87. typedef struct {
  88.     I32s size;        /* size class (~species) */
  89.     I8s label[4];     /* genotype label */
  90. } Genotype;
  91.  
  92. typedef struct {
  93.     I32s si;           /* size index */
  94.     I16s gi;           /* genotype index */
  95. } GlIndex;
  96.  
  97. typedef struct {  /* structure for metabolic data */
  98.     I32s  inst;      /* count of instructions executed */
  99.     I32s  flags;     /* count of flags (error conditions) set */
  100.     I32s  mov_daught;/* count of number of instructions moved to daughter */
  101.     I8s   BreedTrue; /* 0=not, 1 = this daughter genetically same as parent */
  102. } Metabolism;
  103.  
  104. struct g_list { /* structure for genotype list */
  105.     I32s pop;   /* current number of adults of this genotype in soup */
  106.     Genotype gen;   /* genotype of creature */
  107.     Genotype parent;/* genotype of parent genotype (ancestor) */
  108.     I32u bits;             /* see below */
  109.     Metabolism d1;  /* metabolic data for first daughter */
  110.     Metabolism d2;  /* metabolic data for second daughter */
  111.     Event originI;  /* time of origin, in instruction time */
  112.     I32s originC;      /* time of first origin of genotype, in clock time */
  113.     float MaxPropPop;  /* max. propor. of NumCells reached by this gen. */
  114.     float MaxPropInst; /* max. propor. of SoupSize reached by this gen. */
  115.     Event mpp_time;    /* most recent time of MaxPropPop update */
  116.     I8s ploidy;        /* how many tracks */
  117.     I8s track;         /* which track are we on now ... */
  118.     FpInst genome;     /* pointer to genome itself */
  119.     FpGenB gbits;      /* pointer to genome bit field */
  120.     struct g_list  *b;  /* next (below) in queue */
  121.     struct g_list  *a;  /* previous (above) in queue */
  122. } ;
  123.  
  124. /* definitions of bits:
  125.     bit  0  permanent genotype name, saved in .gen file
  126.     bit  1  swapped out to disk from the rambank, saved in .mem file
  127.     bit  2  EXs = executes own instructions (self)
  128.     bit  3  EXd = executes daughter's instructions
  129.     bit  4  EXo = executes other cell's instructions
  130.     bit  5  EXf = executes instructions in free memory
  131.     bit  6  EXh = own instructions are executed by other creature (host)
  132.     bit  7  TCs = matches template complement of self
  133.     bit  8  TCd = matches template complement of daughter
  134.     bit  9  TCo = matches template complement of other
  135.     bit 10  TCf = matches template complement of free memory
  136.     bit 11  TCh = own template complement is matched by other creature (host)
  137.     bit 12  TPs = uses template pattern of self
  138.     bit 13  TPd = uses template pattern of daughter
  139.     bit 14  TPo = uses template pattern of other
  140.     bit 15  TPf = uses template pattern of free memory
  141.     bit 16  TPh = own template pattern is used by other creature (host)
  142.     bit 17  MFs = moves instruction from self
  143.     bit 18  MFd = moves instruction from daughter
  144.     bit 19  MFo = moves instruction from other cell
  145.     bit 20  MFf = moves instruction from free memory
  146.     bit 21  MFh = own instructions are moved by other creature (host)
  147.     bit 22  MTs = moves instruction to self
  148.     bit 23  MTd = moves instruction to daughter
  149.     bit 24  MTo = moves instruction to other cell
  150.     bit 25  MTf = moves instruction to free memory
  151.     bit 26  MTh = is written on by another creature (host)
  152.     bit 27  MBs = executing other creatures code, moves inst from self
  153.     bit 28  MBd = executing other creatures code, moves inst from daughter
  154.     bit 29  MBo = executing other creatures code, moves inst from other cell
  155.     bit 30  MBf = executing other creatures code, moves inst from free memory
  156.     bit 31  MBh = other creature uses another cpu to move your instructions
  157. */
  158.  
  159. typedef struct {
  160.     I8s   magic[4];
  161.     I32s  g_off;
  162.     I16s  size, n, n_alloc;
  163. } head_t;
  164.  
  165. typedef struct {
  166.     I8s   gen[3];
  167.     I8s   pgen[3];
  168.     I16s  psize;
  169.     I32u  bits;
  170.     I32s  originC;
  171.     I16s  mpp, mpi;
  172.     Event mppT;         /* last time of mpp update */
  173.     I32s  ptr;           /* reserved for future versions */
  174.     Event originI;
  175.     Metabolism d1, d2;
  176.     I8s   pt;           /* ploidy and track */
  177. } indx_t;
  178.  
  179. typedef unsigned int   Uint;
  180. typedef unsigned long  Ulong;
  181.  
  182. struct last_out {
  183.     Ulong  time;
  184.     Ulong  ctime;
  185.     char   bd;
  186.     Uint   size;
  187.     char   label[4];
  188.     } ;
  189.  
  190. struct sbar {  /* coordinates of corners of bar */
  191.     int  left;
  192.     int  top;
  193.     int  right;
  194.     int  bottom;
  195.     } ;
  196.  
  197. struct barst {   /* setup for bar screen */
  198.     double nbr;  /* maximum number of bars */
  199.     float  csz;  /* character size in pixels */
  200.     float  bwd;  /* bar width in pixels */
  201.     float  sbb;  /* space between bars in pixels */
  202.     float  lbd;  /* left border in pixels */
  203.     float  tbd;  /* top border in pixels */
  204.     float  thd;  /* space above first bar in pixels */
  205.     float  nsz;  /* number of characters in size part of left labels */
  206.     float  nge;  /* number of characters in genotype part of left labels */
  207.     float  nch;  /* number of characters in left labels (nsz + nge) */
  208.     float  inb;  /* indent to bar, from numbers */
  209.     float  bas;  /* indent to bar, from left border = lbd + n * csz + inb */
  210.     } ;
  211.  
  212. struct tracest {
  213.     int  csz;  /* character size in pixels */
  214.     int  lbd;  /* left border in pixels */
  215.     int  tbd;  /* top border in pixels */
  216.     int  bti;  /* characters before time */
  217.     int  tim;  /* characters in time */
  218.     } ;
  219.  
  220. struct species {
  221.     int   size;     /* size of this species */
  222.     char  label[4]; /* genotype */
  223.     int   num;      /* current number of individuals */
  224.     int   max;      /* maximum number of individuals */
  225.     int   xpm;      /* maximum x-pixel */
  226.     int   xpo;      /* old x-pixel */
  227.     long  min;      /* maximum number of instructions */
  228.     } ;
  229.  
  230. struct rspecies {
  231.     int   size;
  232.     char  label[4];
  233.     int   begin;    /* number at beginning of period */
  234.     int   num;      /* number at end of period */
  235.     int   min;      /* minimum number during run */
  236.     int   max;      /* maximum number during run */
  237.     } ;
  238.  
  239. struct use_template {
  240.     int  locus;
  241.     int  compl_locus;
  242.     int  size;
  243.     char  inst[7];
  244.     char  template[15];
  245.     } ;
  246.  
  247. struct geneprobe {
  248.     int  fit;       /* fit of probe to genome */
  249.     int  position;  /* position on genome of probe */
  250.     int  diff;      /* size of insertion (+) or deletion (-) */
  251.     int  idpos;     /* position on probe after which ins or del occurs */
  252.     int  start;     /* position to start in case of overlap */
  253.     int  stop;      /* position to stop in case of overlap */
  254.     } ;
  255.  
  256. struct insdel {
  257.     int  first;  /* index to geneprobe array of 1st part of probe */
  258.     int  second; /* index to geneprobe array of 2nd part of probe */
  259.     int  diff;   /* size of insertion (+) or deletion (-) */
  260.     int  idpos;  /* position on probe after which ins or del occurs */
  261.     int  fit;    /* best combined fit */
  262.     } ;
  263.  
  264. struct gene_dat {
  265.     struct tnode  *t;
  266.     long          index;
  267.     } ;
  268.  
  269. struct snode {
  270.     long             max;  /* max pop value upon which tree is sorted */
  271.     long             num;  /* number of genotypes of this max value */
  272.     long             gsiz; /* allocated size of *gd array */
  273.     struct gene_dat  *g;
  274.     struct snode     *l;  /* left sub-tree */
  275.     struct snode     *r;  /* right sub-tree */
  276.     } ;
  277.  
  278. struct pop_dat {
  279.     long  max; /* maximum population of this genotype */
  280.     long  min; /* minimum population of this genotype */
  281.     long  beg; /* beginning population of this genotype */
  282.     long  end; /* current population of this genotype */
  283.     } ;
  284.  
  285. struct tnode {
  286.     long            size;  /* genome size */
  287.     struct pop_dat  sd; /* pop_dat for this size class */
  288.     int             gsize; /* allocated size of *g array */
  289.     struct pop_dat  *g; /* array of pop_dat structures */
  290.     struct tnode    *l;  /* left sub-tree */
  291.     struct tnode    *r;  /* right sub-tree */
  292.     } ;
  293.  
  294. struct xyrange { float xn; float xx; float yn; float yx; int n; int f; };
  295. struct point   { float x; float y; };
  296. struct polar    { float r;    float th; } ;
  297. struct rect    { float dx;    float dy; } ;
  298. struct gd { double d;    int bad; };
  299. struct gf { float f;    int bad; };
  300. struct gi { int i;    int bad; };
  301. struct gl { long l;    int bad; };
  302. struct gc { char c;    int bad; };
  303. struct gs { char s[99];    int bad; };
  304.  
  305. #include "protob.h"
  306.  
  307. #endif /* BEAGLE_H */
  308.