Two Plus Two Publishing LLC Two Plus Two Publishing LLC
 

Go Back   Two Plus Two Poker Forums > Other Topics > Programming

Notices

Programming Discussions about computer programming

Reply
 
Thread Tools Display Modes
Old 06-15-2011, 04:21 AM   #91
journeyman
 
Slick Strawberry's Avatar
 
Join Date: Nov 2010
Posts: 334
Re: ** Python Support Thread **

That sort of is what I was looking for, and helped me on the way to fix it. Since the second string I wanted to find was set beforehand, I had a problem putting it directly into the regex. However, if I use your method I can fix that. Here's how I did it in the end:

Code:
string='000101101000101101 -> 000101101110101101'
ideal='000101101110101101'
rexx = r'([01]+)\s->\s('+str(ideal)+')'
m=re.match(rexx,string)
That allows me to call each binary string separately with m.groups()[1] for instance, which is what I wanted. Now all I have to do is translate it to re.findall and I'm probably done, thanks
Slick Strawberry is offline   Reply With Quote
Old 06-15-2011, 05:08 AM   #92
old hand
 
sorrow's Avatar
 
Join Date: Apr 2008
Location: Perth, Western Australia
Posts: 1,500
Re: ** Python Support Thread **

Quote:
Originally Posted by Slick Strawberry View Post
That allows me to call each binary string separately with m.groups()[1] for instance, which is what I wanted. Now all I have to do is translate it to re.findall and I'm probably done, thanks
re.finditer() is damn useful too.

Code:
import re
string="""
000101101000101101 -> 000101101110101101
000101101000101101 -> 000101101110101101
000101101000101101 -> 000101101110101101
000101101000101101 -> 000101101110101101
000101101000101101 -> 000101101110101101
"""
ideal='000101101110101101'
rexx = r'([01]+)\s->\s('+str(ideal)+')'

for m in re.finditer(rexx, string):
    print m.groups()
sorrow is offline   Reply With Quote
Old 06-15-2011, 08:15 AM   #93
Carpal \'Tunnel
 
jjshabado's Avatar
 
Join Date: Jul 2006
Posts: 11,102
Re: ** Python Support Thread **

Quote:
Originally Posted by RoundTower View Post
I used to program in Lisp so I am well used to map, reduce, filter, lambda, but I know they are considered "unpythonic" because they were originally scheduled to be removed in Python 3. (In the end, only reduce was removed).
Cool, I didn't know that.

Maybe the lack of reduce is why Python 3 is having such a slow adoption rate...
jjshabado is offline   Reply With Quote
Old 06-15-2011, 11:58 AM   #94
old hand
 
:::grimReaper:::'s Avatar
 
Join Date: Jul 2010
Posts: 1,463
Re: ** Python Support Thread **

Hi guys,

I decided to use pypoker-eval-138.0 found here:
http://download.gna.org/pokersource/sources/
(very bottom of the page)

I'm new to python. I downloaded it, opened IDLE, loaded the pokereval.py code in the script window, and pressed F5, but in the python shell I get an error:

Traceback (most recent call last):
File "C:\Users\[my name]\Desktop\pypoker-eval-138.0\pypoker-eval-138.0\pokereval.py", line 29, in <module>
_pokereval = __import__('_pokereval_' + sys.version[0] + '_' + sys.version[2])
ImportError: No module named _pokereval_3_2

Thanks.
:::grimReaper::: is offline   Reply With Quote
Old 06-15-2011, 12:22 PM   #95
King of the sidebar
 
Neil S's Avatar
 
Join Date: Sep 2004
Location: Northern Virginia
Posts: 15,953
Re: ** Python Support Thread **

If you're new to python then you'd best learn python before trying to understand a big lump of python sources.
Neil S is offline   Reply With Quote
Old 06-15-2011, 12:24 PM   #96
grinder
 
ChazDazzle's Avatar
 
Join Date: Aug 2005
Location: Casino Night Zone
Posts: 578
Re: ** Python Support Thread **

Quote:
Originally Posted by :::grimReaper::: View Post
Hi guys,

I decided to use pypoker-eval-138.0 found here:
http://download.gna.org/pokersource/sources/
(very bottom of the page)

I'm new to python. I downloaded it, opened IDLE, loaded the pokereval.py code in the script window, and pressed F5, but in the python shell I get an error:

Traceback (most recent call last):
File "C:\Users\[my name]\Desktop\pypoker-eval-138.0\pypoker-eval-138.0\pokereval.py", line 29, in <module>
_pokereval = __import__('_pokereval_' + sys.version[0] + '_' + sys.version[2])
ImportError: No module named _pokereval_3_2

Thanks.
You're getting this particular error here because your python can't find the compiled C poker-eval libraries on your computer. pypokereval is just a wrapper for poker-eval so it needs to be installed and added to the system path as well.

That being said, pypokereval is notoriously difficult to get working on Windows. I believe gimick from the fpdb project was able to get it working once. Sorrow is another good person to ask about this. GL
ChazDazzle is offline   Reply With Quote
Old 06-15-2011, 12:48 PM   #97
old hand
 
:::grimReaper:::'s Avatar
 
Join Date: Jul 2010
Posts: 1,463
Re: ** Python Support Thread **

Interesting. So in other words I shouldn't try getting it to work?

Where else can I get a poker simulator/calculator?
Can I tell VBA or Java to run PokerStove, then I can parse the text from pokerstove.txt?

I know I can get my calculations off pro poker tools, but I want around 50,000 calculations just for one of my calculations. Is it reasonable to have my program go to their site 50,000 times at once? I'm not even sure how long this would take.
:::grimReaper::: is offline   Reply With Quote
Old 06-15-2011, 12:54 PM   #98
grinder
 
ChazDazzle's Avatar
 
Join Date: Aug 2005
Location: Casino Night Zone
Posts: 578
Re: ** Python Support Thread **

Quote:
Originally Posted by :::grimReaper::: View Post
Interesting. So in other words I shouldn't try getting it to work?

Where else can I get a poker simulator/calculator?
Can I tell VBA or Java to run PokerStove, then I can parse the text from pokerstove.txt?

I know I can get my calculations off pro poker tools, but I want around 50,000 calculations just for one of my calculations. Is it reasonable to have my program go to their site 50,000 times at once? I'm not even sure how long this would take.
This thread has source code for a number of good evaluators written in Java, C, C++, etc. http://pokerbots.org/pf3/viewtopic.p...st=0&sk=t&sd=a
ChazDazzle is offline   Reply With Quote
Old 06-19-2011, 09:23 PM   #99
S.A.G.E. Master
 
daveT's Avatar
 
Join Date: Jun 2005
Location: Why didn't I use Clojure instead?
Posts: 16,821
Re: ** Python Support Thread **

So....

I'm working on the mitocw courses. Using spoilers because I don't want to give out the answer to googleBots:

Spoiler:
daveT is offline   Reply With Quote
Old 06-19-2011, 09:45 PM   #100
Pooh-Bah
 
TheIrishThug's Avatar
 
Join Date: Jan 2005
Location: Belligerent and numerous
Posts: 5,213
Re: ** Python Support Thread **

Since test is already a boolean, you don't need to compare it to True. Python, like many scripting languages, is liberal with will evaluate to true in an if clause. However, I tend to only let booleans auto evaluate for the sake of readability.

Also, loops can have an else block that executes when the loop runs to completion. I've never actually used it, but it is exactly what you are testing for.
TheIrishThug is offline   Reply With Quote
Old 06-19-2011, 10:37 PM   #101
ɹǝʍoʇpunoɹ
 
RoundTower's Avatar
 
Join Date: Feb 2005
Location: soah made my profile
Posts: 13,926
Re: ** Python Support Thread **

going back to the "don't mess with an iterable while you are iterating through it",

it is perfectly OK (read: safe and not alarming) to do this, right?

Code:
for key, value in somedict.iteritems():
    somedict[key] = somefunction(value)
or (if we have mutable types as values):
Code:
for key, value in somedict.iteritems():
    value.somealteringfunction(key, value)
RoundTower is offline   Reply With Quote
Old 06-19-2011, 10:45 PM   #102
S.A.G.E. Master
 
daveT's Avatar
 
Join Date: Jun 2005
Location: Why didn't I use Clojure instead?
Posts: 16,821
Re: ** Python Support Thread **

At first, I was doing something similar to:

Code:
while....:
    a = x%y
    if a == 0:
        .....
    else:
        print x
which I guess is the same thing of sorts and serves as a better visual to why the 'test' primitive was in the block instead of outside it.


Not sure how you program without the else blocks. Are you saying you don't specify else or you really don't use it at all? I'm sort of in the habit of using indenting to execute the else opposed to actually writing else. But there are times it is handy. The next two projects are 'brute force algorithms,' which require some else blocks to execute I think, if for nothing else but to return Null values to the main functions. But, eh, I haven't put any effort into much more than a rudimentary start. Hopefully, this one won't take a week to do.
daveT is offline   Reply With Quote
Old 06-19-2011, 11:01 PM   #103
King of the sidebar
 
Neil S's Avatar
 
Join Date: Sep 2004
Location: Northern Virginia
Posts: 15,953
Re: ** Python Support Thread **

Spoilers won't hide the answer from bots by the way. It doesn't do a live call toget the spoiler contents. It just hides or shows a div that's already there.
Neil S is offline   Reply With Quote
Old 06-19-2011, 11:09 PM   #104
old hand
 
sorrow's Avatar
 
Join Date: Apr 2008
Location: Perth, Western Australia
Posts: 1,500
Re: ** Python Support Thread **

Quote:
Originally Posted by RoundTower View Post
going back to the "don't mess with an iterable while you are iterating through it",

it is perfectly OK (read: safe and not alarming) to do this, right?

Code:
for key, value in somedict.iteritems():
    somedict[key] = somefunction(value)
or (if we have mutable types as values):
Code:
for key, value in somedict.iteritems():
    value.somealteringfunction(key, value)
Good question, i've always assumed yes. I generally iterate on the key rather than value though.
sorrow is offline   Reply With Quote
Old 06-19-2011, 11:14 PM   #105
King of the sidebar
 
Neil S's Avatar
 
Join Date: Sep 2004
Location: Northern Virginia
Posts: 15,953
Re: ** Python Support Thread **

Yeah that should be fine.

But you don't want to be adding or deleting. That's typically going to be undefined or weird.
Neil S is offline   Reply With Quote

Reply
      

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -4. The time now is 08:49 PM.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.6.0 ©2011, Crawlability, Inc.
Copyright © 2008-2010, Two Plus Two Interactive