diff options
| author | Franklin Wei <me@fwei.tk> | 2017-05-24 17:55:01 -0400 |
|---|---|---|
| committer | Franklin Wei <me@fwei.tk> | 2017-05-24 17:55:01 -0400 |
| commit | 2c587920f537a3f81c473759c6909d68a4c6f8a8 (patch) | |
| tree | a86948721794d6c613dfbaac77ed1c6858f72931 | |
| parent | 21f6f3e6be5a0e0264c475afb6f6a5c7d7a62b1e (diff) | |
| download | xenonchess-2c587920f537a3f81c473759c6909d68a4c6f8a8.zip xenonchess-2c587920f537a3f81c473759c6909d68a4c6f8a8.tar.gz xenonchess-2c587920f537a3f81c473759c6909d68a4c6f8a8.tar.bz2 xenonchess-2c587920f537a3f81c473759c6909d68a4c6f8a8.tar.xz | |
rename
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | chess.c | 26 |
2 files changed, 17 insertions, 11 deletions
@@ -1,4 +1,4 @@ -PROGRAM_NAME = chessengine +PROGRAM_NAME = xenonchess CC = cc INSTALL = install @@ -94,8 +94,8 @@ int eval_position(const struct chess_ctx *ctx, int color) score += count_material(ctx, color) * 4; score -= count_material(ctx, inv_player(color)) * 2; - score += count_space(ctx, color); - score -= count_space(ctx, inv_player(color)); + score += count_space(ctx, color) / 10; + score -= count_space(ctx, inv_player(color)) / 10; if(can_castle(ctx, color, QUEENSIDE) || can_castle(ctx, color, KINGSIDE)) score += 25; @@ -819,6 +819,12 @@ bool can_castle(const struct chess_ctx *ctx, int color, int style) int end = (style == QUEENSIDE ? 3 : 6); int y = color == WHITE ? 0 : 7; + + int rx = style == QUEENSIDE ? 0 : 7; + if(ctx->board[y][rx].type != ROOK || + ctx->board[y][rx].color != color) + return false; + bool clear = true; for(int i = start; i <= end; ++i) if(ctx->board[y][i].type != EMPTY) @@ -1087,7 +1093,7 @@ bool negamax_cb(void *data, const struct chess_ctx *ctx, struct move_t move) struct chess_ctx local = *ctx; if(info->depth == DEPTH) { -#if defined(UCI) || DEPTH > 4 +#if defined(UCI) || DEPTH > 3 printf("info currmove "); print_move(ctx, move); printf("info currmovenumber %d\n", ++moveno); @@ -1105,7 +1111,7 @@ bool negamax_cb(void *data, const struct chess_ctx *ctx, struct move_t move) ++pondered; execute_move(&local, move); int v = -best_move_negamax(&local, info->depth - 1, -info->b, -info->a, local.to_move, NULL); - if(v > info->best || (v == info->best && rand() % 2 == 0)) + if(v > info->best || (v == info->best && rand() % 8 == 0)) { info->best = v; info->move = move; @@ -1210,12 +1216,6 @@ int main() best_move_negamax(&ctx, DEPTH, -999999, 999999, ctx.to_move, &best); clock_t end = clock(); float time = (float)(end - start) / CLOCKS_PER_SEC; - - if(time) - { - printf("info pondered %"PRIu64" moves in %.2f seconds (%.1f/sec)\n", pondered, - time, pondered / time); - } printf("bestmove "); print_move(&ctx, best); fflush(stdout); @@ -1226,6 +1226,12 @@ int main() print_status(&ctx); #endif + if(time) + { + printf("info pondered %"PRIu64" moves in %.2f seconds (%.1f/sec)\n", pondered, + time, pondered / time); + } + if(best.type == NOMOVE) { printf("info Stalemate\n"); |