Image Image Image




Post new topic Reply to topic  [ 239 posts ]  Go to page Previous  1 ... 8, 9, 10, 11, 12  Next
Author Message
 Post subject: Re: Timmy's Poker Sim Library (PSim) Examples in C, Java, AutoIt
PostPosted: Mon May 30, 2011 3:05 pm 
Offline
New member
User avatar

Posts: 8
Favourite Bot: My Own
nife wrote:
djzsajzer wrote:
Timmy!
Could you include delphi example to the next release?

thanks,



Wow didn't know delphi was still being used. I thought C# and all of the web toolkits had killed all its use.


hm :/ was looking for an example in pascal/delphi... nobody done it yet?


I've tried several things yet, some things I found, some things I tried myself.. but I get several error messages ("Invalid floating operation", "

Code:
type
type
  PostFlopState = packed record
    ///Do we use both of our hole cards?
    UsesBoth: bool;
    UsesOne: bool;
    UsesNone: bool;

    ///What is our actual hand rank?
    IsNoPair: bool;
    IsOnePair: bool;
    IsTwoPair: bool;
    IsTrips: bool;
    IsStraight: bool;
    IsFlush: bool;
    IsFullHouse: bool;
    IsQuads: bool;
    IsStFlush: bool;

    IsTopPair: bool; ///<We paired the highest card one the board with one in our hand.
    IsMiddlePair: bool; ///<We paired the board, but it's not top or bottom pair. (may be 2nd best, 3rd best, etc.)
    IsBottomPair: bool; ///<We paired the lowest card one the board with one in our hand.
    IsOverPair: bool; ///<We have a pocket pair, and it's bigger than any card on the board.
    IsOverCards: bool; ///<We just have two nonpaired cards bigger than anything on the board.

    IsStraightDrawPossible: bool; ///<Could someone have 4 to a straight?
    IsStraightPossible: bool; ///Could someone have a straight?

    IsFlushDrawPossible: bool; ///<Could someone have 4 to a suit?
    IsFlushPossible: bool; ///<Could someone have 5 to a suit?

    IsFullHousePossible: bool; ///<Is a fullhouse or quads possible?

    Is3Flush: bool; ///<Do we have exactly 3 cards to a flush?
    Is4Flush: bool; ///<Do we have exactly 4 cards to a flush?

    FlushOuts: cardinal; ///<How many cards will give us flush?
    StraightOuts: cardinal; ///<How many cards will give us straight?
    BetterOuts: cardinal; ///<How many cards will give us a fullhouse or better?
end;

procedure GetHandState(hand : pChar; state: PostFlopState); stdcall; external 'psim.dll';


and finally...

Code:
procedure TForm1.Button1Click(Sender: TObject);
var
  res  : PostFlopState;
  res2 : tSimResults;
begin

  //SimulateHand('As 9s', res2);
  GetHandState('As 9s', res);

end;


Nothing really works :/

Quote:
---------------------------
Project1
---------------------------
Access violation at address 70E19903 in module 'psim.dll'. Write of address 77D3AEDA.
---------------------------
OK
---------------------------


Some help would be awesome!


Last edited by satyrad on Mon May 30, 2011 4:48 pm, edited 2 times in total.

Top
 Profile E-mail  
 
 Post subject: Re: Timmy's Poker Sim Library (PSim) Examples in C, Java, AutoIt
PostPosted: Mon May 30, 2011 3:06 pm 
Offline
New member
User avatar

Posts: 8
Favourite Bot: My Own
doublepost, sry!


Top
 Profile E-mail  
 
 Post subject: Re: Timmy's Poker Sim Library (PSim) Examples in C, Java, AutoIt
PostPosted: Mon May 30, 2011 7:44 pm 
Offline
New member
User avatar

Posts: 8
Favourite Bot: My Own
Okay, since I can't edit my post any more, I do another one.

After a desperate quest for hours, to finally get your DLL working into Delphi, I found out why it isn't :)...

Apparently Delphi does not support Bit-Fields as you use them in your PostFlopState struct.

HandRank and SimulateHand are working fine, but the GetHandState is a b*tch to implement.

Now I was trying hard to just recompile the DLL without those, but I can't get it to work.

So now my question:
Is there a special reason you use bit-fields or could you simply hand over a version of the DLL, without those?

Anyway, thaaaaaaanks a lot in advance for your awesome work and sharing everything.

satyrad


Top
 Profile E-mail  
 
 Post subject: Re: Timmy's Poker Sim Library (PSim) Examples in C, Java, AutoIt
PostPosted: Mon May 30, 2011 9:52 pm 
Offline
PokerAI fellow
User avatar

Posts: 686
Location: Midwest, USA
Favourite Bot: N/A
You should be able to replace the PostFlopState with a couple integers. You then use the bitwise or operator to check which bits are set.

I don't know Delphi, but if it doesn't natively support bitfields, here's what you need to do:
Call GetHandState with a record containing two 32-bit integers (call them A and B, make them unsigned if you can, maybe "LongWord" is what you want).
Look in psim.hpp for the order of the bits in PostFlopState.
To query if a bit is set, take 2 to the power of that bit's location in PostFlopState, and bitwise or it with A (or B if more than 32).
Example, to check IsNoPair: it is the third bit (remember to start counting at zero) and 2 to the power if three is 8, so take "IsNoPair := 8 or A" to check if IsNoPair is set.
To get the numbers FlushOuts, StraightOuts, and BetterOuts, you'll need to use bitwise and and shifting.


By the way, if you don't know how the binary system works, and bitwise operators, now would be a choice time to learn.

You can also look at the AutoIt code that longfields posted back on the second page of this thread for an example.

Your other option would be to just call GetHandStateBrief with the result from PostFlopState (again, that result is two 32 bit numbers), and parse the resulting text instead. That would be much harder though, in my opinion.

One more thing, get hand state is meant to be called post flop.


Top
 Profile  
 
 Post subject: Re: Timmy's Poker Sim Library (PSim) Examples in C, Java, AutoIt
PostPosted: Mon May 30, 2011 10:37 pm 
Offline
New member
User avatar

Posts: 8
Favourite Bot: My Own
Thank you very much, I will try that right away.

Regarding the post flop thing... yeah, I thought so.

I was looking (except for the post flop play) to check, how to figure out what hands would be profitable to play.

Tried RankHand then, but I don't really know what the numbers are supposed to mean.

Is this right?
AA is 17563648
AK is 831488 (and so is AKs?!)
22 is 16777216

so... apparently it doesn't matter to HandRank if cards are suited or not?
and second thing, the jump from the smallest pocket hand, to i.e. AK is huge.

What's this function for exactly?

Thanks! :drink


Top
 Profile E-mail  
 
 Post subject: Re: Timmy's Poker Sim Library (PSim) Examples in C, Java, AutoIt
PostPosted: Tue May 31, 2011 9:03 am 
Offline
Junior member
User avatar

Posts: 12
Favourite Bot: mine
satyrad wrote:

Is this right?
AA is 17563648
AK is 831488 (and so is AKs?!)
22 is 16777216



If this is preflop it can't be right from general poker knowledge. Even HU where pocket pairs are ranked higher, AK is a better starting hand than 22.


Top
 Profile E-mail  
 
 Post subject: Re: Timmy's Poker Sim Library (PSim) Examples in C, Java, AutoIt
PostPosted: Tue May 31, 2011 9:30 am 
Offline
New member
User avatar

Posts: 8
Favourite Bot: My Own
softix wrote:
satyrad wrote:

Is this right?
AA is 17563648
AK is 831488 (and so is AKs?!)
22 is 16777216



If this is preflop it can't be right from general poker knowledge. Even HU where pocket pairs are ranked higher, AK is a better starting hand than 22.


Hmm, so I probably do something wrong?

Code:
// Function declaration
function RankHand(hand : ansistring): dword; stdcall; external 'psim.dll';

// some debug dialogs
showmessage(inttostr(RankHand('As Ac')));
showmessage(inttostr(RankHand('As Kc')));
showmessage(inttostr(RankHand('2s 2c')));


... as I get the results above?


Top
 Profile E-mail  
 
 Post subject: Re: Timmy's Poker Sim Library (PSim) Examples in C, Java, AutoIt
PostPosted: Tue May 31, 2011 8:19 pm 
Offline
PokerAI fellow
User avatar

Posts: 686
Location: Midwest, USA
Favourite Bot: N/A
RankHand is made to rank poker hands. A higher number means that a poker hand is strictly better. 22 will be AK in a show down, that's why it's ranked higher. AK and AK suited would tie in a show down, so they must have the same rank. Usually the RankHand function would only be used in simulations involving many hands (and often 6 or 7 cards at a time). It's not made to be used pre-flop.

Your best bet for pre-flop is probably to come up with your own system to identify hands you want played. Otherwise, you can use the SimulateHand functions to get a sense of how good the hands are. It will be quite slow if you do a full evaluation, but you can do a Monte-Carlo evaluation rather quickly.


Top
 Profile  
 
 Post subject: Re: Timmy's Poker Sim Library (PSim) Examples in C, Java, AutoIt
PostPosted: Wed Jun 01, 2011 11:20 am 
Offline
New member
User avatar

Posts: 8
Favourite Bot: My Own
Thank you once again, I decided to come up with my own solution (card ranges for each position).

I basically got the GetHandState working, but sometimes (probably on a special hand?) I still get access violations. Trying to debug it right now as I write this, to find out what hand combinations trigger it while reading what property etc.... thanks for sharing your work and giving out support like this! :)


Top
 Profile E-mail  
 
 Post subject: Re: Timmy's Poker Sim Library (PSim) Examples in C, Java, AutoIt
PostPosted: Mon Jun 06, 2011 9:05 am 
Offline
New member
User avatar

Posts: 2
Favourite Bot: esclator
Well the only point of judging cant be the right hand or the higher numbers. Here you can also leave your query by dropping an email

support@PokerSiteCentral.com


Top
 Profile E-mail  
 
 Post subject: Re: Timmy's Poker Sim Library (PSim) Examples in C, Java, AutoIt
PostPosted: Thu Oct 20, 2011 6:53 pm 
Offline
Senior member
User avatar

Posts: 209
Favourite Bot: winnie
hey, without reading all responses.
is it possible that the library has a bug?

if i evaluate the following situation:
Hand: Ad Jh
Flop: Ks 3s Kh

Getting the String: from getHandStateBrief:
Using both hole cards, with middle pair. Someone may be drawing to a flush. The board is paired.

Clearly its not a middle pair using both hole cards, rigth?


Top
 Profile E-mail  
 
 Post subject: Re: Timmy's Poker Sim Library (PSim) Examples in C, Java, AutoIt
PostPosted: Tue Nov 15, 2011 12:30 am 
Offline
Senior member
User avatar

Posts: 131
Bit of a long shot, but I wonder if anyone can help?

I'm trying to get this working with MS Excel. I have been able to make it work as part of a macro worksheet using the CALL function as follows:

=CALL("[Path]\psim.dll","RankHand","JC","AsAc Td5hJh6c3s")

"RankHand" is of course one of the functions within psim.

"JC" is the 'type string' indicating the type of each argument. The first letter corresponds to the returned value, the subsequent letters give the types of the arguments. This is according to the following table:

Code/ Description/ Transferred by/ C type
B/ 8-byte floating-point number (IEEE)/ Value/ double
C/ Zero (null) terminated string/ Reference/ char *
F/ Zero (null) terminated string/ Reference (modify in place)/ char *
J/ 4 bytes wide signed integer/ Value/ long int
P/ Excel's OPER data structure/ Reference/ OPER *
R/ Excel's XLOPER data structure/ Reference/ XLOPER *

So in the above example, the returned value is an integer and the argument is a string. Like I say, this works. But I cannot get it to work with the other functions within psim, e.g. "SimulateHand". I think this is because I don't really understand how the Excel data structures relate to the ones used with psim (if at all). Can anyone point me in the right direction, or ideally give me an example? Thanks!

_________________
http://www.pokerspreadsheets.com


Top
 Profile E-mail  
 
 Post subject: Re: Timmy's Poker Sim Library (PSim) Examples in C, Java, AutoIt
PostPosted: Tue Dec 27, 2011 4:15 pm 
Offline
Junior member
User avatar

Posts: 38
Favourite Bot: Mine :D
Hi Timmy,


I'm looking for the source code of IsStraightPossible()...


Is it possible to have access to your source code or could you post it ?


Regards,


MrNice


Top
 Profile E-mail  
 
 Post subject: Re: Timmy's Poker Sim Library (PSim) Examples in C, Java, AutoIt
PostPosted: Tue Dec 27, 2011 6:51 pm 
Offline
PokerAI fellow
User avatar

Posts: 686
Location: Midwest, USA
Favourite Bot: N/A
MrNice wrote:
I'm looking for the source code of IsStraightPossible()...
Is it possible to have access to your source code or could you post it ?

PSim has been open source from day one. I'm not sure where you could have downloaded it from and missed the source code.

There is no IsStraightPossible() function. Look at the GetHandState() function in simulate.cpp. It enumerates all possible 2 card combinations to check if a straight is possible.


Top
 Profile  
 
 Post subject: Re: Timmy's Poker Sim Library (PSim) Examples in C, Java, AutoIt
PostPosted: Tue Dec 27, 2011 6:54 pm 
Offline
PokerAI fellow
User avatar

Posts: 686
Location: Midwest, USA
Favourite Bot: N/A
winnie wrote:
hey, without reading all responses.
is it possible that the library has a bug?

if i evaluate the following situation:
Hand: Ad Jh
Flop: Ks 3s Kh

Getting the String: from getHandStateBrief:
Using both hole cards, with middle pair. Someone may be drawing to a flush. The board is paired.

Clearly its not a middle pair using both hole cards, rigth?

This has been brought up before. It is not a bug. The "Using both hole cards" indicates whether your hole cards are used to make your best poker hand (i.e. five card hand). Since you only have five cards, it's obviously going to be true.


Top
 Profile  
 
 Post subject: Re: Timmy's Poker Sim Library (PSim) Examples in C, Java, AutoIt
PostPosted: Sun Jan 01, 2012 3:45 pm 
Offline
New member
User avatar

Posts: 2
Favourite Bot: SelfMade
Hello,
First off: Thanks for releasing this, it has really helped me out a lot so far. :)

I just have one quick question regarding the usage of hole card numbers, and i hope, this hasnt come up yet and i simply missed the post.

Is it possible, to "force" the simulation function to always use 2 hole cards? Plainly put: Is an Adaption for Omaha high a possibility ?

Thanks in advance for answering my question :)

cheers


Top
 Profile E-mail  
 
 Post subject: Re: Timmy's Poker Sim Library (PSim) Examples in C, Java, AutoIt
PostPosted: Sun Jan 01, 2012 6:37 pm 
Offline
PokerAI fellow
User avatar

Posts: 686
Location: Midwest, USA
Favourite Bot: N/A
No, it's not really made for that.

You might be able to run several simulations with different hole card combinations, and then take the best hand. You're probably better off going straight to poker-source's poker-eval which I believe supports it, but is hard to use if you're not familiar with C.


Top
 Profile  
 
 Post subject: Re: Timmy's Poker Sim Library (PSim) Examples in C, Java, AutoIt
PostPosted: Sun Jan 01, 2012 8:22 pm 
Offline
New member
User avatar

Posts: 2
Favourite Bot: SelfMade
Thanks for the quick reply and for pointing me in the right direction :)

I'll give pokersource's poker-eval a try then.

cheers,


Top
 Profile E-mail  
 
 Post subject: Re: Timmy's Poker Sim Library (PSim) Examples in C, Java, AutoIt
PostPosted: Thu Jan 05, 2012 10:55 am 
Offline
Junior member
User avatar

Posts: 38
Favourite Bot: Mine :D
Timmy wrote:
MrNice wrote:
I'm looking for the source code of IsStraightPossible()...
Is it possible to have access to your source code or could you post it ?

PSim has been open source from day one. I'm not sure where you could have downloaded it from and missed the source code.

There is no IsStraightPossible() function. Look at the GetHandState() function in simulate.cpp. It enumerates all possible 2 card combinations to check if a straight is possible.



Hi Timmy,

I have checked the source code and it seems that you simulate all hands and check if a straight is possible...

Thanks for the job.

REgards,

MrNice


Top
 Profile E-mail  
 
 Post subject: Re: Timmy's Poker Sim Library (PSim) Examples in C, Java, AutoIt
PostPosted: Wed Feb 15, 2012 5:27 am 
Offline
Regular member
User avatar

Posts: 87
Favourite Bot: Mine
Hello,

I have been trying to compile PSim into a dylib (basically a DLL for Mac) with XCode 3 with no luck. Has anybody else tried to do this yet? I am unfamiliar with XCode so that is not helping matters...


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 239 posts ]  Go to page Previous  1 ... 8, 9, 10, 11, 12  Next


Who is online

Users browsing this forum: No registered users and 14 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: