どうぶつしょうぎの完全解析をするGUI
@@ -0,0 +1,31 @@ | ||
1 | +#include <iostream> | |
2 | +#include <string> | |
3 | +#include <fstream> | |
4 | + | |
5 | +using namespace std; | |
6 | +void seekandread(int index); | |
7 | + | |
8 | +ifstream ifs2; | |
9 | +int main(int ac,char **ag){ | |
10 | + | |
11 | + ifs2.open("winLossCount.dat"); | |
12 | + // ifs2.clear(); | |
13 | + for(int i=0;i<=100;i++){ | |
14 | + ifs2.clear(); | |
15 | + seekandread(i); | |
16 | + } | |
17 | + ifs2.close(); | |
18 | +} | |
19 | + | |
20 | +void seekandread(int index){ | |
21 | + ifs2.seekg(index,ios_base::beg); | |
22 | + | |
23 | +std:cout<<"index="<<index<<";"<<"ifs2.tellg()=\""<<ifs2.tellg()<<"\""; | |
24 | + if (ifs2.bad()) std::cout << "bad\n" << std::endl; | |
25 | + if (ifs2.eof()) std::cout << "eof\n" << std::endl; | |
26 | + if (ifs2.fail()) std::cout << "fail\n" << std::endl; | |
27 | + if (ifs2.good()) std::cout << "good\n" << std::endl; | |
28 | + | |
29 | + unsigned char ret; | |
30 | + ifs2.read((char *)&ret,1); | |
31 | +} |
@@ -1,41 +1,48 @@ | ||
1 | -#ifndef _WIN_LOSE_TABLE_H | |
2 | -#define _WIN_LOSE_TABLE_H | |
3 | -#include "dobutsu.h" | |
4 | -#include "allStateTable.h" | |
5 | - | |
6 | -class WinLoseTable { | |
7 | - AllStateTable const& allS; | |
8 | - vChar winLose; | |
9 | - vuChar winLoseCount; | |
10 | - mutable ifstream ifs1,ifs2; | |
11 | -public: | |
12 | - WinLoseTable(AllStateTable const& allS_,string const& wlName, string const& wlcName,bool lazy=true); | |
13 | - ~WinLoseTable(); | |
14 | - AllStateTable const& getAllS() const { return allS; } | |
15 | - int getWinLose(size_t index) const { | |
16 | - if(winLose.size()>0){ | |
17 | - return winLose[index]; | |
18 | - } | |
19 | - else{ | |
20 | - ifs1.seekg(index,ios_base::beg); | |
21 | - char ret; | |
22 | - ifs1.read((char *)&ret,1); | |
23 | - return ret; | |
24 | - } | |
25 | - } | |
26 | - int getWinLoseCount(size_t index) const { | |
27 | - if(winLoseCount.size()>0){ | |
28 | - return winLoseCount[index]; | |
29 | - } | |
30 | - else{ | |
31 | - ifs2.seekg(index,ios_base::beg); | |
32 | - unsigned char ret; | |
33 | - ifs2.read((char *)&ret,1); | |
34 | - return ret; | |
35 | - } | |
36 | - } | |
37 | - int getWinLose(State const& s, int& wlc) const; | |
38 | - int getWinLose(State const& s, Move const& m,int& wlc) const; | |
39 | - void showSequence(State const& s) const; | |
40 | -}; | |
41 | -#endif | |
1 | +#ifndef _WIN_LOSE_TABLE_H | |
2 | +#define _WIN_LOSE_TABLE_H | |
3 | +#include "dobutsu.h" | |
4 | +#include "allStateTable.h" | |
5 | + | |
6 | +class WinLoseTable { | |
7 | + AllStateTable const& allS; | |
8 | + vChar winLose; | |
9 | + vuChar winLoseCount; | |
10 | + mutable ifstream ifs1,ifs2; | |
11 | +public: | |
12 | + WinLoseTable(AllStateTable const& allS_,string const& wlName, string const& wlcName,bool lazy=true); | |
13 | + ~WinLoseTable(); | |
14 | + AllStateTable const& getAllS() const { return allS; } | |
15 | + int getWinLose(size_t index) const { | |
16 | + if(winLose.size()>0){ | |
17 | + return winLose[index]; | |
18 | + } | |
19 | + else{ | |
20 | + // ifs1.clear(); | |
21 | + ifs1.seekg(index,ios_base::beg); | |
22 | + | |
23 | + char ret; | |
24 | + ifs1.read((char *)&ret,1); | |
25 | + return ret; | |
26 | + } | |
27 | + } | |
28 | + int getWinLoseCount(size_t index) const { | |
29 | + if(winLoseCount.size()>0){ | |
30 | + return winLoseCount[index]; | |
31 | + } | |
32 | + else{ | |
33 | + // ifs2.clear(); | |
34 | + ifs2.seekg(index,ios_base::beg); | |
35 | + unsigned char ret; | |
36 | + ifs2.read((char *)&ret,1); | |
37 | + if(ifs2.eof()){ | |
38 | + ret = 0x1A; | |
39 | + ifs2.clear(); | |
40 | + } | |
41 | + return ret; | |
42 | + } | |
43 | + } | |
44 | + int getWinLose(State const& s, int& wlc) const; | |
45 | + int getWinLose(State const& s, Move const& m,int& wlc) const; | |
46 | + void showSequence(State const& s) const; | |
47 | +}; | |
48 | +#endif |