This is ComputerPlayer.h in view mode; [Download] [Up]
/* * ComputerPlayer * description: a generic class for computer game players. It implements a * threaded, sorted, alpha beta search tree. * history: * 2/15/93 [Erik Kay] - created */ #import "Player.h" #import <mach/cthreads.h> #define OTHER_PLAYER(type) ((type == SQUARE_ONE) ? SQUARE_TWO : SQUARE_ONE) // #define DEBUG_FOO #ifdef DEBUG_FOO #define dprintf(s) printf s #else #define dprintf(msg) #endif @interface ComputerPlayer:Player { int searchDepth; condition_t myTurn; mutex_t myLock; id server; BOOL beingFreed; BOOL sorting; BOOL deterministic; /* debugging stats */ int moveTime; int numLeaves; int pruningPercent; int numPruned; int totalNodes; } // how far it looks ahead - (int)searchDepth; - setSearchDepth:(int)depth; // given a board, rate it - (int)scoreBoard:(Board *)b forPlayer:(square_state)type; // the alpha beta search tree - (int)ABSearch:(Board *)b atDepth:(int)d forPlayer:(square_state)player alpha:(int)alpha beta:(int)beta; // sorting the moves - (int)partition:(List *)boards from:(int)from to:(int)to; - sortMoves:(List *)boards from:(int)from to:(int)to; - sortMoves:(List *)boards; // do the move. These methods control the threaded aspect of the player. - reallyDoNextMove; - (move)nextMove; - waitForTurn; // the name + (const char *)strategyName; - (char *)playerName; @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.