flok99

Untitled

Oct 7th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. x-----o
  2. -------
  3. -------
  4. -------
  5. -------
  6. -------
  7. o-----x
  8. Turn: Black
  9.  
  10. f1 f2 g2 a6 b6 b7 g1e1 g1e2 g1e3 g1f3 g1g3 a7a5 a7b5 a7c5 a7c6 a7c7
  11. Move: f1f2
  12.  
  13. x-----o
  14. -------
  15. -------
  16. -------
  17. -------
  18. -----x-
  19. o-----x
  20. Turn: White
  21.  
  22. b1 a2 b2 f6 g6 f7 a1c1 a1c2 a1a3 a1b3 a1c3 g7e5 g7f5 g7g5 g7e6 g7e7
  23.  
  24.  
  25. DOES NOT MAKE SENSE
  26.  
  27.  
  28. code:
  29. #include <iostream>
  30. #include "libataxx/libataxx.hpp"
  31. #include <string>
  32.  
  33. int main(int argc, char **argv) {
  34. auto pos = libataxx::Position("startpos");
  35.  
  36. while (!pos.gameover()) {
  37. // Print board
  38. std::cout << pos << std::endl;
  39.  
  40. libataxx::Move moves[libataxx::max_moves];
  41. const int num_moves = pos.legal_moves(moves);
  42.  
  43. for (int i = 0; i < num_moves; ++i)
  44. std::cout << moves[i] << " ";
  45. std::cout << std::endl;
  46.  
  47. // Get move
  48. std::cout << "Move: ";
  49. std::string movestr;
  50. std::cin >> movestr;
  51. std::cout << std::endl;
  52.  
  53. libataxx::Move new_move = libataxx::Move::from_uai(movestr);
  54.  
  55. // Find & make move
  56. for (int i = 0; i < num_moves; ++i) {
  57. if (moves[i] == new_move) {
  58. pos.makemove(new_move);
  59. break;
  60. }
  61. }
  62. }
  63.  
  64. // Print board
  65. std::cout << pos << std::endl;
  66.  
  67. return 0;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment