Top Level Namespace
Defined Under Namespace
Modules: Pokerstats
Instance Method Summary collapse
- #display_poker_edge_results ⇒ Object
- #display_ratio(numerator, denominator) ⇒ Object
- #display_recent_pokerstars_results(user) ⇒ Object
- #dopsfile(file, players_shown) ⇒ Object
- #getpsdata(user, time, players_shown) ⇒ Object
- #newpsfiles(user, time) ⇒ Object
-
#search_poker_edge(playername, players_shown = {}) ⇒ Object
require ‘pokerstats/player_statistics’.
Instance Method Details
#display_poker_edge_results ⇒ Object
137 138 139 140 141 142 143 144 145 146 |
# File 'bin/checkps', line 137 def display_poker_edge_results players_shown = {} $*.each do |playername| puts "Poker Edge Search for #{playername}" search_poker_edge(playername, players_shown) puts "="*80 printf "%-20s %s\n", playername, players_shown[playername] puts "="*80 end end |
#display_ratio(numerator, denominator) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'bin/checkps', line 41 def display_ratio numerator, denominator if numerator.nil? or denominator.nil? return "***" elsif denominator < 9 return "#{numerator}/#{denominator}" else return "#{(100.0 * numerator / denominator).to_i}%" end end |
#display_recent_pokerstars_results(user) ⇒ Object
131 132 133 134 135 |
# File 'bin/checkps', line 131 def display_recent_pokerstars_results user players_shown = {} getpsdata(user, Time.now - 3000, players_shown) loop {getpsdata(user, Time.now, players_shown)} end |
#dopsfile(file, players_shown) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'bin/checkps', line 51 def dopsfile(file, players_shown) return if File.directory?(file) players = {} last = nil statistics = Pokerstats::PlayerStatistics.new Pokerstats::PokerstarsFile.open(file) do |pokerstarsfile| pokerstarsfile.each do |handrecord| begin handrecord.parse statistics.record(handrecord) last = handrecord rescue Exception => e puts e. end end end return if last.nil? players = last.stats.players puts puts "=" * file.size puts file puts "=" * file.size STDOUT.sync = true printf("Searching Poker-Edge: ") players.collect {|each| Thread.new{printf("%s ", each); search_poker_edge(each, players_shown) }}.collect{|each| printf("."); each.value} printf("\n") STDOUT.sync = false puts "=" * file.size reports = statistics.reports printf "%-20s|%3s %4s %4s %5s %5s %5s|%5s %5s %5s|%5s %5s %5s | %s\n", "Screen Name", "Num", "VP$%", "PFR%", "Pre/Pos", "BAtt%", "BDef%", "CBet%", "Call", "Fold", "3Bet%", "Call", "Fold", "Poker-Edge Description" puts "--------------------|---------------------------------|-----------------|------------------|--------------------------------------------" players.each do |each| report = reports[each] # puts report.to_yaml t_hands = report[:t_hands] vpi_p = display_ratio report[:t_vpip], report[:t_hands] pfr_p = display_ratio report[:t_pfr_opportunity_taken], report[:t_pfr_opportunity] prefa = report[:t_preflop_passive].zero? ? 0.0 : [1.0 * report[:t_preflop_aggressive] / report[:t_preflop_passive],9.9].min posfa = report[:t_postflop_passive].zero? ? 0.0 : [1.0 * report[:t_postflop_aggressive] / report[:t_postflop_passive],9.9].min batt_p = display_ratio report[:t_blind_attack_opportunity_taken], report[:t_blind_attack_opportunity] bdef_p = display_ratio report[:t_blind_defense_opportunity_taken], report[:t_blind_defense_opportunity] cbet_flop_p = display_ratio report[:t_f_cbet], report[:t_f_cbet_o] call_cbet_flop_p = display_ratio report[:t_c_f_cbet], report[:t_c_f_cbet_o] fold_to_cbet_flop_p = display_ratio report[:t_f2_f_cbet], report[:t_f2_f_cbet_o] preflop_3bet_p = display_ratio report[:t_p_3bet], report[:t_p_3bet_o] call_preflop_3bet_p = display_ratio report[:t_c_p_3bet], report[:t_p_4bet_o] fold_to_preflop_3bet_p = display_ratio report[:t_f2_p_3bet], report[:t_p_4bet_o] description = players_shown[each][/\(.*\)/] description ||= "" description.gsub!("Passive", "P") description.gsub!("Aggressive", "A") description.gsub!("Tight", "T") description.gsub!("Loose", "L") players_shown[each].gsub!(/\(.*\)/, description) printf "%-20s|%3d %4s %4s %2.1f/%2.1f %5s %5s|%5s %5s %5s|%5s %5s %5s | %s\n", each, t_hands, vpi_p, pfr_p, prefa, posfa, batt_p, bdef_p, cbet_flop_p, call_cbet_flop_p, fold_to_cbet_flop_p, preflop_3bet_p, call_preflop_3bet_p,fold_to_preflop_3bet_p, players_shown[each] # puts report.to_yaml end puts "=" * file.size GC.start end |
#getpsdata(user, time, players_shown) ⇒ Object
122 123 124 125 126 127 128 129 |
# File 'bin/checkps', line 122 def getpsdata(user, time, players_shown) puts "Loading PokerStars HandHistories that have changed since #{time}" while (files = newpsfiles(user, time)).empty? sleep 1 end puts files.inspect files.each {|each| dopsfile(each, players_shown)} end |
#newpsfiles(user, time) ⇒ Object
118 119 120 |
# File 'bin/checkps', line 118 def newpsfiles(user, time) Dir["/Users/#{user}/Library/Application Support/PokerStars/HandHistory/**/*"].select{|each| File.mtime(each) > time} end |
#search_poker_edge(playername, players_shown = {}) ⇒ Object
require ‘pokerstats/player_statistics’
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 |
# File 'bin/checkps', line 13 def search_poker_edge(playername, players_shown = {}) return if players_shown[playername] escaped_playername = URI.escape(playername).gsub(/["'\[\]]/,'\\\\\&').gsub(/[\[\]]/,'\\\\\\\\\&') result = `curl -s http://www.poker-edge.com/whoami.php?site=Stars\\&name=#{escaped_playername}` if result =~ /(Pre-Flop Tend.*\n)/ verbose = $1.gsub(/<\/?[^>]*>/, "") if verbose =~ /Pre-Flop Tendency: ([^-]*) -/ preflop = $1 else preflop = "N/A" end else preflop = "N/A (data error)" end if result =~ /(Player Type.*\n)/ verbose = $1.gsub(/<\/?[^>]*>/, "") if verbose =~ /[Yy]ou are a ([^(]* \(.*\))/ player_type = $1 else player_type = "" end else player_type = "" end players_shown[playername] = preflop players_shown[playername] += " " + player_type unless player_type.empty? end |