DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T c

⟦1fb4b350b⟧ TextFile

    Length: 1265 (0x4f1)
    Types: TextFile
    Names: »chose.c«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/General/Gomoku/chose.c« 

TextFile

# include "def.h"

/* Chose what move shall be done depending on threats and points */
chose(who, dox, doy) char who; int *dox, *doy;{
	short int maxpts, movbuf[2][BZIZE], movp, i, good, whomax;
	register int x, y, n;

	if(who == 'x')
		who = 1;
	else
		who = 0;

	for(x = 0; x < 2; x++){
		thtmax[x] = 0;
		for(y = 4; y > 0; y--){
			if(thtcnt[x][y]){
				thtmax[x] = y;
				break;
			}
		}
	}

	good = movp = 0;
	maxpts = -1;
	if(thtmax[who] >= thtmax[!who])
		whomax = who;
	else{
		whomax = !who;
		if(thtmax[!who] == 1)
			whomax = who;
	}
	for(x = 0; x < XZIZE; x++)
		for(y = 0; y < YZIZE; y++)
			if((board[x][y] == ' ') &&
			   (threat[whomax][x][y] == thtmax[whomax])){
				good++;
				if((threat[whomax][x][y]) || (point[x][y] != 0)){
					movbuf[0][movp] = x;
					movbuf[1][movp++] = y;
					if(point[x][y] > maxpts)
						maxpts = point[x][y];
				}
			}
	n = 1;
	for(i = 0; i < movp; i++){
		if(!maxpts || (point[movbuf[0][i]][movbuf[1][i]] * 11) / (10 * maxpts)){
			if(!((rand()>>4) % n++)){
				*dox = movbuf[0][i];
				*doy = movbuf[1][i];
			}
		}
	}
	if(!movp && good)
		for(x = 0; x < XZIZE; x++)
			for(y = 0; y < YZIZE; y++)
				if( (board[x][y] == ' ') &&
				   !((rand()>>4) % n++)){
					*dox = x;
					*doy = y;
				}
	return(good);
}