home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ragnaroek
/
Ragnaroek.img
/
OpponentApp
/
GameState.h
< prev
next >
Wrap
Text File
|
1991-12-08
|
2KB
|
85 lines
#import <objc/Object.h>
struct move {unsigned char from, to;};
struct spot {unsigned char who, idnum;};
struct capture {short when; unsigned char where, idnum;};
extern const unsigned char board[256];
extern BOOL pawn_legal[256];
extern BOOL loki_legal[256];
#define OFFBOARD 0
#define PLAIN 1
#define CENTER 2
#define CORNER 3
#define CAPTURE_HELPER(where) (board[where] > PLAIN)
typedef void (*IMPMakeMove)(id, SEL, struct move);
extern IMPMakeMove makeMove, makeWhiteMove, makeBlackMove;
typedef void (*IMPUndoMove)(id, SEL);
extern IMPUndoMove undoMove, undoWhiteMove, undoBlackMove;
typedef BOOL (*IMPAnyLegalMoves)(id, SEL);
extern IMPAnyLegalMoves anyLegalMoves;
@interface GameState:Object
{
@public
unsigned char pieceLocs[37];
#define XYTONUM(x,y) ( ((x)+2) + ((y)+2)*16 )
#define NUMTOX(num) (((num) % 16) - 2)
#define NUMTOY(num) (((num) / 16) - 2)
#define EAST 1
#define WEST -1
#define NORTH 16
#define SOUTH -16
struct spot pieces[256];
#define NOBODY 0
#define W_PAWN 1
#define B_PAWN 2
#define LOKI 3
#define UNOCCUPIED(where) (pieces[(where)].who == NOBODY)
#define WHITEPIECE(where) (pieces[(where)].who == W_PAWN)
#define BLACKPIECE(where) (pieces[(where)].who >= B_PAWN)
unsigned char whoseTurn;
#define BLACK 0
#define WHITE 1
#define BLACK_WON 2
#define WHITE_WON 3
#define DRAW 4
#define GAMEOVER(whoseTurn) ((whoseTurn) >= 2)
unsigned char numPawns[2];
struct move moves[1024];
short numMoves;
struct capture captures[36];
short numCaptures;
}
+ initialize;
- init;
- (void)resetState;
- (void)makeMove:(struct move)request;
- (void)makeWhiteMove:(struct move)request;
- (void)makeBlackMove:(struct move)request;
- (void)undoMove;
- (void)undoWhiteMove;
- (void)undoBlackMove;
- (BOOL)anyLegalMoves;
- (BOOL)checkMove:(struct move)request;
- read:(NXTypedStream *)stream;
- write:(NXTypedStream *)stream;
@end