My Project
csa.h
Go to the documentation of this file.
1 #ifndef OSL_CSA_H
2 #define OSL_CSA_H
3 
4 #include "osl/numEffectState.h"
5 #include <vector>
6 #include <string>
7 #include <iosfwd>
8 #include <stdexcept>
9 namespace osl
10 {
15  namespace csa
16  {
17  struct CsaIOError : public std::runtime_error
18  {
19  CsaIOError(const std::string& w) : std::runtime_error(w) {
20  }
21  };
22 
23  const Move strToMove(const std::string& s,const SimpleState& st);
24  Player charToPlayer(char c);
25  const Square strToPos(const std::string& s);
26  Ptype strToPtype(const std::string& s);
27 
28  const std::string show(Move);
29  const std::string fancyShow(Move);
30  const std::string show(Square);
31  const std::string show(Ptype);
32  const std::string show(Piece);
33  const std::string show(Player);
34  const std::string show(const Move *first, const Move *last);
35 
36  const std::string show(Move, std::string& buf);
37  const std::string show(Square, std::string& buf, size_t offset=0);
38  const std::string show(Ptype, std::string& buf, size_t offset=0);
39  const std::string show(Player, std::string& buf, size_t offset=0);
40  } // namespace csa
41 
43  {
45  std::vector<Move> moves;
46  const NumEffectState& initialState() const { return initial_state; }
47  };
48 
49  namespace csa
50  {
52  {
54  public:
55  CsaFileMinimal(const std::string& filename);
56  CsaFileMinimal(std::istream& is);
57  virtual ~CsaFileMinimal();
58  RecordMinimal load() const { return record; }
59  std::vector<Move> moves() const { return load().moves; }
60  const NumEffectState& initialState() const { return load().initialState(); }
61  protected:
63  void load(std::istream&);
64  public:
65  static bool parseLine(SimpleState&, RecordMinimal&, std::string element,
67  };
68 
69  class CsaString : public CsaFileMinimal
70  {
71  public:
72  CsaString(const std::string&);
74  };
75  }
76  using csa::CsaIOError;
77  using csa::CsaFileMinimal;
78  using csa::CsaString;
79 } // namespace osl
80 #endif /* _CSA_H */
81 // ;;; Local Variables:
82 // ;;; mode:c++
83 // ;;; c-basic-offset:2
84 // ;;; End:
osl::Square
Definition: basic_type.h:532
osl::csa::CsaIOError::CsaIOError
CsaIOError(const std::string &w)
Definition: csa.h:19
osl::RecordMinimal::initialState
const NumEffectState & initialState() const
Definition: csa.h:46
osl::csa::fancyShow
const std::string fancyShow(Move)
Definition: csa.cc:141
osl::csa::CsaFileMinimal::~CsaFileMinimal
virtual ~CsaFileMinimal()
Definition: csa.cc:216
osl::RecordMinimal::initial_state
NumEffectState initial_state
Definition: csa.h:44
osl::csa::strToPos
const Square strToPos(const std::string &s)
Definition: csa.cc:28
osl::Move
圧縮していない moveの表現 .
Definition: basic_type.h:1052
osl::csa::CsaString
Definition: csa.h:70
osl::SimpleState
Definition: simpleState.h:35
osl::Ptype
Ptype
駒の種類を4ビットでコード化する
Definition: basic_type.h:84
osl::csa::show
const std::string show(Move)
Definition: csa.cc:133
osl::csa::CsaFileMinimal::initialState
const NumEffectState & initialState() const
Definition: csa.h:60
osl::RecordMinimal::moves
std::vector< Move > moves
Definition: csa.h:45
osl::Piece
駒.
Definition: basic_type.h:788
osl::csa::strToMove
const Move strToMove(const std::string &s, const SimpleState &st)
Definition: csa.cc:48
osl::csa::CsaFileMinimal::record
RecordMinimal record
Definition: csa.h:53
osl::csa::CsaString::CsaString
CsaString(const std::string &)
Definition: csa.cc:325
osl::csa::CsaIOError
Definition: csa.h:18
osl::NumEffectState
利きを持つ局面
Definition: numEffectState.h:34
osl::csa::CsaFileMinimal::parseLine
static bool parseLine(SimpleState &, RecordMinimal &, std::string element, CArray< bool, 9 > &)
Definition: csa.cc:247
osl::csa::charToPlayer
Player charToPlayer(char c)
Definition: csa.cc:18
osl::csa::strToPtype
Ptype strToPtype(const std::string &s)
Definition: csa.cc:38
osl::csa::CsaString::initialState
NumEffectState initialState() const
Definition: csa.h:73
osl::csa::CsaFileMinimal
Definition: csa.h:52
std
Definition: basic_type.h:1353
osl::csa::CsaFileMinimal::CsaFileMinimal
CsaFileMinimal()
Definition: csa.h:62
osl::Player
Player
Definition: basic_type.h:8
osl::csa::CsaFileMinimal::load
RecordMinimal load() const
Definition: csa.h:58
numEffectState.h
osl::csa::CsaFileMinimal::moves
std::vector< Move > moves() const
Definition: csa.h:59
osl::CArray
Definition: container.h:20
osl
Definition: additionalEffect.h:6
osl::RecordMinimal
Definition: csa.h:43