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 m

⟦16d13a1db⟧ TextFile

    Length: 867 (0x363)
    Types: TextFile
    Names: »move.c«

Derivation

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

TextFile

/*
 *	move.c
 *
 *	move player to x,y in board
 */

# include	"reversi.h"

int		offsets[] = { -11, -10, -9, -1, 1, 9, 10, 11, 0 };

move (player, x, y, board)
register int	player;
int				x, y;
boardT			board;
{
	register char	*b, *m;
	register int	*o, i;

	b = & board[x][y];
	*b = player;
	player = -player;
	for (o = offsets; i = *o++;) {
		if (b[i] == player) {
			m = b+i;
			while (*m == player)
				m += i;
			if (*m == -player) {
				while (m != b) {
					*m = -player;
					m -= i;
				}
			}
		}
	}
}

legal (player, x, y, board)
register int	player;
int				x, y;
boardT			board;
{
	register char	*b, *m;
	register int	*o, i;

	b = & board[x][y];
	player = -player;
	if (*b == EMPTY) {
		for (o = offsets; i = *o++;) {
			if (b[i] == player) {
				m = b+i;
				while (*m == player)
					m += i;
				if (*m == -player)
					return 1;
			}
		}
	}
	return 0;
}