コード例 #1
0
ファイル: analyse.py プロジェクト: arkravitz/range-vs-range
 def _create_afei(self, combo, is_agg=False, is_pas=False, is_fol=False):
     """
     Create an AnalaysisFoldEquityItem for a particular combo in Hero's range
     """
     afei = AnalysisFoldEquityItem()
     afei.gameid = self.gameid
     afei.order = self.order
     lower_card, higher_card = sorted(combo)
     afei.higher_card = higher_card.to_mnemonic()
     afei.lower_card = lower_card.to_mnemonic()
     afei.is_aggressive = is_agg
     afei.is_passive = is_pas
     afei.is_fold = is_fol
     afei.fold_ratio = 1.0
     for _folder, fold_range, nonfold_range in self.folds:
         fold_size = len(
             fold_range.generate_options_unweighted(self.board +
                                                    list(combo)))
         nonfold_size = len(
             nonfold_range.generate_options_unweighted(self.board +
                                                       list(combo)))
         folder_fold_ratio = 1.0 * fold_size / (fold_size + nonfold_size)
         afei.fold_ratio *= folder_fold_ratio
         # product of everyone's fold ratios = how often we take it down
     nonfold_ratio = 1.0 - afei.fold_ratio
     afei.immediate_result = afei.fold_ratio * self.pot_before_bet -  \
         nonfold_ratio * self.bet_cost
     if nonfold_ratio and self.street != RIVER:
         afei.semibluff_ev = -afei.immediate_result / nonfold_ratio
         afei.semibluff_equity = afei.semibluff_ev / self.pot_if_called
     else:
         afei.semibluff_ev = None
         afei.semibluff_equity = None
     return afei
コード例 #2
0
 def _create_afei(self, combo, is_agg=False, is_pas=False, is_fol=False):
     """
     Create an AnalaysisFoldEquityItem for a particular combo in Hero's range
     """
     afei = AnalysisFoldEquityItem()
     afei.gameid = self.gameid
     afei.order = self.order
     lower_card, higher_card = sorted(combo)
     afei.higher_card = higher_card.to_mnemonic()
     afei.lower_card = lower_card.to_mnemonic()
     afei.is_aggressive = is_agg
     afei.is_passive = is_pas
     afei.is_fold = is_fol
     afei.fold_ratio = 1.0
     for _, fold_range, nonfold_range in self.folds:
         fold_size = len(fold_range.generate_options(
             self.board + list(combo)))
         nonfold_size = len(nonfold_range.generate_options(
             self.board + list(combo)))
         folder_fold_ratio = 1.0 * fold_size / (fold_size + nonfold_size)
         afei.fold_ratio *= folder_fold_ratio
         # product of everyone's fold ratios = how often we take it down
     nonfold_ratio = 1.0 - afei.fold_ratio
     afei.immediate_result = afei.fold_ratio * self.pot_before_bet -  \
         nonfold_ratio * self.bet_cost
     if nonfold_ratio and self.street != RIVER:
         afei.semibluff_ev = -afei.immediate_result / nonfold_ratio
         afei.semibluff_equity = afei.semibluff_ev / self.pot_if_called
     else:
         afei.semibluff_ev = None
         afei.semibluff_equity = None
     return afei
コード例 #3
0
ファイル: dump.py プロジェクト: arkravitz/range-vs-range
def write_analysis_fold_equity_items(session, afeis):
    """ Write AnalysisFoldEquityItem table from memory into DB """
    for gameid, order, higher_card, lower_card, is_aggressive, is_passive,  \
            is_fold, fold_ratio, immediate_result, semibluff_ev,  \
            semibluff_equity in afeis:
        afei = AnalysisFoldEquityItem()
        session.add(afei)
        afei.gameid = gameid
        afei.order = order
        afei.higher_card = higher_card
        afei.lower_card = lower_card
        afei.is_aggressive = is_aggressive
        afei.is_passive = is_passive
        afei.is_fold = is_fold
        afei.fold_ratio = fold_ratio
        afei.immediate_result = immediate_result
        afei.semibluff_ev = semibluff_ev
        afei.semibluff_equity = semibluff_equity