[net.games.emp] coastwatch

dudek (08/05/82)

  We are running the empire export of Apr 17 1982 and never seem
to be able to get a reasonable response from "coastwatch."  At best,
it says the range is 0.5 (for a 100% efficient sector - non-radar -
with some technology [empfix shows the sector has nv=5 too]). Does
coastwatch EVER work?  If somebody out there has a
working version, we'd love to hear about it. (Maybe you
could send the coas.o uuencoded - does that require psl's
permission?)

  By the way, we discovered that by patching enli.o with adb, we
could make enlistment more BTU costly and avoid the "steamroller
effect" in wars.  This seems to work rather well, and is relatively
realistic. After all, the ought to be a lot of paperwork involved in
starting and army!
  (By the ways, ours is a 4.1BSD version)

       Greg Dudek

jj (08/05/82)

	My sectors all have a range of 1.1.  They have never seen a single
ship anywhere in the world.  Not ever! (My radar saw ONE, once.)
My regular sectors have never seen anything when doing a coastwatch, even
when my own fleet is parked in the adjacent sector.  My radar stations
do show ships, but I can never identify them.  C'est morte?

	As far as raising the cost for elistment, I am opposed to it.  It
only puts the defending country at a greater disadvantage, since it cannot
enlist defensive forces.  It doesn't help the steamroller effect.

muller (11/25/82)

The following is the current version of coaswatch being used in
our game. Place it in EMP/coas.c.
then do:
cc -c coas.c
ar ru empcom.a coas.o
ranlib empcom.a
make BIN/emp1 

If you have problems please mail me.
Keith Muller
EECS Dept
UCSD

ucbvax!sdcsvax!muller
sdcsvax!muller@nosc

------------------coas.c----------------------
#include <stdio.h>
coas() 
{
#define D_MCHRSTR
#define D_SHIPTYP
#define D_SECTDES
#define D_SCTSTR
#define D_NATSTR
#define D_SHPSTR
#define D_FILES
#define D_NATSTAT
#include "empdef.h"
extern short w_xsize;
extern short w_ysize;

register int k,j;
int w_xsize_2, w_ysize_2;
int x,y,shx,shy;
float distsh;
int mink, minj, maxk, maxj;
int abj, abk;
float disvis;
float idvis, seevis;
float secteffic;
int copy;
int seen;
int shnum;
int simcon;
FILE *fout;

w_xsize_2 = w_xsize/2;
w_ysize_2 = w_ysize/2;
copy = 0;
for (j=0;j<78;j++)
    if (combuf[j] == '>'){
	if (combuf[j+1] == '>')
	    j++;
	if((fout=fopen(&combuf[j+1],"a")) == NULL)
	    break;
	fflush(fout);
	copy = 1;
	break;
    }

if ((nat.nat_stat == GOD) && (argp[1][0] != '0'))
   simcon = atoi(argp[1]);
else
   simcon = lgn_num;
x=nat.nat_xcap;
y=nat.nat_ycap;

/*  go to top of ship file */
lseek( shipf, 0L, 0 );
shnum = -1;

printf("\n  - = [ Coastwatch report for %s ] = -\n", nat.nat_cnam);
printf("  Ship     Sector   Nat    Ship Type\n");
if (copy){
    fprintf(fout,"\n  - = [ Coastwatch report for %s ] = -\n", nat.nat_cnam);
    fprintf(fout,"  Ship     Sector   Nat    Ship Type\n");
}
while (1) {
    if (read(shipf, &ship, sizeof(ship)) <= 0) break;
    shnum++;
    if (ship.shp_own == simcon) continue;
    disvis = mchr[ship.shp_type].m_visib/10.0;
    if (ship.shp_type == SHP_S)
       maxk = 2;
    else
       maxk = (disvis * 2.0);
    maxj = 2*maxk;
    minj = (-maxj);
    mink = (-maxk);
    seen = 0;
    for (j = minj; j <=maxj; j++){
        for(k= mink; k<=maxk; k++){
	    abj = abs(j);
	    abk = abs(k);
	    if (((abj+abk) % 2) != 0) continue;
	    if (getsect(j+ship.shp_x-x,k+ship.shp_y-y,0) == -1)
	        printf("Watch error: plse report: j=%d, k=%d.\n",j,k);
	    if ((sect.sct_own != simcon) || (sect.sct_type == SCT_WATER))
	        continue;
	    secteffic = sect.sct_effic/100.0;
	    if (abj > abk)
	        distsh = abk + ((abj - abk)/2);
	    else
	        distsh = abk;
	    switch(sect.sct_type){
		case SCT_RADAR:
		    if (ship.shp_type == SHP_S){
			idvis = 0.0;
			seevis = 2.1;
		    }else{
			seevis = disvis * 2.0;
			idvis = seevis/2.0;
		    }
		    break;
		case SCT_MOUNT:
		case SCT_FORTR:
		    if (ship.shp_type == SHP_S){
			idvis = 0.0;
			seevis = 2.1;
		    }else{
			seevis = disvis * 1.6;
			idvis = seevis/2.0;
		    }
		    break;
		case SCT_HARBR:
		    if (ship.shp_type == SHP_S){
			idvis = 1.1;
			seevis = 2.1;
		    }else{
			seevis = disvis * 1.4;
			idvis = seevis/2.0;
		    }
		    break;
		case SCT_BSPAN:
		    if (ship.shp_type == SHP_S){
			idvis = 0.0;
			seevis = 1.1;
		    }else{
			seevis = disvis * 1.4;
			idvis = seevis/2.0;
		    }
		    break;
		default:
		    seevis = disvis;
		    idvis = seevis/2.0;
	    }
	    idvis = idvis * secteffic;
	    seevis = seevis * secteffic;
	    if (distsh <= idvis){
		k = maxk + 1;
		j = maxj + 1;
		seen = 2;
	    }else if (distsh <= seevis){
		seen = 1;
	    }
	}
    }
    if (seen == 0) continue;
    shx=(ship.shp_x-nat.nat_xcap);
    shy=(ship.shp_y-nat.nat_ycap);
    if (shx >= w_xsize_2 )
	shx=shx-w_xsize;
    if (shy >= w_ysize_2 )
	shy=shy-w_ysize;
    if (-shx > w_xsize_2)
	shx = shx + w_xsize;
    if (-shy > w_ysize_2)
	shy = shy + w_ysize;
    if (seen == 2){
	printf("  %-6d  %3d,%-3d    ",shnum,shx,shy);
	printf("%-2d    %s",ship.shp_own,mchr[ship.shp_type].m_name);
	if (ship.shp_own == 0)
	    printf(" wreckage");
	printf("\n");
	if (copy){
	    fprintf(fout,"  %-6d  %3d,%-3d    ",shnum,shx,shy);
	    fprintf(fout,"%-2d    %s",ship.shp_own,mchr[ship.shp_type].m_name);
	    if (ship.shp_own == 0)
	        fprintf(fout," wreckage");
	        fprintf(fout,"\n");
	}
    }else{
	printf("  ?       %3d,%-3d    ?     %s\n",shx,shy,mchr[ship.shp_type].m_name);
	if (copy)
	    fprintf(fout,"  ?       %3d,%-3d    ?     %s\n",shx,shy,mchr[ship.shp_type].m_name);
    }
    fflush(stdout);
    if (copy)
	fflush(fout);
}
if (copy)
    fclose(fout);
}