Skip to content

Commit

Permalink
Avoid multiple connections to mongodb
Browse files Browse the repository at this point in the history
  • Loading branch information
dickreuter committed Jan 26, 2018
1 parent 3f214e5 commit fc6beea
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion compile.sh
@@ -1,5 +1,5 @@
cd poker
source activate poker_venv
source activate poker
pyinstaller main.spec
mkdir dist
mkdir dist/main/
Expand Down
2 changes: 1 addition & 1 deletion poker/main.py
Expand Up @@ -24,7 +24,7 @@
from poker.tools.mouse_mover import MouseMoverTableBased


version = 3.04
version = 3.05



Expand Down
29 changes: 22 additions & 7 deletions poker/tools/mongo_manager.py
Expand Up @@ -61,7 +61,7 @@ def get_preflop_sheet_url(self):
cursor = self.mongodb.internal.find()
c = cursor.next()
self.preflop_url = c['preflop_url']
self.preflop_url_backup='decisionmaker/preflop.xlsx'
self.preflop_url_backup = 'decisionmaker/preflop.xlsx'
return self.preflop_url, self.preflop_url_backup


Expand All @@ -75,12 +75,16 @@ def get_playable_strategy_list(self):
return l

def check_defaults(self):
if not 'initialFunds2' in self.selected_strategy: self.selected_strategy['initialFunds2'] = self.selected_strategy['initialFunds']
if not 'initialFunds2' in self.selected_strategy: self.selected_strategy['initialFunds2'] = \
self.selected_strategy['initialFunds']
if not 'use_relative_equity' in self.selected_strategy: self.selected_strategy['use_relative_equity'] = 0
if not 'use_pot_multiples' in self.selected_strategy: self.selected_strategy['use_pot_multiples'] = 0
if not 'opponent_raised_without_initiative_flop' in self.selected_strategy: self.selected_strategy['opponent_raised_without_initiative_flop'] = 1
if not 'opponent_raised_without_initiative_turn' in self.selected_strategy: self.selected_strategy['opponent_raised_without_initiative_turn'] = 1
if not 'opponent_raised_without_initiative_river' in self.selected_strategy: self.selected_strategy['opponent_raised_without_initiative_river'] = 1
if not 'opponent_raised_without_initiative_flop' in self.selected_strategy: self.selected_strategy[
'opponent_raised_without_initiative_flop'] = 1
if not 'opponent_raised_without_initiative_turn' in self.selected_strategy: self.selected_strategy[
'opponent_raised_without_initiative_turn'] = 1
if not 'opponent_raised_without_initiative_river' in self.selected_strategy: self.selected_strategy[
'opponent_raised_without_initiative_river'] = 1
if not 'always_call_low_stack_multiplier' in self.selected_strategy: self.selected_strategy[
'always_call_low_stack_multiplier'] = 8
if not 'differentiate_reverse_sheet' in self.selected_strategy: self.selected_strategy[
Expand Down Expand Up @@ -178,7 +182,18 @@ def modify_strategy(self, elementName, change):
self.modified = True


class GameLogger(object):
class Singleton(type):
def __init__(cls, name, bases, dict):
super(Singleton, cls).__init__(name, bases, dict)
cls.instance = None

def __call__(cls, *args, **kw):
if cls.instance is None:
cls.instance = super(Singleton, cls).__call__(*args, **kw)
return cls.instance


class GameLogger(object, metaclass=Singleton):
def __init__(self, connection='mongodb://guest:donald@dickreuter.com:27017/POKER'):
self.mongoclient = MongoClient('mongodb://guest:donald@dickreuter.com:27017/POKER')
self.mongodb = self.mongoclient.POKER
Expand Down Expand Up @@ -678,4 +693,4 @@ def get_flop_frequency_of_player(self, playername):
# strategy_return = L.get_strategy_return('.*', 500)
# print("Return: " + str(strategy_return))

print(L.get_neural_training_data())
print(L.get_neural_training_data())

0 comments on commit fc6beea

Please sign in to comment.