blob: b49c5c4d233e00ddafccd3d9288da909fe8db166 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#include "misc.hpp"
#include "board/board.hpp"
#include "moves.hpp"
#include <cstdint>
#include <iostream>
#include <string_view>
#include <vector>
/*
* Return engine name with version number
*/
std::string_view engine_info() { return "Mono 1\n"; }
/*
* Returns total possible branches with depth X
*/
uint64_t MoveGenTest(uint32_t depth, Game *g) {
if (depth == 0) {
return 1;
}
uint64_t positionCount = 0;
std::vector<uint16_t> moves = GetLegalMoves(g, ALL);
// for each possible move create new branch
for (uint16_t move : moves) {
Undo undo = MakeMove(move, g);
positionCount += MoveGenTest(depth - 1, g);
UndoMove(undo, g);
}
return positionCount;
}
uint64_t MoveGenTestDivide(uint32_t depth, Game *g) {
if (depth == 0) {
return 1;
}
uint64_t total = 0;
std::vector<uint16_t> moves = GetLegalMoves(g, ALL);
for (uint16_t move : moves) {
uint8_t from = getFromValueFromMove(move);
uint8_t to = getToValueFromMove(move);
Position fromPos = IndexToPosition(from);
Position toPos = IndexToPosition(to);
Undo undo = MakeMove(move, g);
uint64_t count = MoveGenTest(depth - 1, g);
UndoMove(undo, g);
char fromFile = static_cast<char>('a' + fromPos.file);
char toFile = static_cast<char>('a' + toPos.file);
std::cout << fromFile << (fromPos.rank + 1) << toFile << (toPos.rank + 1);
PieceType promo = getPromotionTypeFromMove(move);
if (promo == QUEEN) {
std::cout << 'q';
} else if (promo == ROOK) {
std::cout << 'r';
} else if (promo == KNIGHT) {
std::cout << 'n';
} else if (promo == BISHOP) {
std::cout << 'b';
}
std::cout << ": " << count << "\n";
total += count;
}
std::cout << "\nTotal: " << total << "\n";
return total;
}
|