12 using namespace osl::effect_util;
14 void usage(
const char *program_name)
16 std::cerr << program_name <<
" csafiles\n";
21 void run(
const char *filename);
23 int main(
int argc,
char **argv)
25 const char *program_name = argv[0];
26 bool error_flag =
false;
31 while ((c = getopt(argc, argv,
"s:vh")) != EOF)
37 default: error_flag =
true;
43 if (error_flag || (argc < 1))
48 for (
int i=0; i<argc; ++i)
53 catch (std::exception& e)
55 std::cerr << e.what() <<
"\n";
64 void run(
const char *filename)
68 unsigned long long total_cycles_step=0;
69 unsigned long long total_cycles_step1=0;
71 Record rec=CsaFile(filename).getRecord();
72 NumEffectState state(rec.getInitialState());
73 const vector<osl::Move>
moves=rec.getMoves();
81 const PieceMask black_pins = Pin::make(state,
BLACK);
82 const PieceMask white_pins = Pin::make(state,
WHITE);
83 total_cycles += clock.
stop();
85 const PieceMask black_pins_naive = Pin::makeNaive(state,
BLACK);
86 const PieceMask white_pins_naive = Pin::makeNaive(state,
WHITE);
87 total_cycles_naive += clock.
stop();
89 const PieceMask black_pins_step = Pin::makeStep(state, state.kingSquare<
BLACK>(),
BLACK);
90 const PieceMask white_pins_step = Pin::makeStep(state, state.kingSquare<
WHITE>(),
WHITE);
91 total_cycles_step += clock.
stop();
93 const PieceMask black_pins_step1 = Pin::makeStep1(state, state.kingSquare<
BLACK>(),
BLACK);
94 const PieceMask white_pins_step1 = Pin::makeStep1(state, state.kingSquare<
WHITE>(),
WHITE);
95 total_cycles_step1 += clock.
stop();
98 if (i >= moves.size())
100 const Move move = moves[i++];
101 state.makeMove(move);
103 std::cerr <<
"p " << total_cycles <<
" / " << positions <<
" = "
104 << total_cycles/(double)positions <<
"\n";
105 std::cerr <<
"n " << total_cycles_naive <<
" / " << positions <<
" = "
106 << total_cycles_naive/(double)positions <<
"\n";
107 std::cerr <<
"n " << total_cycles_step <<
" / " << positions <<
" = "
108 << total_cycles_step/(double)positions <<
"\n";
109 std::cerr <<
"n " << total_cycles_step1 <<
" / " << positions <<
" = "
110 << total_cycles_step1/(double)positions <<
"\n";