// ******************************************************************* // (C) Copyright 2013 Leiden Institute of Advanced Computer Science // Universiteit Leiden // All Rights Reserved // ******************************************************************* // Dou Shou Qi (engine) // ******************************************************************* // FILE INFORMATION: // File: main.cc // Author: Jonathan K. Vis // Revision: 1.01a // Date: 2013/04/18 // ******************************************************************* // DESCRIPTION: // Bagheera // ******************************************************************* #include "../core/position.h" #include "../interface/cstdio_interface.h" #include "../interface/options.h" #include "../interface/jlkiss64.h" #include "search.h" #include "timer.h" #include #include #include static char const* const ENGINE_NAME = "Bagheera v1.03alpha"; int main(int argc, char* argv[]) { char const* depth_string = get_option(argc, argv, 'd'); char const* configuration = get_option(argc, argv, 'p'); int depth = depth_string == 0 ? 0 : atoi(depth_string); if (depth <= 0) { depth = 256; } // if Position position; if (configuration != 0) { set_configuration(position, configuration); } // if else { position.initial(); } // else RNG::seed(static_cast(time(0))); position.set_key(RNG::next()); fprintf(stderr, "Engine `%s' started.\n", ENGINE_NAME); //draw_board(position, stderr); Move move; int value = -INFINITY; //fputs("depth time nodes value move principal variation\n" // "=============================================================\n", stderr); tic(); for (int d = 1; d <= depth; ++d) { Move variation[256]; node_count = 0; leaf_count = 0; value = negamax_root(position, d, move); //value = alphabeta_root(position, d, -INFINITY, INFINITY, move); int const count = principal_variation(position, d, value, 0, variation); /* fprintf(stderr, "%5d%8.2f%13llu%8d ", d, seconds(toc()), leaf_count, value); if (!move.is_capture()) { fputc(' ', stderr); } // if write_move(move, stderr); fputs(" ", stderr); for (int i = 0; i < count; ++i) { write_move(variation[i], stderr); fputc(' ', stderr); } // for fputc('\n', stderr); */ if (value <= WIN || value >= -WIN) { break; } // if } // for printf("%d\n", value); write_move(move, stdout); putchar('\n'); return 0; } // main