Open Side Menu Go to the Top
Register
Coding a hand history translator - getting started - seeking experienced advice ??? Coding a hand history translator - getting started - seeking experienced advice ???

10-31-2013 , 03:18 AM
I often use regexp in several situations. So I already knew it quite well. And its quite easy to use. Thera are alot of online regexp tester and the syntax is the same (difference might only be on masking special chars).
Learning about parsing came to me when I was thinking how I would put a handhistory in form of object orientated software sructures and how to fill it. Its no big deal. Just make sure to seperate the data logic from the presentation layer.
Coding a hand history translator - getting started - seeking experienced advice ??? Quote
11-20-2013 , 02:48 PM
@ Kreatief - That's interesting. I finally did find one intro tutorial on RegExes. I didn't understand much of it 'cause my head has been exhausted trying to figure out some OO concepts where I left off learning the last time. I'm definitely going to come back to RegExes later, though. When they stop looking like hieroglyphics to me, I think they'll help speed up the process quite a bit.

@ Phaze_mafiamaniac - Thanks for that link. I was thinking something along those lines, converting the Excel file to *.csv or something similar until I seen the output of it. Since the code will require about the same logic no matter what the source input is, I'm going to just read in the small *.xlsx files and go from there. Before I got started with Python, I wasn't sure how to go about it all, but now that I've learned enough to read/write *.xlsx files, I'm going to stick with that way, just so I also learn a few ins and outs of openpyxl and/or xlrd.

I was going to just continue on with this thread, but it's gotten kind've outdated and unrelated to where I'm currently at with the prog, so I think I'm going to put some code up in another thread to see if I can get some pointers on it.
Coding a hand history translator - getting started - seeking experienced advice ??? Quote
11-20-2013 , 03:02 PM
On second thought, I might as well not waste a new thread, and just keep on using this one. I've listed some Python code below, and a small description w/ questions following that. I'll try to post a more detailed follow up post to this one later, but I've been either burnt out or concentrating on adding to the program so I don' know if I'll have much time/energy left for that.

SomeGUI.py
Code:
import sys
import os
from Tkinter import *
import tkMessageBox

tempString = "Click on the \"TRANSLATE\" button to begin.  Or click the \"X\" in the upper-right corner to close this program."

class HhtStart_Window(Tk):
    def __init__(self, parent):
        Tk.__init__(self, parent)
        self.parent = parent
        self.initialize()

    def initialize(self):
        self.geometry("999x650+30+20")

        HhtswMessage = Message(self, text=tempString, width=979)
        HhtswMessage.pack(fill=X, side=TOP)

        CWD = os.getcwd()
        CWDlength = len(os.listdir(CWD))
        CWDFname = os.listdir(CWD)

        HhtswLabel1 = Label(self, text="The current working directory, from which this program instance is running, is:", padx=5, 

pady=5,)
        HhtswLabel1.pack()

        HhtswLabel2 = Label(self, text=CWD, padx=5, pady=5, fg="blue")
        HhtswLabel2.pack()

        HhtswLabel3 = Label(self, text="The contents of this directory are:", padx=5, pady=5)
        HhtswLabel3.pack()

        HhtswScroll = Scrollbar(self)
        HhtswScroll.pack(side=RIGHT, fill=Y)

        HhtswListbox = Listbox(self, selectmode=SINGLE, fg="blue", width=68, height=5)

        xlsxCounter = 0
        for i in range(CWDlength):
            HhtswListbox.insert(END, CWDFname[i])
            if CWDFname[i].endswith('.xlsx') == True:
                xlsxCounter = xlsxCounter + 1

        HhtswListbox.pack()

        HhtswScroll.config(command=HhtswListbox.yview)
        HhtswListbox.config(yscrollcommand=HhtswScroll.set)

        S30 = "The total number of items in this directory is " + str(CWDlength) + ".  Of these items, " + str(xlsxCounter) + " 

is/are *.xlsx files."
        HhtswLabel4 = Label(self, text=S30, padx=5, pady=5)
        HhtswLabel4.pack()

        S31 = "Click on the \"TRANSLATE\" button to begin.  Or click the \"X\" in the upper-right corner to close this program."
        HhtswLabel5 = Label(self, text=S31, padx=5, pady=5)
        HhtswLabel5.pack()

        HhtswButton = Button(self, text="TRANSLATE", command = self.OnButtonClick)
        HhtswButton.pack()

        self.resizable(False, False)

    def OnButtonClick(self):
        result = tkMessageBox.askquestion("Do you need to CANCEL and EXIT? \n", "Click \"Yes\" to CANCEL and EXIT. \n Click \"No\" to 

Translate hand histories")
        if result == 'yes':
            self.destroy()
        else:
            tkMessageBox.showinfo('Now translating hand histories...', 'Allow several seconds per file...')
        return result
##############################
SomeMain.py
Code:
from TestGUI import*

if __name__ == "__main__":
    Hhtsw = HhtStart_Window(None)
    Hhtsw.title("Test HUSnG HH Translator")

Hhtsw.mainloop()
##############################

The above code, when ran in IDLE, displays a window (class HhtStart_Window). Towards the bottom of the window, is a 'TRANSLATE' button. The user is told to either click on the button to proceed, or click on 'X' and close the program.

When the 'TRANSLATE' button is clicked, displayed is a tkMessageBox.askquestion. This message box has two buttons, named 'Yes' and 'No'. If 'Yes' is clicked, the program cancels and exits. If 'No' is clicked, a second tkMessageBox.showinfo is displayed. This second tkMessageBox.showinfo message box is titled, 'Now translating hand histories...', and displays the content of, 'Allow several seconds per file...', then there's an 'OK' button at the bottom of the message box.

QUESIONS vvv

What I would like to know how to do is to make this second tkMessageBox.showinfo message box not even have a button, or if it must have a button, how can I make it unresponsive? I think I know that this feature is set somehow in the options, but I have seen maybe several dozen online resources on tkMessageBoxes and haven't yet seen one single example listing the syntax of the options part. In tkMessageBox.showinfo('...', '...', X), where the 'X' is, I've tried things like default=None; type=None; default=CANCEL; default=cancel; default='CANCEL'; but I haven't gotten anything to work yet, which is why the GUI is set up in the unusual (redundant) way that it is (another story). I have a feeling that I've been close to the answer, but how is this done?

Also, if the user navigates this far and the prog gets to the point where this second tkMessageBox.showinfo message box appears, how do I then Make the main (class HhtStart_Window) window's "TRANSLATE" button unresponsive, so that the GUI is pretty much unresponsive until the prog gets finished processing files - While the prog is processing files, all I want the user to be able to do is CANCEL file processing and close the program; otherwise the GUI will 'pause' and the user will have to wait?

My last question is, what would be a good (conventional) way for me to continue on with the program and write any additional code in the 'SomeMain.py' file. See, even though it's not really that much code, since I'm a beginner, I want to keep the GUI code from distracting me when I begin to write the logic behind the main code (it's bound to be long and tedious). So, I want to start writing the rest of the program inside the SomeMain.py file and just would like some pointers of what would be a conventional way to set it all up and start doing that. I can start making the transition from the '...GUI' file to the '...Main' file right now, but my lack of OO understanding makes me not know if I'm going about it the correct way or not?

Thanks for any advice given. If you need any more description/info related to the above post, or want to see any screenshots of the code output, don't hesitate to ask. Thanks
Coding a hand history translator - getting started - seeking experienced advice ??? Quote
12-25-2013 , 03:16 AM
cool, do you complete it?
I also need this,
Could you share it to me?
Coding a hand history translator - getting started - seeking experienced advice ??? Quote
12-25-2013 , 12:42 PM
No, I don't have it finished yet. I guess it's about %25-%30 done. I got the GUI done, up to the point of clicking on a button to ahead and process the any *.xlsx files that are in the working directory along with the program. Mainly, the logic of that part of the program is all that's needed. I attempted to do it using a procedural type style, but it became difficult for me to keep track of everything, so I've went back in the books to try and learn more about OOP. I never really learned that paradigmn completely, but I know enough to stay on the right track as far as what I need to learn, etc. There's so many good online resources out there that I've found alot of info, I just have to wait until the OO way of doing things clicks before I give the prog any more major attention. Specifically, I'm compiling some Q&A's for a type of quiz to help me memorize some fundamentals of Python and OO analysis, design, and programming. I've got about 500 of those questions so far; mostly basic, generic, code examples (Foo, Bar, Baz, etc) to get me used to the rules involved with class/instance variables; class definitions; method definitions; etc. And also modeling the domain. Once I learn those basic rules of Python & OOP better, I think I've got a chance at making a program that works - I'll share it with 2p2ers if/when I ever get a working version of it finished.
In learning about how to do it the OO way, I've been messing around lately with a smaller problem domain to practice on, until I can 'put it all together', so to speak. It's just an 8deck shoe that may eventually deal itself out and play blackjack. I need to learn OOP and also get quicker at basic strategy, so I figure that's a simple enough place for me to start. I had never seen the site before but that StackOverflow is a valuble resource for learning about Python and a bunch of other stuff.
Coding a hand history translator - getting started - seeking experienced advice ??? Quote
12-25-2013 , 11:06 PM
I decided to see what I could do with this problem in an afternoon.

http:/checkmywwstats.com/extractexcelhh.zip

Here's some source code in c# for you. It's a console program that takes the name of excel file(s) and outputs fulltilt HHs to the console. It works on the one HH you supplied. It will need help for things like: no showdown, split pots, post out of turn, all-in, and no doubt more. Kreatief has probably solved these problems!

I used the Keith Rule hand evaluator: http://www.codeproject.com/Articles/...n-and-Analysis

and read excel using EPPLus: http://epplus.codeplex.com/

Both are included in the zip I linked above.

Your spreadsheet format is pretty close to the full tilt format, so I got away with not saving much state. Still I think you'd be better off with marrying my code to Kreatief's code.

You can build this with the no cost visual studio express: http://www.visualstudio.com/en-us/do...loadFamilies_2
Coding a hand history translator - getting started - seeking experienced advice ??? Quote
12-26-2013 , 06:51 PM
AutoHotKey is the platform you want to use for this. It is c#-like and has functions for File I/O, Regular Expressions, String Manipulation, and Math. I have refined a script that translates Pokerstars play money hand histories into real money hand histories on the fly (as I am playing) so that they import into Holdem Manager and provides a HUD and instant info on EV and a record of all playing stats while I am practicing with Play Money. This works for Hold Em as well as PLO. I am about 95% done with my Seals with Clubs to Full Tilt conversion script, which allows me to have a HUD on Seals with Clubs and keep track of my EV and other stats. I'm still trying to perfect the PLO side of this script. Let me know if I can help you with any code or examples. Maybe you can help me figure out why my PLO files aren't importing, as I don't have a big variety of samples of Full Tilt PLO hand histories at my disposal to use as a guide.
Coding a hand history translator - getting started - seeking experienced advice ??? Quote
01-06-2014 , 09:36 PM
Thanks Chips Ahoy. Can you provide a fresh link to your c# code when you get a chance? I tried the '...checkmywwstats...' above, but kept getting a 404-NotFound response. I guess I didn't recheck this thread in time for it to still be available.
I've haven't been as active on here lately since getting the Python bug. I'm compiling a bunch of Questions/Answers for a flashcard/quiz type program that I'm writing in Python to learn more about its library. I originally started gathering only OOP example code that illustrated concepts, but I've been messing around with RegExes lately because I stumbled onto a few good intro tutorial for them and they seem like they'll help me to code the Py/OO quiz.
If you're able to repost or PM me your source code, I'll try to translate it to Python and see what I can add to it. I remember that the variable number of lines in the *.xlsx for the preflop, flop, turn, and river had me stumped for awhile, but then I was able to get some ~pseudocode together for determining when certain streets began and ended, etc.
Coding a hand history translator - getting started - seeking experienced advice ??? Quote
01-07-2014 , 04:52 AM
01-09-2014 , 03:13 AM
Thanks Chips Ahoy. I'll give the source code a look. It's liable to give me some more ideas to pursue, even if I myself am not able yet to translate it to Python. I've seen enough C# that I think I can follow what the code is saying, but not having ever programmed in it, I've not really ever checked my accuracy.

Being inexperienced at C# (I should Google the 'how', but I just woke up), how do I go about looking at the source code in your link? After I extract it, would the source code maybe be in \extractexcelhh\extractexcelhh\Program.cs or maybe ...\extractexcelhh.csproj ? Or maybe it's further into the directory structure (\bin, \obj, or \Properties)? Or, maybe I should decompile something with Visual Studio Express? I would guess that C# is a compiled language, but I really have no idea. I couldn't even name, by memory, one of its methods() unless it was just a lucky guess on my part.
Coding a hand history translator - getting started - seeking experienced advice ??? Quote
01-09-2014 , 04:03 AM
*.cs are the code files
*.csproj are the project files for Visual Studio
*.sln are solution files that connect all the projects to one big project
.\bin contains the binarys that have been compiled and linked from sourcecode
.\obj contains the objects that have been compiled from sourcecode. They need to be linked together to produce a DLL or EXE


If you have Visual Studio (express is enough), then find the *.sln file and open it. If you have a newer version of Visual Studio it will convert it.
Otherwise just open the *.cs files with a texteditor (notepad++ is very good).
Coding a hand history translator - getting started - seeking experienced advice ??? Quote
01-18-2014 , 03:02 AM
Oh, cool. Thanks. I'll probably get that Visual Studio Express and see what I can make of the source code. I have a Visual Studio for Visual Basic, but I don't have access to it for a few months.
Those Regexes in Python are powerful. I learned a bit about their syntax, and turned ~20 lines of code that I had for a Python quiz into only 9 lines. I had never really messed around with *.txt file I/O much before, because it was difficult to keep my attention, even though I knew it was important stuff to know. But, I learned a little about the re module and not mixing file iteration with read methods, and now I can study Python code that's tailored to what I want/need to learn, instead of trying to understand a dry read or two (although, some of those are useful also).
Coding a hand history translator - getting started - seeking experienced advice ??? Quote
01-18-2014 , 10:02 AM
visual studio express is free btw.
Coding a hand history translator - getting started - seeking experienced advice ??? Quote
01-20-2014 , 05:07 AM
ruby is the tits for string manipulation
Coding a hand history translator - getting started - seeking experienced advice ??? Quote
02-03-2014 , 05:49 PM
I found the discussion very interesting and helpful this is something very useful in terms of discussion on forums. Thanks for that updated information.
Coding a hand history translator - getting started - seeking experienced advice ??? Quote

      
m