Go to the documentation of this file.00001
00002
00003 #include "osl/eval/progressEval.h"
00004 #include "osl/eval/ppair/piecePairPieceEval.h"
00005 #include "osl/record/csaRecord.h"
00006 #include "osl/state/numEffectState.h"
00007 #include "osl/oslConfig.h"
00008 #include <iostream>
00009 #include <iomanip>
00010 #include <cstdlib>
00011 #include <cstdio>
00012 #include <unistd.h>
00013
00014 using namespace osl;
00015 using namespace osl::eval;
00016
00017 void usage(const char *prog)
00018 {
00019 using namespace std;
00020 cerr << "Usage: " << prog << " csa-filename"
00021 << endl;
00022 exit(1);
00023 }
00024
00025 void show(const char *filename);
00026 int verbose = 0;
00027 int max_progress = 8;
00028
00029 int main(int argc, char **argv)
00030 {
00031 const char *program_name = argv[0];
00032 bool error_flag = false;
00033
00034
00035 extern int optind;
00036 char c;
00037 while ((c = getopt(argc, argv, "vh")) != EOF)
00038 {
00039 switch(c)
00040 {
00041 default: error_flag = true;
00042 }
00043 }
00044 argc -= optind;
00045 argv += optind;
00046
00047 if (error_flag)
00048 usage(program_name);
00049
00050 eval::ProgressEval::setUp();
00051 eval::PiecePairPieceEval::setUp();
00052
00053 for (int i=0; i<argc; ++i)
00054 {
00055 show(argv[i]);
00056 }
00057 }
00058
00059 void show(const NumEffectState& state)
00060 {
00061 const progress::Effect5x3 progress(state);
00062 if (progress.progress16().value() > max_progress)
00063 return;
00064 if (verbose)
00065 std::cout << state;
00066 const eval::ProgressEval eval(state);
00067 const PieceEval piece(state);
00068 const eval::PiecePairPieceEval ppair(state);
00069
00070 if (verbose)
00071 std::cout << "progress piece ppair endgame safety pieceadjust total\n";
00072 std::cout << progress.progress16().value()
00073 << " " << piece.value() << " " << ppair.value()
00074 << " " << eval.endgameValue()
00075 << " " << eval.attackDefenseBonus() << " " << eval.minorPieceValue()
00076 << " " << eval.value() << "\n";
00077 }
00078
00079 void show(const char *filename)
00080 {
00081 CsaFile file(filename);
00082 const vector<osl::Move> moves = file.getRecord().getMoves();
00083 NumEffectState state(file.getInitialState());
00084 for (unsigned int i=0; i<moves.size(); i++)
00085 {
00086 show(state);
00087 const Move m = moves[i];
00088 state.makeMove(m);
00089 }
00090 show(state);
00091 }
00092
00093
00094
00095
00096
00097