diff options
| author | Franklin Wei <me@fwei.tk> | 2017-05-26 21:05:33 -0400 |
|---|---|---|
| committer | Franklin Wei <me@fwei.tk> | 2017-05-26 21:05:33 -0400 |
| commit | df29f1dba7e10c1eaa683a2625cb2556de46d351 (patch) | |
| tree | 37d7cb330d671aac996fda70d2647f59669d5d3f | |
| parent | f3d6ed29d304b8dc336675a9da427c31d08d4fd4 (diff) | |
| download | xenonchess-df29f1dba7e10c1eaa683a2625cb2556de46d351.zip xenonchess-df29f1dba7e10c1eaa683a2625cb2556de46d351.tar.gz xenonchess-df29f1dba7e10c1eaa683a2625cb2556de46d351.tar.bz2 xenonchess-df29f1dba7e10c1eaa683a2625cb2556de46d351.tar.xz | |
king penalty
| -rw-r--r-- | chess.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -1,6 +1,6 @@ #include "chess.h" -#define DEPTH 2 +#define DEPTH 1 #define AUTOMATCH //#define UCI @@ -26,9 +26,9 @@ int count_material(const struct chess_ctx *ctx, int color) /* pawn near promotion */ if(ctx->board[y][x].type == PAWN) { - if((y >= 5 && ctx->board[y][x].color == WHITE) || - (y <= 2 && ctx->board[y][x].color == BLACK)) - total += 4; + if((y >= 4 && ctx->board[y][x].color == WHITE) || + (y <= 3 && ctx->board[y][x].color == BLACK)) + total += 5; /* pawns are more valuable the further they have advanced */ total += ctx->board[y][x].color == WHITE ? y : 7 - y; @@ -1094,8 +1094,12 @@ bool negamax_cb(void *data, const struct chess_ctx *ctx, struct move_t move) ++pondered; + int king_penalty = 0; + if(move.type == NORMAL && ctx->board[move.data.normal.from.x][move.data.normal.from.y].type == KING) + king_penalty = 100; + execute_move(&local, move); - int v = -best_move_negamax(&local, info->depth - 1, -info->b, -info->a, local.to_move, NULL); + int v = -(best_move_negamax(&local, info->depth - 1, -info->b, -info->a, local.to_move, NULL) + king_penalty); if(v > info->best || (v == info->best && rand() % 8 == 0)) { info->best = v; |