예제 #1
0
void yarrAIWanderer :: think()
{
	// avoiding attacks is more important than being a vagrant
	avoid_bullets();
	wander();

	// look for something to kill
	spaceShip* enemy = getclosest();

	if( enemy != NULL )
	{
		attack(enemy);
	}
}
예제 #2
0
void yarrAIPsycho :: think()
{
	// save yourself!
	avoid_bullets();

	// look for something to kill
	//getvisible();
	//spaceShip* enemy = seen.back();
	spaceShip* enemy = getclosest();

	if( enemy != NULL )
	{
		pursue(enemy);
		attack(enemy);
	}
	else
		wander();	// or just wander around if nothing's around
}
예제 #3
0
extern int
refine_first(void)			/* initial refinement pass */
{
	int	*esamp = (int *)zprev;	/* OK to reuse */
	int	hl_erri = errori(HL_ERR);
	int	nextra = 0;
	int	x, y, xp, yp;
	int	neigh;
	register int	n, np;

	if (sizeof(int) < sizeof(*zprev))
		error(CONSISTENCY, "code error in refine_first");
	if (!silent) {
		printf("\tFirst refinement pass...");
		fflush(stdout);
	}
	memset((void *)esamp, '\0', sizeof(int)*hres*vres);
	/*
	 * In our initial pass, we look for lower error pixels from
	 * the same objects in the previous frame, and copy them here.
	 */
	for (y = vres; y--; )
	    for (x = hres; x--; ) {
		n = fndx(x, y);
		if (obuffer[n] == OVOID)
			continue;
		if (xmbuffer[n] == MO_UNK)
			continue;
		xp = x + xmbuffer[n];
		if ((xp < 0) | (xp >= hres))
			continue;
		yp = y + ymbuffer[n];
		if ((yp < 0) | (yp >= vres))
			continue;
		np = fndx(xp, yp);
					/* make sure we hit same object */
		if (oprev[np] != obuffer[n])
			continue;
					/* is previous frame error lower? */
		if (aprev[np] < AMIN + ATIDIFF)
			continue;
		if (aprev[np] <= abuffer[n] + ATIDIFF)
			continue;
					/* shadow & highlight detection */
		if (abuffer[n] > hl_erri &&
				getclosest(&neigh, 1, x, y) &&
				bigdiff(cbuffer[neigh], cprev[np],
					HL_ERR*(.9+.2*frandom())))
			continue;
		abuffer[n] = aprev[np] - ATIDIFF;
		copycolor(cbuffer[n], cprev[np]);
		esamp[n] = 1;		/* record extrapolated sample */
		nextra++;
	    }
	for (n = hres*vres; n--; )	/* update sample counts */
		if (esamp[n])
			sbuffer[n] = 1;
	if (!silent)
		printf("extrapolated %d pixels\n", nextra);
	return(1);
}