This is Board.h in view mode; [Download] [Up]
/* * Board * description: the object that stores the state of a Splat Board * history: * 2/15/93 [Erik Kay] - created * < I wasn't keeping track of my changes here > * 6/8/93 [Erik Kay] - added bycopy support */ #import <appkit/appkit.h> #import <remote/transport.h> #define BOARD_EXTENSION "sboard" // the extension for a splat board file // a couple of useful macros #define IS_MOVE(mv) ((abs(mv.from.col - mv.to.col) < 2) && (abs(mv.from.row - mv.to.row) < 2)) ? YES : NO #define IS_JUMP(mv) ((abs(mv.from.col - mv.to.col) == 2) || (abs(mv.from.row - mv.to.row) == 2)) ? YES : NO // structures defining moves and sequences of moves typedef struct _location { int col; int row; } location; typedef struct _move { location from; location to; } move; typedef struct _move_list { move mv; struct _move_list *prev; struct _move_list *next; } move_list; // the board is stored as an array of square_states // it can either be empty, blocked, have a player 1 piece, a player 2 piece // or have an error. typedef enum _square_state { SQUARE_ERROR, SQUARE_EMPTY, SQUARE_BLOCKED, SQUARE_ONE, SQUARE_TWO } square_state; @interface Board:Object <NXTransport> { // Everything is made public for optimization reasons. // I don't like breaking these abstraction barriers, but you have to do // what you have to do. @public square_state *board; int maxRow, maxCol; move currentMove; int numone, numtwo; int score; char *filename; } // how to load from a .board file + newFromFile:(const char *)filename; - reloadFromFile; - setFilename:(const char *)filename; - (const char *)filename; - initCols:(int)c Rows:(int)r; // addressing individual locations - (square_state)pieceAt:(int)col :(int)row; - (square_state)pieceAt:(location *)loc; - setPiece:(square_state)value at:(int)col :(int)row; - setPiece:(square_state)value at:(location *)loc; // query other info about the board - (int)rows; - (int)cols; - (int)numberOfPiece:(square_state)type; - (location *)pieces:(square_state)type; // score is a weight used by the computer player - (int)score; - setScore:(int)s; // board utilities - trueCopy; - clearBoard; - fillEmptyWith:(square_state)type; // keeping track of the last move on the board - setCurrentMove:(move *)mv; - (move *)currentMove; // Transport protocol - encodeRemotelyFor:(NXConnection *)connection freeAfterEncoding:(BOOL *)flagp isBycopy:(BOOL)isBycopy; - encodeUsing:(id <NXEncoding>)portal; - decodeUsing:(id <NXDecoding>)portal; @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.