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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
/**
* @file
* count.cc
*
* ȥ꤬и
* ޤиʤΤϽŤߤη
*/
#include "osl/progress/ptypeoSquare.h"
#include "osl/progress/ptypeRank.h"
#include "osl/stat/activityCount.h"
#include "osl/record/kisen.h"
#include "osl/numEffectState.h"
#include "osl/effectUtil.h"
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <unistd.h>
void usage(const char *prog)
{
using namespace std;
cerr << "Usage: " << prog << " [-N#games] -o output-filename"
<< " -g gekisashi simulation\n"
<< endl;
exit(1);
}
using namespace osl;
using namespace osl::progress;
typedef NumEffectState state_t;
stat::ActivityCount activities(3); // feature οɬ 饹?
void processState(state_t& state, Move nextMove)
{
}
void processRecord(state_t& state, const osl::vector<Move>& moves)
{
for (size_t j=0;j<moves.size();j++)
{
const Player turn = state.turn();
// ʬμ֤β => ľμ꤬ˡ
if (EffectUtil::isKingInCheck(alt(turn), state)
|| (! state.isValidMove(moves[j])))
{
std::cerr << "e"; // eState;
break;
}
processState(state, moves[j]);
state.doMove(moves[j]);
}
}
int main(int argc, char **argv)
{
nice(20);
const char *program_name = argv[0];
bool error_flag = false;
extern char *optarg;
extern int optind;
char c;
size_t maxGames = 0;
const char *countFileName = 0;
while ((c = getopt(argc, argv, "HN:m:M:o:q:vh")) != EOF)
{
switch(c)
{
case 'N': maxGames = atoi(optarg);
break;
case 'o': countFileName = optarg;
break;
default: error_flag = true;
}
}
argc -= optind;
argv += optind;
if (error_flag || (! countFileName))
usage(program_name);
KisenFile kisenFile("../../data/kisen/01.kif");
if (! maxGames)
maxGames = kisenFile.size();
for (size_t i=0;i<maxGames;i++)
{
if (i % 1000 == 0)
std::cerr << "\nprocessing " << i << "-" << i+1000 << " th record\n";
if ((i % 100) == 0)
std::cerr << '.';
NumEffectState state(kisenFile.getInitialState());
const osl::vector<Move> moves=kisenFile.getMoves(i);
processRecord(state, moves);
}
activities.show(countFileName);
return 0;
}
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
|