Line 142... |
Line 142... |
PIECE_THREAT0,
|
PIECE_THREAT0,
|
PIECE_MARKER = PIECE_THREAT0,
|
PIECE_MARKER = PIECE_THREAT0,
|
/* These threat markers are usable by the AIs */
|
/* These threat markers are usable by the AIs */
|
};
|
};
|
typedef int PIECE;
|
typedef int PIECE;
|
//#pragma bitsize PIECE 16
|
#pragma bitsize PIECE 32
|
|
|
#define MAX_THREAT (INT_MAX - PIECE_THREAT0)
|
#define MAX_THREAT (INT_MAX - PIECE_THREAT0)
|
/* Highest value a threat marker can have */
|
/* Highest value a threat marker can have */
|
|
|
#define PIECE_THREAT(n) (PIECE_THREAT0 + (n))
|
#define PIECE_THREAT(n) (PIECE_THREAT0 + (n))
|
Line 187... |
Line 187... |
|
|
PIECE data[board_stride][board_stride];
|
PIECE data[board_stride][board_stride];
|
} Board;
|
} Board;
|
/* The board structure represents the state of the game board. Do NOT preserve
|
/* The board structure represents the state of the game board. Do NOT preserve
|
board pointers across games. */
|
board pointers across games. */
|
|
typedef struct{
|
|
unsigned int data[361];
|
|
#pragma bitsize data 9
|
|
} index_array;
|
|
|
extern AllocChain *board_root;
|
extern AllocChain *board_root;
|
extern gsize board_mem;
|
extern gsize board_mem;
|
/* Variables for the allocation chain */
|
/* Variables for the allocation chain */
|
|
|
Line 342... |
Line 346... |
void aimoves_append(AIMoves *moves, const AIMove *aim);
|
void aimoves_append(AIMoves *moves, const AIMove *aim);
|
#define aimoves_set aimoves_append
|
#define aimoves_set aimoves_append
|
///////////* Add an AIMove to an AIMoves array; existing moves weights will be
|
///////////* Add an AIMove to an AIMoves array; existing moves weights will be
|
////////// overwritten */
|
////////// overwritten */
|
//////////
|
//////////
|
int aimoves_choose(AIMoves *moves, AIMove *move, unsigned int *index);
|
int aimoves_choose(AIMoves *moves, AIMove *move, index_array *index);
|
/* Will choose one of the best moves from a GArray of AIMove structures at
|
/* Will choose one of the best moves from a GArray of AIMove structures at
|
random. Returns non-zero if a move was chosen or zero if a move could not
|
random. Returns non-zero if a move was chosen or zero if a move could not
|
be chosen for some reason. */
|
be chosen for some reason. */
|
//////////
|
//////////
|
int aimoves_compare(const void *a, const void *b);
|
int aimoves_compare(const void *a, const void *b);
|
Line 417... |
Line 421... |
////////// function */
|
////////// function */
|
//////////
|
//////////
|
/*AIMoves **/ void enum_adjacent(Board *b, int dist,AIMoves *moves,unsigned int current_random);
|
/*AIMoves **/ void enum_adjacent(Board *b, int dist,AIMoves *moves,unsigned int current_random);
|
/* Enumerate empty tiles at most dist away from some other piece on the board */
|
/* Enumerate empty tiles at most dist away from some other piece on the board */
|
|
|
void streamsort(AIMoves *moves,unsigned int *index);
|
void streamsort(AIMoves *moves,index_array *index);
|
/*AIMoves **/void ai_marks(Board *b, PIECE min,AIMoves *moves);
|
/*AIMoves **/void ai_marks(Board *b, PIECE min,AIMoves *moves);
|
/* Fills a moves list with tiles marked at least PIECE_THREAT(min) */
|
/* Fills a moves list with tiles marked at least PIECE_THREAT(min) */
|
|
|
/*
|
/*
|
* AI
|
* AI
|
Line 457... |
Line 461... |
///////////
|
///////////
|
///////////AIMoves *ai_utility(const Board *b);
|
///////////AIMoves *ai_utility(const Board *b);
|
///////////AIMoves *ai_dfs_utility(const Board *b);
|
///////////AIMoves *ai_dfs_utility(const Board *b);
|
////////////* Utility function */
|
////////////* Utility function */
|
///////////
|
///////////
|
/*AIMoves **/int ai_threats(Board *board,AIMoves *moves,unsigned int *index);
|
/*AIMoves **/int ai_threats(Board board[5][16],int depth,int branch,AIMoves moves[5][16],index_array *index);
|
AIMoves *ai_priority(const Board *b);
|
AIMoves *ai_priority(const Board *b);
|
/* Multi-level threats */
|
/* Multi-level threats */
|
|
|
|
|
|
|
Line 481... |
Line 485... |
typedef struct {
|
typedef struct {
|
PLAYER ai;
|
PLAYER ai;
|
//SEARCH search;
|
//SEARCH search;
|
int depth, branch, cache, tss;
|
int depth, branch, cache, tss;
|
} Player;
|
} Player;
|
/*AIMoves **/int search(const Board *board,AIMove *move, Player *player);
|
/*AIMoves **/int search(Board *board,AIMove *move, Player *player);
|
#endif
|
#endif
|
|
|
No newline at end of file
|
No newline at end of file
|