All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
treePredictor.cc
Go to the documentation of this file.
1 /* treePredictor.cc
2  */
4 
5 bool osl::threatmate::TreePredictor::predict(const NumEffectState& state,
6  const Move move){
7  const Player turn = alt(state.turn());
8  osl::progress::ml::NewProgress tprogress(state);
9  const int progress = (tprogress.progressAttack(alt(turn)).value());
10 
11  if (Neighboring8Direct::hasEffect(state, newPtypeO(turn, move.ptype()), move.to(), state.kingSquare(alt(turn)))){
12  King8Info K(state.Iking8Info(alt(turn)));
13  if(progress>=5 || K.dropCandidate()) return true;
14  if(turn==BLACK)
15  return K.hasMoveCandidate<BLACK>(state);
16  else
17  return K.hasMoveCandidate<WHITE>(state);
18  }
19  if (progress > 5 ) {
20  if (! isPiece( move.capturePtype() ) )
21  return false;
22  if ( isMajor(move.capturePtype()) ||
23  (move.capturePtype() == SILVER) ||
24  (move.capturePtype() == PSILVER)||
25  (move.capturePtype() == GOLD) )
26  return true;
27  }
28  return false;
29 }
30 double osl::threatmate::TreePredictor::probability(const NumEffectState& state,
31  const Move move){
32  const Player turn = alt(state.turn());
33  osl::progress::ml::NewProgress tprogress(state);
34  const int progress = (tprogress.progressAttack(alt(turn)).value());
35  if (Neighboring8Direct::hasEffect(state, newPtypeO(turn, move.ptype()), move.to(), state.kingSquare(alt(turn)))){
36  if (progress > 4) {
37  if (progress > 5)
38  return 0.87601;
39  return 0.69349;
40  }
41  King8Info K(state.Iking8Info(alt(turn)));
42  if (K.dropCandidate() )
43  return 0.5637;
44  if(turn==BLACK){
45  if(K.hasMoveCandidate<BLACK>(state))
46  return 0.89933;
47  }
48  else if(K.hasMoveCandidate<WHITE>(state))
49  return 0.89933;
50  return 0.22403;
51  }
52  if (progress < 5 )
53  return 0.041633;
54  if (move.capturePtype() == GOLD)
55  return 0.81872;
56  if (move.capturePtype() == SILVER)
57  return 0.78608;
58  if (move.capturePtype() == ROOK)
59  return 0.83592;
60  if (move.capturePtype() == BISHOP)
61  return 0.84542;
62  return 0.14094;
63 }
64 // ;;; Local Variables:
65 // ;;; mode:c++
66 // ;;; c-basic-offset:2
67 // ;;; End: