eval_t: s16 + add in pos_t + remove useless opening pieces values
This commit is contained in:
@@ -37,15 +37,20 @@ struct command {
|
||||
};
|
||||
|
||||
int execute_line (pos_t *, struct command *, char *);
|
||||
|
||||
struct command *find_command (char *);
|
||||
int string_trim (char *str);
|
||||
|
||||
/* The names of functions that actually do the manipulation. */
|
||||
|
||||
/* standard UCI commands */
|
||||
int do_ucinewgame(pos_t *, char *);
|
||||
int do_uci(pos_t *, char *);
|
||||
int do_isready(pos_t *, char *);
|
||||
|
||||
int do_position(pos_t *, char *);
|
||||
|
||||
/* commands *NOT* in UCI standard */
|
||||
int do_moves(pos_t *, char *);
|
||||
int do_diagram(pos_t *, char *);
|
||||
int do_perft(pos_t *, char *);
|
||||
@@ -70,22 +75,6 @@ struct command commands[] = {
|
||||
{ "diagram", do_diagram, "(not UCI) print current position diagram" },
|
||||
{ "hist", do_hist, "(not UCI) print history states" },
|
||||
|
||||
/*
|
||||
* { "init", do_init, "Set position to normal start position" },
|
||||
|
||||
* { "genmove", do_genmoves, "Generate move list for " },
|
||||
* { "prmoves", do_prmoves, "Print position move list" },
|
||||
* // { "prmovepos", do_prmovepos, "Print Nth move resulting position" },
|
||||
* { "prpieces", do_prpieces, "Print Pieces (from pieces lists)" },
|
||||
* { "memstats", do_memstats, "Generate next move list" },
|
||||
* { "eval", do_eval, "Eval current position" },
|
||||
* { "simple-eval", do_simple_eval, "Simple eval current position" },
|
||||
* { "do_move", do_move, "execute nth move on current position" },
|
||||
* { "debug", do_debug, "Set log level to LEVEL" },
|
||||
* { "depth", do_depth, "Set search depth to N" },
|
||||
* { "search", do_search, "Search best move (negamax)" },
|
||||
* { "pvs", do_pvs, "Search best move (Principal Variation Search)" },
|
||||
*/
|
||||
{ NULL, (int(*)()) NULL, NULL }
|
||||
};
|
||||
|
||||
|
@@ -91,11 +91,9 @@ typedef struct __movelist_s movelist_t;
|
||||
|
||||
/* basic types
|
||||
*/
|
||||
typedef u64 bitboard_t;
|
||||
|
||||
/* eval type
|
||||
*/
|
||||
//typedef s32 eval_t;
|
||||
typedef u64 bitboard_t;
|
||||
typedef s16 eval_t;
|
||||
|
||||
/* forward enum definition is impossible in C11.
|
||||
* To simplify cross-dependancies, all important enum are moved here.
|
||||
|
32
src/piece.c
32
src/piece.c
@@ -25,22 +25,22 @@
|
||||
* piece_details
|
||||
*/
|
||||
const struct piece_details piece_details[PIECE_MAX] = {
|
||||
/* cap low fen sym name values */
|
||||
[EMPTY] = { "", "", "", "", "", 0, 0, 0 },
|
||||
[W_PAWN] = { "", "", "P", "♙", "Pawn", P_VAL_OPN, P_VAL_MID, P_VAL_END },
|
||||
[W_KNIGHT] = { "N", "n", "N", "♘", "Knight", N_VAL_OPN, N_VAL_MID, N_VAL_END },
|
||||
[W_BISHOP] = { "B", "b", "B", "♗", "Bishop", B_VAL_OPN, B_VAL_MID, B_VAL_END },
|
||||
[W_ROOK] = { "R", "r", "R", "♖", "Rook", R_VAL_OPN, R_VAL_MID, R_VAL_END },
|
||||
[W_QUEEN] = { "Q", "q", "Q", "♕", "Queen", Q_VAL_OPN, Q_VAL_MID, Q_VAL_END },
|
||||
[W_KING] = { "K", "k", "K", "♔", "King", K_VAL_OPN, K_VAL_MID, K_VAL_END },
|
||||
[7] = { "", "", "", "", "", 0, 0, 0 },
|
||||
[8] = { "", "", "", "", "", 0, 0, 0 },
|
||||
[B_PAWN] = { "", "", "p", "♟", "Pawn", P_VAL_OPN, P_VAL_MID, P_VAL_END },
|
||||
[B_KNIGHT] = { "N", "n", "n", "♞", "Knight", P_VAL_OPN, N_VAL_MID, N_VAL_END },
|
||||
[B_BISHOP] = { "B", "b", "b", "♝", "Bishop", P_VAL_OPN, B_VAL_MID, B_VAL_END },
|
||||
[B_ROOK] = { "R", "r", "r", "♜", "Rook", P_VAL_OPN, R_VAL_MID, R_VAL_END },
|
||||
[B_QUEEN] = { "Q", "q", "q", "♛", "Queen", P_VAL_OPN, Q_VAL_MID, Q_VAL_END },
|
||||
[B_KING] = { "K", "k", "k", "♚", "King", P_VAL_OPN, K_VAL_MID, K_VAL_END },
|
||||
/* cap low fen sym name midgame val endgame val */
|
||||
[EMPTY] = { "", "", "", "", "", 0, 0 },
|
||||
[W_PAWN] = { "", "", "P", "♙", "Pawn", P_VAL_MID, P_VAL_END },
|
||||
[W_KNIGHT] = { "N", "n", "N", "♘", "Knight", N_VAL_MID, N_VAL_END },
|
||||
[W_BISHOP] = { "B", "b", "B", "♗", "Bishop", B_VAL_MID, B_VAL_END },
|
||||
[W_ROOK] = { "R", "r", "R", "♖", "Rook", R_VAL_MID, R_VAL_END },
|
||||
[W_QUEEN] = { "Q", "q", "Q", "♕", "Queen", Q_VAL_MID, Q_VAL_END },
|
||||
[W_KING] = { "K", "k", "K", "♔", "King", K_VAL_MID, K_VAL_END },
|
||||
[7] = { "", "", "", "", "", 0, 0 },
|
||||
[8] = { "", "", "", "", "", 0, 0 },
|
||||
[B_PAWN] = { "", "", "p", "♟", "Pawn", P_VAL_MID, P_VAL_END },
|
||||
[B_KNIGHT] = { "N", "n", "n", "♞", "Knight", N_VAL_MID, N_VAL_END },
|
||||
[B_BISHOP] = { "B", "b", "b", "♝", "Bishop", B_VAL_MID, B_VAL_END },
|
||||
[B_ROOK] = { "R", "r", "r", "♜", "Rook", R_VAL_MID, R_VAL_END },
|
||||
[B_QUEEN] = { "Q", "q", "q", "♛", "Queen", Q_VAL_MID, Q_VAL_END },
|
||||
[B_KING] = { "K", "k", "k", "♚", "King", K_VAL_MID, K_VAL_END },
|
||||
};
|
||||
|
||||
const char pieces_str[6+6+1] = "PNBRQKpnbrqk";
|
||||
|
35
src/piece.h
35
src/piece.h
@@ -44,23 +44,15 @@ typedef enum __piece_e {
|
||||
PIECE_MAX
|
||||
} piece_t;
|
||||
|
||||
/* default values for opening, midgame, endgame
|
||||
/* default values for midgame, endgame
|
||||
*/
|
||||
#define E_VAL_OPN 0 /* empty */
|
||||
#define P_VAL_OPN 100
|
||||
#define N_VAL_OPN 300
|
||||
#define B_VAL_OPN 300
|
||||
#define R_VAL_OPN 500
|
||||
#define Q_VAL_OPN 900
|
||||
#define K_VAL_OPN 20000
|
||||
|
||||
#define E_VAL_MID 0
|
||||
#define P_VAL_MID 100
|
||||
#define N_VAL_MID 300
|
||||
#define B_VAL_MID 300
|
||||
#define R_VAL_MID 500
|
||||
#define Q_VAL_MID 900
|
||||
#define K_VAL_MID 20000
|
||||
#define K_VAL_MID 10000
|
||||
|
||||
#define E_VAL_END 0
|
||||
#define P_VAL_END 100
|
||||
@@ -68,7 +60,7 @@ typedef enum __piece_e {
|
||||
#define B_VAL_END 300
|
||||
#define R_VAL_END 500
|
||||
#define Q_VAL_END 900
|
||||
#define K_VAL_END 20000
|
||||
#define K_VAL_END 10000
|
||||
|
||||
/* some default values for pieces
|
||||
* @abbr: char, piece capital letter (used for game notation)
|
||||
@@ -86,9 +78,8 @@ extern const struct piece_details {
|
||||
char *fen; /* cap=white, low=black */
|
||||
char *sym; /* UTF-8 symbol */
|
||||
char *name; /* piece name */
|
||||
s64 opn_value; /* value opening */
|
||||
s64 mid_value; /* value midgame */
|
||||
s64 end_value; /* value endgame */
|
||||
s16 mid_value; /* value midgame */
|
||||
s16 end_value; /* value endgame */
|
||||
} piece_details[PIECE_MAX];
|
||||
|
||||
extern const char pieces_str[6+6+1]; /* to search from fen/user input */
|
||||
@@ -102,13 +93,18 @@ extern const char pieces_str[6+6+1]; /* to search from fen/user inp
|
||||
#define PIECE(p) ((p) & MASK_PIECE)
|
||||
#define MAKE_PIECE(p, c) ((p) | (c) << 3)
|
||||
|
||||
#define IS_WHITE(p) (!COLOR(p))
|
||||
#define IS_BLACK(p) (COLOR(p))
|
||||
#define IS_BLACK(p) ((p) & MASK_COLOR)
|
||||
#define IS_WHITE(p) (! IS_BLACK(p))
|
||||
|
||||
#define SET_WHITE(p) (piece_t)((p) &= ~MASK_COLOR)
|
||||
#define SET_BLACK(p) (piece_t)((p) |= MASK_COLOR)
|
||||
#define SET_COLOR(p, c) (piece_t)(!(c)? SET_WHITE(p): SET_BLACK(p))
|
||||
|
||||
static __inline s16 piece_val(piece_type_t pt)
|
||||
{
|
||||
return piece_details[pt].mid_value;
|
||||
}
|
||||
|
||||
bool piece_ok(piece_t p);
|
||||
|
||||
char *piece_to_cap(piece_t p);
|
||||
@@ -118,18 +114,13 @@ char *piece_to_sym(piece_t p);
|
||||
char *piece_to_name(piece_t p);
|
||||
|
||||
#define piece_to_char(c) piece_to_fen(c)
|
||||
//#define piece_to_char_t(p) piece_to_uci(p)
|
||||
#define piece_to_uci(p) piece_to_low(p)
|
||||
|
||||
//piece_type_t char_to_piece(char c);
|
||||
piece_type_t piece_t_from_char(char c);
|
||||
piece_t piece_from_fen(char c);
|
||||
|
||||
#define piece_from_char(c) piece_from_fen(c)
|
||||
|
||||
/* use short name or symbol - no effect
|
||||
*/
|
||||
#define P_USE_UTF 1
|
||||
|
||||
//void piece_list_print(struct list_head *list);
|
||||
//pool_t *piece_pool_init();
|
||||
//void piece_pool_stats();
|
||||
|
@@ -52,10 +52,10 @@ typedef struct __pos_s {
|
||||
move_t move;
|
||||
struct state_s *prev;
|
||||
);
|
||||
eval_t eval;
|
||||
bitboard_t checkers; /* opponent checkers */
|
||||
bitboard_t pinners; /* opponent pinners */
|
||||
bitboard_t blockers; /* pieces blocking pin */
|
||||
|
||||
piece_t board[BOARDSIZE];
|
||||
bitboard_t bb[2][PIECE_TYPE_MAX]; /* bb[0][PAWN], bb[1][ALL_PIECES] */
|
||||
square_t king[2]; /* dup with bb, faster retrieval */
|
||||
|
Reference in New Issue
Block a user