forked from Fossana/cplusplus-cfr-poker-solver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRangeManager.h
More file actions
71 lines (60 loc) · 2.22 KB
/
RangeManager.h
File metadata and controls
71 lines (60 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef RANGE_MANAGER_H
#define RANGE_MANAGER_H
#include <vector>
#include <unordered_map>
#include <set>
#include "Hand.h"
#include "card_utility.h"
#include <iostream>
#include <string>
#include "HandEvaluator.h"
using std::vector;
using std::set;
using std::unordered_map;
using std::string;
class RangeManager
{
private:
vector<Hand> p1StartingHands;
vector<Hand> p2StartingHands;
unordered_map<int, vector<Hand>> p1Ranges;
unordered_map<int, vector<Hand>> p2Ranges;
unordered_map<int, vector<int>> p1ReachProbsMapping;
unordered_map<int, vector<int>> p2ReachProbsMapping;
HandEvaluator* handEvaluator;
void quickSort(vector<Hand>& hands, vector<int>& handMap, int low, int high);
int partition(vector<Hand>& hands, vector<int>& handMap, int low, int high);
static bool compare_hands(Hand h1, Hand h2);
void initialize_starting_range(int player, string startingHands, uint8_t initialBoard[5]);
inline int get_key(uint8_t board[5])
{
if (!board_has_turn(board))
return 100000000 * (board[0] + 1) +
1000000 * (board[1] + 1) +
10000 * (board[2] + 1);
else if (!board_has_river(board))
return
100000000 * (board[0] + 1) +
1000000 * (board[1] + 1) +
10000 * (board[2] + 1) +
100 * (board[3] + 1);
return 100000000 * (board[0] + 1) +
1000000 * (board[1] + 1) +
10000 * (board[2] + 1) +
100 * (board[3] + 1) +
(board[4] + 1);
}
public:
RangeManager(string p1StartingHands, string p2StartingHands, uint8_t initialBoard[5]);
void initialize_ranges(int player, uint8_t initialBoard[5]);
void initialize_reach_probs_mapping(int player, uint8_t initialBoard[5]);
vector<float> get_reach_probs(int player, uint8_t board[5], vector<float>& reachProbs);
vector<float> get_initial_reach_probs(int player);
int RangeManager::get_num_hands(int player, uint8_t board[5]);
vector<Hand>& get_starting_hands(int player);
unordered_map<int, vector<int>>& get_reach_probs_mappings(int player);
unordered_map<int, vector<Hand>>& get_ranges(int player);
vector<Hand>& get_hands(int player, uint8_t board[5]);
vector<int>& get_reach_probs_mapping(int player, uint8_t board[5]);
};
#endif