Open Side Menu Go to the Top
Register
Will Tipton Video Pack 2 - Solving Poker Will Tipton Video Pack 2 - Solving Poker

07-23-2014 , 04:20 PM
Will,

Have you used wxpython or know any reasons or setbacks to using it over any of your suggestions as a gui?
Will Tipton Video Pack 2 - Solving Poker Quote
07-23-2014 , 05:01 PM
Quote:
Originally Posted by Befeltingu12
Will,

Have you used wxpython or know any reasons or setbacks to using it over any of your suggestions as a gui?
I've never used wxWindows, and I haven't used anything other than Qt recently as far as gui frameworks go. My recommendation was based on perceived ease of learning and use. Laying out the gui with QDesigner is pretty much point and click, and there's not much boilerplate necessary to connect it to the rest of your code either.
Will Tipton Video Pack 2 - Solving Poker Quote
07-23-2014 , 05:16 PM
Quote:
Originally Posted by yaqh
I've never used wxWindows, and I haven't used anything other than Qt recently as far as gui frameworks go. My recommendation was based on perceived ease of learning and use. Laying out the gui with QDesigner is pretty much point and click, and there's not much boilerplate necessary to connect it to the rest of your code either.
Ok, Thanks for the response
Will Tipton Video Pack 2 - Solving Poker Quote
07-23-2014 , 05:48 PM
Quote:
Originally Posted by yaqh
The error message there says that you're trying to add a number (a float) to a NoneType which is essentially a special error-indicating thing. And it says the error is coming from a line where you're adding nfrac to the result of the getFrac function. Presumably you expect to be adding two numbers together. Please figure out which of the summands is incorrect, and then investigate why. See post #16 for more ideas about tracking down issues and providing useful debugging info.
Will Thanks, I seem to have made progress as I am not getting any errors anymore. However, when I try and display Range I get a large text block in the output that looks something like this.
Code:
'<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="260" height "260"><rect x=0" y="0" width="20" height="20" fill="#ffffff"></rect><text x=0 y=20 font-size=12 >AA</text><rect x=0" y="20" width="20" height="20" fill="#ffffff"></rect><text x=0 y=40 font-size=12 >AK</text><rect x=0" y="40" width="20" height="20" fill="#ffffff"></rect><text x=0 y=60 font-size=12 >AQ</text><rect x=0" y="60" width="20" height="20" fill="#ffffff"></rect><text x=0 y=80 font-size=12 >AJ</text><rect x=0" y="80" width="20" height="20" fill="#ffffff"></rect><text x=0 y=100 font-size=12 >AT</text>
My code for the _repr_svg_ function looks identical to yours, indents included.
Will Tipton Video Pack 2 - Solving Poker Quote
07-23-2014 , 06:33 PM
Quote:
Originally Posted by minotaurs
But i already have b instead of board in that function and i got exactly the same results with doFP() when you were doing calculations to minraise shove game. Not for a digit different. But im getting different numbers when we are doing that big tree (T)
When I checked your code, earlier on, you had this bug. Did you fix it before generating the 3 new equity arrays? This generation occurred when you defined the big tree T. Try deleting those arrays from your hard drive and run the code for defining the big tree again.
Will Tipton Video Pack 2 - Solving Poker Quote
07-23-2014 , 06:57 PM
Quote:
Originally Posted by Sevendeuceo
When I checked your code, earlier on, you had this bug. Did you fix it before generating the 3 new equity arrays? This generation occurred when you defined the big tree T. Try deleting those arrays from your hard drive and run the code for defining the big tree again.
ohh tnx didnt think of that
Will Tipton Video Pack 2 - Solving Poker Quote
07-24-2014 , 08:00 AM
So are these the right results what we were supposed to get from our big tree?


Will Tipton Video Pack 2 - Solving Poker Quote
07-24-2014 , 08:04 AM
Problem loading objects saved to to disk.

How do you save your big solutions (instances of the StrategyPair() class) to disk?

I've learned how to save objects with the used of file handlers and the pickle library. Then I saved the solution for the big T tree (which is a StrategyPair object). It saves to disk fine, though the file is 638MB big.

For loading it, I first create an object of the StrategyPair class (with T as input) and then I assign it the value: pickle.load(fileX).

(fileX is the file handler, which I have first opened for reading)

I get a memory error despite having enough memory. Might pickle not be up to the task?


On edit:

Of course, I could write a program that saves all the ranges for all the players and nodes using numpy.save(), and then loads them back into a strategy pair, but I would like to know of the is a simpler way to save and load big objects of custom classes.

Last edited by Sevendeuceo; 07-24-2014 at 08:20 AM.
Will Tipton Video Pack 2 - Solving Poker Quote
07-24-2014 , 08:08 AM
Quote:
Originally Posted by minotaurs
So are these the right results what we were supposed to get from our big tree?
It very much looks like it. I trust you now also have average EVs identical to ours?
Will Tipton Video Pack 2 - Solving Poker Quote
07-24-2014 , 08:41 AM
Just ran into another 'interesting' problem as it doesn't seem to be related to the code. In the graph visualisations video I managed to make the first tree no problem. But when I attempt to run the minrShoveTree it displays the following error message:
Quote:
C:\Users\Onno\Anaconda\lib\site-packages\IPython\core\formatters.py:239: FormatterWarning: Exception in image/png formatter: 'module' object has no attribute 'edge'
FormatterWarning,
<__main__.Tree instance at 0x078A3080>
My limited understanding so far is that something is going wrong when the formatter is attempting to display a module that is unattached to an 'edge'. Any guidance on how to proceed is appreciated.

#
This issue is now fixed after finding out that I typed Pydot.edge instead of Pydot.Edge!

Last edited by oxiej; 07-24-2014 at 08:46 AM. Reason: SOLVED
Will Tipton Video Pack 2 - Solving Poker Quote
07-24-2014 , 09:30 AM
Quote:
Originally Posted by Sevendeuceo
It very much looks like it. I trust you now also have average EVs identical to ours?
They looked exactly like the ones you sent me when u runed ur program the 1st time. Are they the right ones?
Will Tipton Video Pack 2 - Solving Poker Quote
07-24-2014 , 09:46 AM
Quote:
Originally Posted by minotaurs
They looked exactly like the ones you sent me when u runed ur program the 1st time. Are they the right ones?
But looks like they are not right coz why would BB randomly check A6, K6, Q6 on his 1st decision point. 6 isnt come yet but he bets them like he would know that 6 will come.
Will Tipton Video Pack 2 - Solving Poker Quote
07-24-2014 , 06:40 PM
Quote:
Originally Posted by minotaurs
But looks like they are not right coz why would BB randomly check A6, K6, Q6 on his 1st decision point. 6 isnt come yet but he bets them like he would know that 6 will come.
This is a good observation. But I think it is as we should expect. Both players actually know that the 6 is coming, only just not which of the two suits. That's part of the definition of the restricted game that this three represents. This foreknowledge is implemented in the doFP() algorithm when strategies are progressively optimized on the basis of full knowledge of the opponent's strategy -- and this includes knowledge of the opponent's ranges for future actions.

In order to remove this quirk, we would have to allow all possible cards to fall on the river and then, after the solution is at hand, only consider sub-ranges for scenarios we are interested in. But this would be much more computationally intensive.
Will Tipton Video Pack 2 - Solving Poker Quote
07-24-2014 , 06:48 PM
Quote:
Originally Posted by Sevendeuceo
Problem loading objects saved to to disk. [...]
Coming to think of it, using pickle to save StrategyPair objects, even if they could be loaded back, will redundantly save the EV arrays for the boards of the associated trees. So, I had better write my own saving and loading method to only save ranges and reconstruct the StrategyPair objects. I'd still be interested to know what Will does, and if pickle can work nonetheless.
Will Tipton Video Pack 2 - Solving Poker Quote
07-25-2014 , 02:03 AM
Once one is able to save and load StrategyPair objects to disk, then it becomes possible to spread calculations of fictitious play with high iteration count through multiple sessions. To this effect, I've modified the doFP() function. It turns out that only very simple changes to the code are required.

First we add two optional variables, initIter and initStrats that default to 1 and None, respectively.

initIter is the initial iteration count that we want to start from and initStrats is used to pass an initial StrategyPair object, which just is the previously saved solution that was returned as an output by the previous run of doFP(). We then test if initStrats has the value None. If it does, then we initialize the local variable strats as usual. Else, we just assign to it the value of initStrats.

Lastly, we run the main iteration loop for i in range(initIter, initIter+nIter)

I tested this with the big tree T, first running iterations 1 to 30 with the command:

solnBigTreeTo30 = doFP(T, 30, sbStartingRange, bbStartingRange)

then resumed for iterations 31 to 100 with:

solnBigTreeTo100 = doFP(T, 70, dummyInput, AnotherDummyInput, 31, solnBigTreeTo30)

It works fine. I see the average EVs being adjusted starting from the (approx) values they previously had reached. I now still need to find out how best to save and load solutions to disk.

Last edited by Sevendeuceo; 07-25-2014 at 02:14 AM.
Will Tipton Video Pack 2 - Solving Poker Quote
07-25-2014 , 04:54 AM
i found this Sevenduceo's idea very clever so i tryed to do something like that but when i splited calculation in 2 parts i got a little diferent results.
Code:
import pickle
I used this for saving

Code:
            file_obj = open('strats1.obj', 'wb')
            pickle.dump(strats, file_obj)
            file_obj.close()
and this for loading

Code:
           file_obj = open("strats1.obj",'rb')
           strats = pickle.load(file_obj)
           file_obj.close()
Is there something wrong with saving and loading methods?
Will Tipton Video Pack 2 - Solving Poker Quote
07-25-2014 , 05:11 AM
Quote:
Originally Posted by minotaurs
Is there something wrong with saving and loading methods?
Does this work for you? I had tried to save as text rather than binary but I still get the same memory error with binary while loading:

C:\Users\Pierre-Normand\Anaconda\lib\pickle.pyc in load_string(self)
960
961 def load_string(self):
--> 962 rep = self.readline()[:-1]
963 for q in "\"'": # double or single quote
964 if rep.startswith(q):

memory error:
Will Tipton Video Pack 2 - Solving Poker Quote
07-25-2014 , 05:15 AM
Quote:
Originally Posted by Sevendeuceo
Does this work for you? I had tried to save as text rather than binary but I still get the same memory error with binary while loading:

C:\Users\Pierre-Normand\Anaconda\lib\pickle.pyc in load_string(self)
960
961 def load_string(self):
--> 962 rep = self.readline()[:-1]
963 for q in "\"'": # double or single quote
964 if rep.startswith(q):

memory error:
yea this was working fine in my code except that the results were not the same as when i just runed doFP one instead of splitting it.
Will Tipton Video Pack 2 - Solving Poker Quote
07-25-2014 , 05:26 AM
Quote:
Originally Posted by minotaurs
i found this Sevenduceo's idea very clever so i tryed to do something like that but when i splited calculation in 2 parts i got a little diferent results.
Upon further experimenting I discovered that the procedure I described earlier causes the StrategyPair object passed to doFP() to be accessed by reference rather than by value, and so it is being modified by doFP(). To fix that I imported copy and used the assignment with copy.deepcopy(). Here are the first lines of my modified doFP():

Code:
def doFP(tree, nIter, sbStartingRange = None, bbStartingRange = None, initIter = 1, initStrats = None):
    
    if initStrats == None: # initialize quess at strategies for both players
        strats = StrategyPair(tree, sbStartingRange, bbStartingRange)
    else:
        strats = copy.deepcopy(initStrats)

    
    for i in range(initIter, nIter+initIter):
The rest is identical to Will's code. It now works as expected and doesn't modify the passed object.

If I do iterations from 1 to 20, and then from 1 to 10 and yet again with 11 to 20 (while passing the result of 1 to 10, and using 11 as initIter,) I get average EVs and range results identical to the first single pass.

Formerly, though, when I wouldn't copy the passed object, if I would run iterations 11 to 20 more than once with the same object initially produced by the initial run from 1 to 10 as input, the result would change because the input object would be modified by every new run from 11 to 20. I hope this isn't too unclear.

Last edited by Sevendeuceo; 07-25-2014 at 05:37 AM.
Will Tipton Video Pack 2 - Solving Poker Quote
07-25-2014 , 05:33 AM
Also, since the mixing fraction depends on the exact iteration number, make sure that if you pick up from where you were after x iterations, you must start with x+1 as the value for initIter.

For instance, you can do something like this:

Code:
solnBigTree6iter = doFP(T, 6, sbStartingRange, bbStartingRange)
and get the very same results when splitting it like this:

Code:
solnBigTree3iter = doFP(T, 3, sbStartingRange, bbStartingRange)
solnBigTree4to6 = doFP(T, 3, sbStartingRange, bbStartingRange, 4, solnBigTree3iter)

Last edited by Sevendeuceo; 07-25-2014 at 05:38 AM.
Will Tipton Video Pack 2 - Solving Poker Quote
07-25-2014 , 05:56 AM
Quote:
Originally Posted by Sevendeuceo
Also, since the mixing fraction depends on the exact iteration number, make sure that if you pick up from where you were after x iterations, you must start with x+1 as the value for initIter.

For instance, you can do something like this:

Code:
solnBigTree6iter = doFP(T, 6, sbStartingRange, bbStartingRange)
and get the very same results when splitting it like this:

Code:
solnBigTree3iter = doFP(T, 3, sbStartingRange, bbStartingRange)
solnBigTree4to6 = doFP(T, 3, sbStartingRange, bbStartingRange, 4, solnBigTree3iter)
Nice man very good job. Now the only thing what should be done is to save that solnBigTree3iter
Will Tipton Video Pack 2 - Solving Poker Quote
07-25-2014 , 06:10 AM
I tryed to do it ur way and i got this error about deepcopy. Any ideas?

Quote:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-138-1bbab9fc53bb> in <module>()
----> 1 solnBigTree4to6 = doFP(T, 3, sbStartingRange, bbStartingRange, 4, solnBigTree3iter)

<ipython-input-122-6c28b4ed333f> in doFP(tree, nIter, sbStartingRange, bbStartingRange, initIter, initStrats)
21 strats = StrategyPair(tree, sbStartingRange, bbStartingRange)
22 else:
---> 23 strats = copy.deepcopy(initStrats)
24
25

AttributeError: 'function' object has no attribute 'deepcopy'
Will Tipton Video Pack 2 - Solving Poker Quote
07-25-2014 , 06:22 AM
Quote:
Originally Posted by minotaurs
I tryed to do it ur way and i got this error about deepcopy. Any ideas?
Did you run the command:
Code:
import copy
?
Will Tipton Video Pack 2 - Solving Poker Quote
07-25-2014 , 06:52 AM
Quote:
Originally Posted by Sevendeuceo
Did you run the command:
Code:
import copy
?
oops yea i didnt before. Now its working as you said it would
Will Tipton Video Pack 2 - Solving Poker Quote
07-25-2014 , 06:59 AM
Ohh man after running

Code:
solnBigTree3iter = doFP(minrShoveTree,3, sbStartingRange, bbStartingRange)
i tryed to run

Code:
import pickle
# The file where to write the serialized string
file_obj = open('strats1.obj', 'wb')
            # Dump the data as string to file 
pickle.dump(solnBigTree3iter, file_obj)
file_obj.close()

file_obj = open("strats1.obj",'rb')
newstrats = pickle.load(file_obj)
file_obj.close()
and than

Code:
solnBigTree4to6 = doFP(minrShoveTree, 3, sbStartingRange, bbStartingRange, 4, newstrats)
And this file saving and loading combined with ur code worked. I got exactly the same results as running this doFP just 1 time
U are awesome man im telling u
Will Tipton Video Pack 2 - Solving Poker Quote

      
m