| 51 | } |
| 52 | |
| 53 | const vector<float> CfrPlusTrainable::getcurrentStrategy() { |
| 54 | if(this->r_plus_sum.empty()){ |
| 55 | fill(retval.begin(),retval.end(),1.0 / this->action_number); |
| 56 | }else { |
| 57 | for (int action_id = 0; action_id < action_number; action_id++) { |
| 58 | for (int private_id = 0; private_id < this->card_number; private_id++) { |
| 59 | int index = action_id * this->card_number + private_id; |
| 60 | if(this->r_plus_sum[private_id] != 0) { |
| 61 | retval[index] = this->r_plus[index] / this->r_plus_sum[private_id]; |
| 62 | }else{ |
| 63 | retval[index] = 1.0 / this->action_number; |
| 64 | } |
| 65 | if(this->r_plus[index] != this->r_plus[index]) throw runtime_error("nan found"); |
| 66 | /* |
| 67 | if(this.r_plus_sum[private_id] == 0) |
| 68 | { |
| 69 | System.out.println("Exception regret status, r_plus_sum == 0:"); |
| 70 | System.out.println(String.format("r plus length %s , card num %s",r_plus.length,this.card_number)); |
| 71 | for(int i = index % this.card_number;i < this.r_plus.length;i += this.card_number){ |
| 72 | System.out.print(String.format("%s:%s ",i,this.r_plus[i])); |
| 73 | if(i == index){ |
| 74 | System.out.print("[current]"); |
| 75 | } |
| 76 | } |
| 77 | System.out.println(); |
| 78 | System.out.println(); |
| 79 | throw new RuntimeException(); |
| 80 | } |
| 81 | */ |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | return retval; |
| 86 | } |
| 87 | |
| 88 | void CfrPlusTrainable::updateRegrets(const vector<float>& regrets, int iteration_number, const vector<float>& reach_probs) { |
| 89 | this->regrets = regrets; |
no test coverage detected