weightTracer.h
Go to the documentation of this file.
00001 /* winCountTracer.h
00002  */
00003 #ifndef GAME_PLAYING_WEIGHTTRACER_H
00004 #define GAME_PLAYING_WEIGHTTRACER_H
00005 
00006 #include "osl/game_playing/openingBookTracer.h"
00007 #include "osl/record/opening/openingBook.h"
00008 #include "osl/stl/stack.h"
00009 
00010 namespace osl
00011 {
00012   namespace record
00013   {
00014     namespace opening
00015     {
00016       class WeightedBook;
00017     }
00018   }
00019   namespace game_playing
00020   {
00024     class WeightTracer : public OpeningBookTracer
00025     {
00026     public:
00027       typedef record::opening::WeightedBook WeightedBook;
00028     protected:
00029       WeightedBook& book;
00030       int state_index, start_index;
00031       Player turn;
00032       osl::stack<int> state_stack;
00033       const osl::Move selectMoveAtRandom(const std::vector<osl::record::opening::WMove>& moves) const;
00034       const int weight_coef_for_the_initial_move;
00035       const int weight_coef;
00036     public:
00037       explicit WeightTracer(WeightedBook&, bool verbose=false, 
00038                             const int weight_coef_for_the_initial_move = 16,
00039                             const int weight_coef = 10);
00040       WeightTracer(const WeightTracer&);
00041       OpeningBookTracer* clone() const;
00042 
00043       void update(Move);
00044       const Move selectMove() const;
00045 
00046       int stateIndex() const { return state_index; }
00047       bool isOutOfBook() const;
00048       void popMove();
00049     };
00050 
00051     class DeterminateWeightTracer : public WeightTracer
00052     {
00054       const int topn;
00055     public:
00056       explicit DeterminateWeightTracer(WeightedBook& book, bool verbose=false, const int topn=1,
00057                                        const int weight_coef_for_the_initial_move = 16,
00058                                        const int weight_coef = 10)
00059         : WeightTracer(book, verbose, weight_coef_for_the_initial_move, weight_coef), 
00060           topn(topn)
00061       {} 
00062       DeterminateWeightTracer(const DeterminateWeightTracer& copy)
00063         : WeightTracer(copy), topn(copy.getTopn()) {}
00064       OpeningBookTracer* clone() const;
00065 
00066       const Move selectMove() const;
00067       int getTopn() const {return topn;}
00068     };
00069 
00070   } // namespace game_playing
00071 } // namespace osl
00072 
00073 #endif // GAME_PLAYING_WEIGHTTRACER_H
00074 // ;;; Local Variables:
00075 // ;;; mode:c++
00076 // ;;; c-basic-offset:2
00077 // ;;; coding:utf-8
00078 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines