Poker-AI.org
http://poker-ai.org/phpbb/

OCR and numbers, easy game or not?
http://poker-ai.org/phpbb/viewtopic.php?f=26&t=2711
Page 1 of 1

Author:  fisherking [ Sat Feb 22, 2014 3:43 pm ]
Post subject:  OCR and numbers, easy game or not?

Hi all,
we are talking to an experienced programmer who will be working on the "stealthness" of our bot, he says the best way to go is with two machines + OCR etc., and in theory I totally agree with him, but he is very concerned about errors in reading numbers from the client via OCR (he says words won't be a problem as there are very few words in poker).

Before spending money on the programmer I would really like to know if an OCR with acceptable errors in number reading for poker is doable or not, in your opinion. Anyone got an OCR working and running no problem with a bot?

Ty!

Author:  shalako [ Sat Feb 22, 2014 5:26 pm ]
Post subject:  Re: OCR and numbers, easy game or not?

It is easy. You may have to scale the image or convert to black and white before running thru the OCR engine to improve accuracy. Mine had issues with the number 5 thinking it was an S. I resolved this by checking to see if the string returned is numeric and if not by replacing any S's with fives or any other problamatic numbers.

Author:  fisherking [ Sat Feb 22, 2014 5:47 pm ]
Post subject:  Re: OCR and numbers, easy game or not?

Hey Shalako, hello and ty again! :)

If I remember correctly you are mostly doing HU thou; do you think it would be no more difficult for 6max?
Also, do you think we should compile our OCR or could we go with Tesseract or similia?
Tyvm!

Author:  shalako [ Sat Feb 22, 2014 6:31 pm ]
Post subject:  Re: OCR and numbers, easy game or not?

fisherking wrote:
Hey Shalako, hello and ty again! :)

If I remember correctly you are mostly doing HU thou; do you think it would be no more difficult for 6max?
Also, do you think we should compile our OCR or could we go with Tesseract or similia?
Tyvm!


Yeah I am mostly doing HU but I have a 9max NL and a 6max PLO bot that use the same OCR stuff. I use the Tesseract engine that was available as a plugin for my IDE and it is lightning fast. I do not know about other engines but I am sure compiling is always the better option.

At some sites the stack sizes are in the chat text so anytime you can utilize that vs OCR then do it. One thing you can always get from the chat text is the bet to call and potsize so you can save yourself some processing time by parsing text instead of OCR. The less screen shots you have to take the better obviously.

One trick to help you get more OCR accuracy is too clean the string of any odd random characters which seem to appear. Like here is my code dealing with the S problem and cleaning the text of anything but numbers:

Code:
    ocrtext = ocr.GetText
    //replace S with 5
    ocrtext = ocrtext.Replace("S","5")
    //clean all chars but numbers
    ocrtext = StrClean(ocrtext,"`~;:,!@#$%^&*()_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .’'")
    PotSize = Val(ocrtext)

Author:  fisherking [ Sat Feb 22, 2014 9:17 pm ]
Post subject:  Re: OCR and numbers, easy game or not?

Oh, ty boy, karma + for you! :)

Btw this sounds as very good news for me, as the programmer says that once done the compiling of a decent OCR a very secure setup could be at hand. Hope we are not overlooking at other things...
as, e.g., mouse movements, which he is pretty confident won't be a big issue instead.

Author:  shalako [ Sun Feb 23, 2014 1:28 am ]
Post subject:  Re: OCR and numbers, easy game or not?

Well all the stealth and mouse stuff is all easy compared to the AI. I remember you where going to perhaps do a combo of rules and simulations but not really sure. What method did you end up using?

Author:  fisherking [ Sun Feb 23, 2014 10:41 am ]
Post subject:  Re: OCR and numbers, easy game or not?

You remember correctly, we are still working on a combo between Montecarlo and rule based. Not great results yet but we are still very confident in this approach, we need time thou as the Montecarlo guy is not working full time - he's got a family and a demanding career.
We are already setting up the interface thing because we wish to have it all ready when and if we get a decent AI.

P.s.: out of curiosity, what language is the one you are using for that code you posted? ty!

Author:  shalako [ Sun Feb 23, 2014 5:15 pm ]
Post subject:  Re: OCR and numbers, easy game or not?

fisherking wrote:
You remember correctly, we are still working on a combo between Montecarlo and rule based. Not great results yet but we are still very confident in this approach, we need time thou as the Montecarlo guy is not working full time - he's got a family and a demanding career.
We are already setting up the interface thing because we wish to have it all ready when and if we get a decent AI.

P.s.: out of curiosity, what language is the one you are using for that code you posted? ty!


I use RealStudio which is known as Xojo now. It is a basic type language that is really easy to use. I have been using it since 1999 and have never seen the need to use anything else.

What part of the bots behavior are you using monte carlo on?

Author:  fisherking [ Sun Feb 23, 2014 7:26 pm ]
Post subject:  Re: OCR and numbers, easy game or not?

shalako wrote:

What part of the bots behavior are you using monte carlo on?


We will be making a very slim rule based core for all the basics and then we will be leaving to the montecarlo all the rest, and then adjust accordingly to the results.
We are setting rules for the most basic parts of the strategy, starting obv from the preflop, e.g. how much $ to open from what position, what range etc. and what range to 3bet vs what opening range and things like this, that I consider almost "solved" on my part (as an experienced poker player).
So the Montecarlo part of the bot will be playing its role mostly on the postflop. But as I said we are still far from decent results, and we will still need months to finish the first part of the work. Also, consider that more than a developer I am the guy who is mostly putting the different brains together and doing the testing, so take my words on the different technical things "cum grano salis"! :)

Author:  bpdummy666 [ Tue Feb 25, 2014 3:30 pm ]
Post subject:  Re: OCR and numbers, easy game or not?

My experience with 3d party OCRs was bad.
I trained Tesseract with the chat characters.
But at the end for the same input I got different results.

So I changed my idea and at the moment I use the chat reader: http://chatreader.x10.bz/

I realized that the OCR must be perfect reading the data.

Author:  shalako [ Tue Feb 25, 2014 4:31 pm ]
Post subject:  Re: OCR and numbers, easy game or not?

yeah I can see how using OCR for the chat would fail quite often. Luckily there are other methods for getting that information. I only use OCR for stacks and pot sizes so it has never been a real problem. I had a situation come up the other day in which I needed to know the name of a player in the pot that was not in the chat text and OCR failed miserably. I still am not sure what I am going to do about it.

Author:  bpdummy666 [ Tue Feb 25, 2014 9:26 pm ]
Post subject:  Re: OCR and numbers, easy game or not?

shalako wrote:
yeah I can see how using OCR for the chat would fail quite often. Luckily there are other methods for getting that information. I only use OCR for stacks and pot sizes so it has never been a real problem. I had a situation come up the other day in which I needed to know the name of a player in the pot that was not in the chat text and OCR failed miserably. I still am not sure what I am going to do about it.


I don't know what poker room are you using and I don't perfectly understand your problem, but the only situation where I think there are players on the table (pot), but not in the chat, is when they are sit out or they are not playing the hand. If a player is not playing then you don't need to read his information from the table. I suppose.

Please tell me more.

Author:  shalako [ Wed Feb 26, 2014 2:16 am ]
Post subject:  Re: OCR and numbers, easy game or not?

I have never had a problem on PS. This problem was on a specific game on FTP in which I could not tell who the player was on the button in a 4 handed game if the bot was on the CO. So I tried to OCR the player name but the accuracy was terrible.

Author:  HontoNiBaka [ Thu Mar 06, 2014 8:19 pm ]
Post subject:  Re: OCR and numbers, easy game or not?

It's relativelly easy on stars. It doesn't scale linearilly, there are only 7 font-size levels. You can just use training pics of every size, clean them up, then get a screenshot, clean it up the same way and you will get the exact same characters every time. No need for fancy machine learning techniques or anything, just look for a character, where every single pixel matches.

Author:  Bliss [ Fri Mar 07, 2014 2:29 pm ]
Post subject:  Re: OCR and numbers, easy game or not?

I don't think there's any need to take screenshots.
Check out the gx/fonts folder. Besides that check the gx.ini files. (default + the one of your theme).

I haven't written anything concrete for it yet, but I think that is the easiest as there is no noise.

Author:  HontoNiBaka [ Tue Mar 11, 2014 11:08 am ]
Post subject:  Re: OCR and numbers, easy game or not?

There is no real noise in screenshots, it's just the way the font gets rendered, but it's deterministic. The training image screenshots will look 100% like the screenshots you take, while using the software. You can get 100% accuracy.

Author:  Tom [ Sun Mar 16, 2014 3:54 am ]
Post subject:  Re: OCR and numbers, easy game or not?

I wrote a bot for PS, 888, Neo, Satre and Poker Academy Pro OCR based using U_MinDst (Minimum-Distance-Cluster) with SparBot strength.
Any Questions, send me PM.

Tom

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/