SRL Archive - Senior Scripts and Snippets

PokerStars Script Odds [or more]


Narcle

2009-04-29 06:19:17

So I've been playing PokerStars a lot, and I want to get the opinions of others. I want it to be multi-versatile in detecting the cards.

For example there is the most popular Texas Hold'em, however there is more then just that game. Like Stud, Omaha and some others.

I need to detect the Card number obviously 2 - A and the type; Spade, Clubs, Diamond or Hearts. I think 2 - A could just be Bitmap masks so can be used for all colors, and then detect what type it is. So only 17 bitmaps would be needed I believe.

Counting the cards is just a math thing, but getting them detected is most important first then we can do all the math calculations. :D

I have not started this script yet, but I will soon (I hope).

Thoughts, suggestions, comments etc.?

Any help would be appreciated.

Nava2

2009-04-29 07:18:23

If the cards don't move, simple counts might be suffice. Also, check for changing colours for the same reason.

Red and black is pretty basic though. :)

Narcle

2009-04-29 07:31:02

The problem I think I'll have is the changing of positions, also the slight size changes that can occur if you re-size the window etc. So I'm not sure how to handle that… sigh

Boreas

2009-04-29 07:52:56

For the suits, size changes wouldn't be a problem as you could do stuff like hearts have the widest part 20-30% of the way down from the top, and diamonds are widest in the middle, etc etc. Can the size change on the numbers too?

Narcle

2009-04-29 08:27:35

Yeah it all changes if you accidentally resize it. Idk i'm trying to find a program thats free that read it internally. Anyone know of one? Otherwise i'll continue this project.

Sir R. M8gic1an

2009-04-29 10:01:49

simple; don't resize it. The same way we don't play runescape HD ;)

~RM

Narcle

2009-04-29 13:11:01

From: Rasta Magician
simple; don't resize it. The same way we don't play runescape HD ;)

~RM


True.

I wish I could do a internal reading… but I'd probably get caught. >.<
I don't know how I could even do internal reading, but it would be nice.

Nava2

2009-04-30 07:21:57

You can always do density.

Just another thought. :)

nielsie95

2009-05-02 00:39:13

Could you post some screenshots?

Narcle

2009-05-06 03:53:16

so I was thinking more about this. Would it be possible to read the output somehow instead of doing a SCAR color etc searching method? Like an internal reading?

I've seen odd calculators out there so I'm sure there is a way of doing it.

Anyone suggest what method it might be? I'm planning on learning C++ over the summer and a project like this I think would keep me motivated. I'll have to research it myself at some point, but any help would be nice. :D

Narcle

2009-05-15 14:43:09

Ok I finally started working on it a little. Right now all I got is the detection system worked out. Right now its kinda gaudy, I'm going to change the TBox areas to TPoints then all the points are worked off from that one point making it easy.

As you'll see in the script I'm using a record to story the cards; Kind = Heart, Diamond, Spade or Club. Num is obvious its the number but I'm using 2 - 14. I'm thinking on some kind of point system to figure out hands and how good they are etc.

Now I'm kinda stumped on how to do the system to find out possible hands from cards on table. How to sort what my best hand is (from 7 cards). How to sort and rank hands. Umm I know there's others I wanted but can't remember atm.

Also I want to record their names and start doing stats on them. How many times they fold, raise, call, check, win, lose and more if I can. All of this I will save in a ini file and use it for future use in case I run into same ppl.

I will need to figure out how to read the different text and load it. I've never done it so I might need help. I really don't want to do it manually, there is commas and other strange letters that is used for names. So if anyone knows what font it is and how to load it in scar please tell me how to do it.

Edit: Later I'll be doing a complex automation that calculates the odds counts cards which will also be given to the player if they want to play with it w/o auto. But the auto will bet by percentages +/- random amount depending on how much the player has and much more.

Here's a picture to give you guys the idea. You'll notice only 4 cards on table but as I'm sure you know 1 more card will be flipped after betting. Also note its a jpg not the original bmp which was 1.75megs so my script detection might now work on this picture if you want to try it.


Note I am repeating the detection system and clearing the debug constantly. This will be tweaked and changed completely later on.
{  Client Size 799, 576
Player Layout
9 Chips 1
8 2
7 3
6 5 4
Sit at 5
{
Spade = 33 color 0
Clubs = 16 color 0
Dimonds = 58 color 526536
Hearts = 45 color 394952

Table Cards
y1 = 199 Card Type
y2 = 215
y1 = 184 Card Num
y2 = 198
x2 +12
X1a = 274 286
x1b = 328 340
x1c = 382 394
x1d = 436 448
x1e = 490 502

Card1Num := 274, 184, 286, 198
Card2num := 328, 184, 340, 198
Card3num := 382, 184, 394, 198
Card4Num := 436, 184, 448, 198
Card5Num := 490, 184, 502, 198



My Cards
Kind Number
y1a = 385 y1N = 370
y2a = 399 y2N = 384
x1a = 374
x2a = 386

y1b = 391 y1N = 374
y2b = 403 y2N = 388
x1b = 389
x2b = 401
}

type
Card = record
Kind: string;
Num: integer;
end;


Var
CardsDealt, LastDealt: Integer;
SevenBlack, SevenRed, NineRed, NineBlack: integer;
TCardKindArea, TCardNumArea, MyKindArea, MyNumArea: Array of TBox;
MyCards: String;
MyCardArr, TCardArr: Array of Card;

function CardNumber(Area: TBox): Integer;//requires bitmaps
var
B, R: TPointArray;
i, x, y, Len: integer;
CardNum, CardNumCount: TIntegerArray;
begin
CardNum := [ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14];
CardNumCount := [ 35, 26, 39, 31, 37, 26, 42, 35, 69, 33, 54, 45, 38];
FindColorsTolerance(B, 131586, Area.x1, Area.y1, Area.x2, Area.y2, 0);
FindColorsTolerance(R, 1184458, Area.x1, Area.y1, Area.x2, Area.y2, 0);
Len := Length(B)+Length(R);
if (Len = 26) then
if FindBitmapIn(SevenBlack, x, y, Area.x1, Area.y1, Area.x2, Area.y2) or FindBitmapIn(SevenRed, x, y, Area.x1, Area.y1, Area.x2, Area.y2) then
Result := 7
else
Result := 3;
if (Len = 35) then
if FindBitmapIn(NineBlack, x, y, Area.x1, Area.y1, Area.x2, Area.y2) or FindBitmapIn(NineRed, x, y, Area.x1, Area.y1, Area.x2, Area.y2) then
Result := 9
else
Result := 2;
if (Len = 35) or (Len = 26) then
Exit;

For i := 0 to High(CardNum) do
if Len = CardNumCount[i] then
Result := CardNum[i];

end;

function PlayersDealt: integer;
var
i, x, y: integer;
PlayerCardsArray, PA: Array of TPoint;
begin
PlayerCardsArray := [Point(540, 115), Point(602, 143), Point(676, 233), Point(592, 306), Point(176, 305), Point(106, 232), Point(181, 141), Point(243, 115)];
PA := PlayerCardsArray;
For i := 0 to High(PlayerCardsArray) do
if FindColorTolerance(x, y, 7037951, PA[i].x, PA[i].y, PA[i].x+12, PA[i].y+15, 0) then
Result := Result + 1;
if FindColorTolerance(x, y, 16777215, 406, 368, 426, 388, 0) or FindColorTolerance(x, y, 7037951, 423, 341, 440, 356, 0) then //Player 5 sitting here or watching
Result := Result + 1;
if Result > 9 then
Result := -1;
Status('Players = '+IntToStr(Result));
end;

Function CardKind(Area: TBox): String;
var
TPA: TPointArray;
begin
FindColorsTolerance(TPA, 0, Area.x1, Area.y1, Area.x2, Area.y2, 0);
If Length(TPA) = 33 then
Result := 'S';
If Length(TPA) = 16 then
Result := 'C';
if (Result = 'C') or (Result = 'S') then
Exit;
FindColorsTolerance(TPA, 526536, Area.x1, Area.y1, Area.x2, Area.y2, 0);
If Length(TPA) = 58 then
begin
Result := 'D';
Exit;
end;
FindColorsTolerance(TPA, 394952, Area.x1, Area.y1, Area.x2, Area.y2, 0);
If Length(TPA) = 45 then
begin
Result := 'H';
Exit;
end;
end;


Procedure LoadBitmaps;
begin
SevenBlack := BitmapFromString(11, 15, 'beNr7/58YwMTExI4BgI' +
'JxcXHICpgwgJSUFFwBECCb+fHjR2RBTAXz5s0DiqxYsQKrkyDa9fT' +
'03rx5g1VBTEwMUAHQEPK0A+0lqF1fXx+X9t27dwMVTJo0CVeQRkZG' +
'AhV8+fIFlwKg29ACBDNS8CvAAgDNz3CD');
SevenRed := BitmapFromString(11, 15, 'beNr7/58YcEpI6LS4OBoC' +
'Ct7NyEBWACTR0HlNTbgCIEI288/Hj8iCmApeLVkCFHmzdi1WJ0G0X' +
'7a2/v32LVYFd9PSgAqAhpCnHWgvYe02Nri0f9i/H6jgxcyZuIL0Tk' +
'oKUMGfL19wKQC6DS1AMCMFvwIsAADv85aK');
NineBlack := BitmapFromString(11, 15, 'beNqNUTEKxCAQBBtfIJh' +
'CCwW7fCB/sdXCIt9IZZ2UviHPCvELuYEF8Tw4MsXi7Li74/o873Ec' +
'x7IsjDHEUsqg5pyNMaxDjLGp930jo7WutYIiOueQua6LLnjvQUkl4' +
'IxMCIEo9RyGIjPP8/8OrYo8KKWaSh76ttZa9g3O+TD3PE8hBKnbtv' +
'UefjG8AkAtrDa6rmu/ByClNHjoN0nY911KCWmaJmz+7Rd+AEA6Q00' +
'=');
NineRed := BitmapFromString(11, 15, 'beNr7/5948HL+/Gvu7qeEh' +
'IDk6+XL0WSfT5160cAAKAtH9wsL4bK/370DilzQ0fn9/j2I+/79JR' +
'MToMivN28gCu6mpwO5EFmolvfvQYYUFEC4EDPRLAWKXLaywm8CXBf' +
'cDXBZiBuQjb1oaIjsBSA6LS6OZu/7HTvOqahAZJ/19yO7AROg+QII' +
'gHqBToVzH1ZUIIcDEDwoKUFzA3JIQuNi3rzz6upAqfMaGsCQJzYKA' +
'cRtdzI=');

TCardKindArea := [IntToBox(274, 199, 286, 215), IntToBox(328, 199, 340, 215), IntToBox(382, 199, 394, 215), IntToBox(436, 199, 448, 215), IntToBox(490, 199, 502, 215)];
TCardNumArea :=[IntToBox(274, 184, 286, 200), IntToBox(328, 184, 340, 200), IntToBox(382, 184, 394, 200), IntToBox(436, 184, 448, 200), IntToBox(490, 184, 502, 200)];
MyKindArea := [IntToBox(374, 385, 386, 399), IntToBox(389, 391, 401, 403)];
MyNumArea := [IntToBox(374, 370, 386, 385), IntToBox(389, 374, 401, 388)];
end;


Procedure ReadCards;
var
i: integer;
Table: String;
begin
for i := 0 to 4 do
Table := Table+' '+(IntToStr( CardNumber(TCardNumArea[i]) )+CardKind(TCardKindArea[i]));

SetArrayLength(MyCardArr, 2);
for i := 0 to 1 do
begin
MyCardArr[i].Num := CardNumber(MyNumArea[i]);
MyCardArr[i].Kind := CardKind(MyKindArea[i]);
end;

SetArrayLength(TCardArr, 5);
for i := 0 to 4 do
begin
TCardArr[i].Num := CardNumber(TCardNumArea[i]);
TCardArr[i].Kind := CardKind(TCardNumArea[i]);
end;

MyCards := IntToStr(CardNumber(MyNumArea[0]))+CardKind(MyKindArea[0])+' '+IntToStr(CardNumber(MyNumArea[1]))+CardKind(MyKindArea[1]);
SetArrayLength(MyCardArr, 2);

ClearDebug;
Writeln('My Cards: '+MyCards);
Writeln('Table: '+Table);
end;

Begin
LoadBitmaps;
ClearDebug;
ChangeReportWidth(220);
ClearReport;
Status('Waiting to be Dealt...');
ReadCards;
Repeat
If PlayersDealt > 0 then//Player and Card Count
begin
wait(2000);
repeat
CardsDealt := PlayersDealt * 2;
wait(200);
until CardsDealt > 0;
LastDealt := CardsDealt;
ClearReport;
AddToReport(IntToStr(CardsDealt)+' Cards Dealt');
AddToReport(IntToStr(52 - CardsDealt)+ ' in Deck');
Repeat
Wait(1000);
ReadCards;
until (PlayersDealt < 1);
Status('Waiting to be Dealt...');
CardsDealt := 0;
end; //End;


wait(10);
Until(false);

end.

Boreas

2009-05-16 06:51:50

For making the hands you need to start at the top and work down. There's no point in figuring out that you can make pair when you'll later see you got a full house. Once you have your best hand, you have an estimate probability of winning. You can then use the remaining time to figure out what the best hands are for all the other combination of 2 starter cards in a similar fashion to get a better probability. This is important because having 3 aces when 2 are yours leaves less good hands for other people than if 2 are in the flop.

To decide whether you should even pay to see the flop, check out these
http://www.tightpoker.com/poker_hands.html
http://www.tightpoker.com/hands/ev_position.html

R0b0t1

2009-06-01 02:44:03

They have probably taken precautions against memory editing.