-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgen_test_pipeline.cpp
52 lines (50 loc) · 1.43 KB
/
gen_test_pipeline.cpp
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
#include "reversi.hpp"
#include <algorithm>
#include <iostream>
#include <random>
#include <string>
int main(int argc, char** argv) {
if (argc < 2) {
std::cerr << "Usage: " << argv[0] << " NUM_DATA" << std::endl;
return EXIT_FAILURE;
}
size_t count = std::stoi(argv[1]);
int empty_min = 1;
if (argc >= 3 ) {
empty_min = std::stoi(argv[2]);
}
int empty_max = 7;
std::random_device rd;
std::mt19937 mt(rd());
std::uniform_int_distribution<int> empty_dis(empty_min, empty_max);
for (size_t i = 0; i < count; ++i) {
Board board;
std::bernoulli_distribution dis_sq;
for (size_t j = 0; j < Length; ++j) {
for (size_t k = 0; k < Length; ++k) {
if (dis_sq(mt)) {
board[j][k] = Square::Player;
} else {
board[j][k] = Square::Opponent;
}
}
}
std::vector<size_t> empties_candi(Area);
std::iota(std::begin(empties_candi), std::end(empties_candi), 0);
std::vector<size_t> empties;
std::sample(std::begin(empties_candi), std::end(empties_candi), std::back_inserter(empties),
empty_dis(mt), mt);
for (auto&& pos : empties) {
board[pos / Length][pos % Length] = Square::Empty;
}
if (is_gameover(board)) {
--i;
continue;
}
auto res = solve(board);
std::cout << to_bit(board, Square::Player).to_ulong() << " "
<< to_bit(board, Square::Opponent).to_ulong() << " "
<< res << "\n";
}
return 0;
}