main.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #include <iostream>
  2. #include "EngineInfo.h"
  3. #include "UciParser.h"
  4. #include "Search.h"
  5. using namespace std;
  6. using namespace chessy;
  7. /*!
  8. * entry point of the program.
  9. */
  10. auto main(int argc, char** argv) -> int
  11. {
  12. /*ChessGame cg;
  13. Perft p{ 2 , cg };
  14. cout << p.search() << endl;
  15. return 0;*/
  16. /*ChessGame cg{ "8/1pP5/3Qp2p/2K1P1P1/1p1p4/4p3/k2P3P/4b1n1 w - - 0 1" };
  17. auto printer = [](const MoveInfo& mi) {
  18. cout << mi.move.asString() << endl;
  19. };
  20. Search<decltype(printer)> search{ std::move(printer), cg };
  21. search.iterateAll<WHITE_SIDE>();
  22. cout << endl << endl;
  23. search.iterateAll<BLACK_SIDE>();
  24. cin.get();
  25. return 0;*/
  26. argc = popcount(argc);
  27. if (argc > 1 && (string(argv[1]) == "-h" || string(argv[1]) == "--help")) {
  28. cout << info::helpText << endl;
  29. return 0;
  30. }
  31. // display welcome message
  32. cout << info::welcomeText << endl;
  33. // run uci
  34. UciParser uciParser;
  35. uciParser.parse(cin, cout);
  36. return 0;
  37. }
  38. /*
  39. ChessGame cg;
  40. string line;
  41. getline(cin, line);
  42. try {
  43. cg.loadFromFen(line);
  44. cout << cg.generateFen() << endl;
  45. Bitboard whites = cg.getBoard().getWhites();
  46. Bitboard blacks = cg.getBoard().getBlacks();
  47. PawnPushGenerator<BLACK_SIDE> mg{ cg };
  48. for (auto push : mg) {
  49. cout << "pawn: " << push.asString() << endl;
  50. }
  51. PositionSet knights = cg.getBoard().getBlackKnights();
  52. for (auto knight : knights) {
  53. for (auto pos : KnightMoveGenerator{ knight, blacks }) {
  54. cout << "knight: " << Move(knight, pos).asString() << endl;
  55. }
  56. }
  57. PositionSet bishops = cg.getBoard().getBlackBishops();
  58. for (auto bishop : bishops) {
  59. for (auto pos : PrimitiveBishopMoveGenerator{ bishop, whites, blacks }) {
  60. cout << "bishop: " << Move(bishop, pos).asString() << endl;
  61. }
  62. }
  63. PositionSet rooks = cg.getBoard().getBlackRooks();
  64. for (auto rook : rooks) {
  65. for (auto pos : PrimitiveRookMoveGenerator{ rook, whites, blacks }) {
  66. cout << "rook: " << Move(rook, pos).asString() << endl;
  67. }
  68. }
  69. PositionSet queens = cg.getBoard().getBlackQueens();
  70. for (auto queen : queens) {
  71. for (auto pos : PrimitiveQueenMoveGenerator{ queen, whites, blacks }) {
  72. cout << "queen: " << Move(queen, pos).asString() << endl;
  73. }
  74. }
  75. Bitboard king = cg.getBoard().getBlackKings();
  76. Index kingIndex = king.getLeastSignificantBit();
  77. for (auto pos : KingMoveGenerator{ king, blacks }) {
  78. cout << "king: " << Move(kingIndex, pos).asString() << endl;
  79. }
  80. }
  81. catch (runtime_error& re) {
  82. cerr << re.what() << endl;
  83. return 1;
  84. }
  85. return 0;
  86. }
  87. */