open ended when conditions

Coding-related discussion: OpenPPL (Poker Programming Language) and internal OpenHoldem-script
Post Reply
rudeone
First blood
First blood
Posts: 17
Joined: Thu Apr 04, 2019 11:09 am

open ended when conditions

Post by rudeone » Tue Apr 16, 2019 3:55 pm

i dont really understand what the manual means with this example.

Code: Select all

WHEN hand$AT
    WHEN StillToAct = 2
        WHEN Raises = 1
            WHEN (AmountToCall <= 4) RaisePot FORCE
            WHEN (AmountToCall > 4) Fold FORCE
        WHEN Raises = 2
            WHEN...
In principle this is a good idea, but it does not work. Simply because there is no way to tell, where one open-ended when-condition ends and where the next one starts. So the semantics would be completely undefined (it is in fact not, but it is for sure not what you want). Sure you could argue about indentation, but spaces have no meaning in most programming languages (except good old Fortran 77) and everybody does it differently. So let’s restate: There is at most one level of open-ended when-conditions (without action), each one bound to a sequence of when-conditions with actions.
is it ledgit code? only in combination with "When Others"? if so what would be the correct way to do it?

Code: Select all

WHEN hand$AT
    WHEN StillToAct = 2
        WHEN Raises = 1
            WHEN (AmountToCall <= 4) RaisePot FORCE
            WHEN (AmountToCall > 4) Fold FORCE
            When Others
        WHEN Raises = 2
            WHEN (AmountToCall <= 4) RaisePot FORCE
            WHEN (AmountToCall > 4) Fold FORCE
            When Others
 
like so?

User avatar
frogmd
Flush draw
Flush draw
Posts: 195
Joined: Thu Jan 31, 2019 12:56 am

Re: open ended when conditions

Post by frogmd » Tue Apr 16, 2019 4:11 pm

No. I believe you can't perform "nested" WHEN statements. Each WHEN statement without an action will execute action codes underneath. If you start a non-action WHEN statement, it ends the previous non-action WHEN statement.

So:
WHEN hand$AA
WHEN StackSize > 10
WHEN AmountToCall < 2 Call FORCE


is not the same as WHEN hand$AA AND StackSize > 10. The first WHEN statement is ignored and this code will Call every hand where the bet is less than 2 BB while your stacksize is greater than 10 regardless of what you're holding.
“Life is not always a matter of holding good cards, but sometimes, playing a poor hand well.” ― Jack London

rem54
Out of this world
Out of this world
Posts: 381
Joined: Fri Apr 27, 2018 5:19 am

Re: open ended when conditions

Post by rem54 » Tue Apr 16, 2019 4:25 pm

In a real programming language you could but not in these interpreted ones.

Code: Select all

WHEN hand$AT AND StillToAct = 2 AND Raises = 1
            WHEN (AmountToCall <= 4) RaisePot FORCE
            WHEN (AmountToCall > 4) Fold FORCE
WHEN hand$AT AND StillToAct = 2 AND Raises = 2
              WHEN...

// And don't forget the
WHEN Others             
or

Code: Select all

WHEN hand$AT AND StillToAct = 2 
  WHEN Raises = 1 AND (AmountToCall <= 4) RaisePot FORCE
  WHEN Raises = 1 AND (AmountToCall >  4) Fold FORCE
  WHEN AND Raises = 2

// And don't forget the
WHEN Others         

rudeone
First blood
First blood
Posts: 17
Joined: Thu Apr 04, 2019 11:09 am

Re: open ended when conditions

Post by rudeone » Tue Apr 16, 2019 5:06 pm

ok i got it now. i missed this part where it says that the next open ended statement closes the previous. now When Others at the end makes sense.
thanks a lot. no multi nested for me then :geek:

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests