treePredictor.cc
Go to the documentation of this file.
00001 /* treePredictor.cc
00002  */
00003 #include "osl/threatmate/treePredictor.h"
00004 
00005 bool osl::threatmate::TreePredictor::predict(const NumEffectState& state, 
00006                                                const Move move){
00007   const Player turn = alt(state.turn());
00008   osl::progress::ml::NewProgress tprogress(state);
00009   const int progress = (tprogress.progressAttack(alt(turn)).value());
00010 
00011   if (Neighboring8Direct::hasEffect(state, newPtypeO(turn, move.ptype()), move.to(), state.kingSquare(alt(turn)))){
00012     King8Info K(state.Iking8Info(alt(turn)));
00013     if(progress>=5 || K.dropCandidate()) return true;
00014     if(turn==BLACK)
00015       return K.hasMoveCandidate<BLACK>(state);
00016     else
00017       return K.hasMoveCandidate<WHITE>(state);
00018   }
00019   if (progress > 5 ) {
00020     if (! isPiece( move.capturePtype() ) )
00021       return false;
00022     if ( isMajor(move.capturePtype())    ||
00023          (move.capturePtype() == SILVER) ||
00024          (move.capturePtype() == PSILVER)||
00025          (move.capturePtype() == GOLD) )
00026       return true;
00027   }
00028   return false;
00029 }
00030 double osl::threatmate::TreePredictor::probability(const NumEffectState& state,
00031                                                    const Move move){
00032   const Player turn = alt(state.turn());
00033   osl::progress::ml::NewProgress tprogress(state);
00034   const int progress = (tprogress.progressAttack(alt(turn)).value());
00035   if (Neighboring8Direct::hasEffect(state, newPtypeO(turn, move.ptype()), move.to(), state.kingSquare(alt(turn)))){
00036     if (progress > 4) {
00037       if (progress > 5)
00038         return 0.87601;
00039       return 0.69349;
00040     }
00041     King8Info K(state.Iking8Info(alt(turn)));
00042     if (K.dropCandidate() )
00043       return 0.5637;
00044     if(turn==BLACK){
00045       if(K.hasMoveCandidate<BLACK>(state))
00046         return 0.89933;
00047     }
00048     else if(K.hasMoveCandidate<WHITE>(state))
00049       return 0.89933;
00050     return 0.22403;
00051   }
00052   if (progress < 5 )
00053     return 0.041633;
00054   if (move.capturePtype() == GOLD)
00055     return 0.81872;
00056   if (move.capturePtype() == SILVER)
00057     return 0.78608;
00058   if (move.capturePtype() == ROOK)
00059     return 0.83592;
00060   if (move.capturePtype() == BISHOP)
00061     return 0.84542;
00062   return 0.14094;
00063 }
00064 // ;;; Local Variables:
00065 // ;;; mode:c++
00066 // ;;; c-basic-offset:2
00067 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines