From: yan <yan...@gm...> - 2014-10-01 18:05:02
|
Hi, I want to add some stats that I miss, so I installed eclipse, pydev, anaconda, winpaths etc and I can run the proyect in eclipse, so yesterday I spent some time looking at the code and a python tutorial, and today I start to write some things. First time with python, so it feels a like weird, and mostly I doubt if I know what Im doing so... I decided to write to ask for some advice, BTW English is not my first language, so excuse me if I write something wrong or whatever Well, the first stats that I would love to have in the hud is positional unopened preflop raises, sometimes called raise first in, but I saw that rfi count when the player does raise over limpers, and I want just when a player raises and previusly all actions where folds(if any). So i want to add UOPFR for EP, MP, CO, BT and SB First in DerivedStats.py, in _buildStatsInitializer(), I inicialiced the variables like: init['UOPFRChanceEP'] = False init['UOPFREP'] = False I call a method to calculate the stats in assembleHandsPlayers like this self.calcUOPFR(hand) and I write it down: def calcUOPFR(self, hand): """Fills UOPFRChance|UOPFR for all positions UOPFR - preflop raise in an unopened hand(no limpers and no raisers before the raiser)""" if hand.gametype['base'] != 'stud': for action in hand.actions[hand.actionStreets[1]]: pname=action[0] act=action[1] player_stats = self.handsplayers.get(pname) if player_stats['sitout']: continue #positions: 5=EP,2=MP,1=CO,0=BT,-1=SB posn = player_stats['position'] #todo: comment this print print "\naction:", action[0], posn, type(posn), act if posn == 5: player_stats['UOPFRChanceEP'] = True if act == 'raises': player_stats['UOPFREP'] = True break elif posn == 2: player_stats['UOPFRChanceMP'] = True if act == 'raises': player_stats['UOPFRMP'] = True break elif posn == 1: player_stats['UOPFRChanceCO'] = True if act == 'raises': player_stats['UOPFRCO'] = True break elif posn == 0: player_stats['UOPFRChanceBT'] = True if act == 'raises': player_stats['UOPFRBT'] = True break elif posn == -1: player_stats['UOPFRChanceSB'] = True if act == 'raises': player_stats['UOPFRSB'] = True break if act != 'folds': break then I add the stats in database.py and I start looking for places where I needed to write code in SQL.py, so I'm just copying what I see that was done with other stats like UOPFRChanceEP BOOLEAN, or UOPFRChanceEP INT, to add the colums or sum(hc.UOPFRChanceEP) AS UOPFRChanceEP, where I see that the is similar stuff for other stats I also add this where I found similar code, but I don't know for what its used: cast(hp2.UOPFRChanceEP as <signed>integer) AS UOPFRChanceEP, cast(hp2.UOPFRChanceMP as <signed>integer) AS UOPFRChanceMP, cast(hp2.UOPFRChanceCO as <signed>integer) AS UOPFRChanceCO, cast(hp2.UOPFRChanceBT as <signed>integer) AS UOPFRChanceBT, cast(hp2.UOPFRChanceSB as <signed>integer) AS UOPFRChanceSB, cast(hp2.UOPFREP as <signed>integer) AS UOPFREP, cast(hp2.UOPFRMP as <signed>integer) AS UOPFRMP, cast(hp2.UOPFRCO as <signed>integer) AS UOPFRCO, cast(hp2.UOPFRBT as <signed>integer) AS UOPFRBT, cast(hp2.UOPFRSB as <signed>integer) AS UOPFRSB, and I do the calculations like this where I saw that they need to be ,case when sum(cast(hp.UOPFRChanceEP as <signed>integer)) = 0 then -999 else 100.0 * sum(cast(hp.UOPFREP as <signed>integer)) / sum(cast(hp.UOPFRChanceEP as <signed>integer)) end AS uopfrep I would much apreciate any kind of advice, if you know that I need to add code in some other modules for example, or if you realize that Im doing something wrong... I could attach some files o upload it to github if you think it would help |