説明を見る。00001
00002
00003 #ifndef PROGRESS_PTYPE_PROGRESS_H
00004 #define PROGRESS_PTYPE_PROGRESS_H
00005
00006 #include "osl/numEffectState.h"
00007 #include <iosfwd>
00008 namespace osl
00009 {
00010 namespace progress
00011 {
00014 class PtypeProgressTable
00015 {
00016 private:
00017 CArray<int,PTYPE_SIZE> ptype2Val;
00018 CArray2d<int,PTYPEO_SIZE,Square::SIZE> pos2Val;
00019 static const CArray<int,10> yVals;
00020 public:
00021 void init();
00022 ~PtypeProgressTable();
00023 int progress(PtypeO ptypeo,Square pos) const{
00024 return pos2Val[ptypeo-PTYPEO_MIN][pos.index()];
00025 }
00026 };
00027 extern PtypeProgressTable Ptype_Progress_Table;
00028
00029 class PtypeProgress
00030 {
00031 int val;
00032 public:
00033 explicit PtypeProgress(SimpleState const& state);
00034 int progress() const{ return val; }
00035 private:
00036 void addVal(int d) { val+=d; }
00037 public:
00038 void changeTurn() {}
00039 static int getProgress(const SimpleState& state)
00040 {
00041 const PtypeProgress progress(state);
00042 return progress.progress();
00043 }
00044 void update(const SimpleState& , Move last_move)
00045 {
00046 const PtypeO ptypeo = last_move.ptypeO();
00047 if (last_move.isDrop()) {
00048 val += Ptype_Progress_Table.progress(ptypeo,last_move.to())
00049 - Ptype_Progress_Table.progress(ptypeo,Square::STAND());
00050 return;
00051 }
00052 val += Ptype_Progress_Table.progress(ptypeo,last_move.to())
00053 - Ptype_Progress_Table.progress(ptypeo,last_move.from());
00054 Ptype ptype = last_move.capturePtype();
00055 if (ptype != PTYPE_EMPTY)
00056 val += Ptype_Progress_Table.progress(last_move.capturePtypeO(), Square::STAND())
00057 - Ptype_Progress_Table.progress(last_move.capturePtypeO(), last_move.to());
00058 }
00059
00060 bool operator==(const PtypeProgress rhs) const { return val == rhs.val; }
00061 };
00062 std::ostream& operator<<(std::ostream& os, PtypeProgress prog);
00063 }
00064 using progress::PtypeProgress;
00065 }
00066
00067
00068 #endif
00069
00070
00071
00072
00073