ftp.nice.ch/pub/next/games/network/Splat.1.0.s.tar.gz#/Splat-1.0/Jaws.bproj/JawsComp.m

This is JawsComp.m in view mode; [Download] [Up]

/*
 * Stratgey: Jaws
 * Description: Same as greedy, except that open holes are scored as well.
 *		Every open hole gets a score that is added to the total score.
 *		This score is the number of all opposing pieces minus the
 *		number of the player's own pieces that surround the given
 *		empty square.  The factor used in the greedy part of the
 *		algorithm is so large as to make the holes only a factor when
 *		deciding between equally scored greedy boards.
 * Author: Mat Hostetter (rewritten by Erik_Kay@next.com)
 */

#import "JawsComp.h"

@implementation JawsComp

+ (const char *)strategyName
{
    return "Jaws";
}

-(int)scoreBoard:(Board *)b forPlayer:(square_state)player
{
    int x1, y1, x, y, score = 0;
    int cols, rows;
    square_state square1, square2;

    score = 1000 * 
    	([b numberOfPiece:player] - [b numberOfPiece:OTHER_PLAYER(player)]);
    cols = [b cols];
    rows = [b rows];
    for (x1=0; x1 < cols; x1++)
	for (y1=0; y1 < rows; y1++) {
	    square1 = b->board[x1 + y1 * cols];
	    if (square1 == SQUARE_EMPTY) {
		for (x=MAX(x1-1, 0); x<=MIN(x1+1, cols - 1); x++)
		    for (y=MAX(y1-1, 0); y<=MIN(y1+1, rows - 1); y++) {
			square2 = b->board[x + y * cols];
			switch (square2) {
			    case SQUARE_ONE:
			    case SQUARE_TWO:
				score += ((square2 == player) ? -1 : 1);
				break;
			    default:
			    	break;
			}
		    }
	    }
	}
    return score;
}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.