randomizing actions

Coding-related discussion: OpenPPL (Poker Programming Language) and internal OpenHoldem-script
Post Reply
panXfocaccia
First blood
First blood
Posts: 17
Joined: Thu Jun 08, 2023 8:47 am

randomizing actions

Post by panXfocaccia »

Hi,
I would like to randomize some actions:

ex.

Code: Select all

WHEN HeadsUp
	AND SomeConditions
	AND Random <=25
	AND list_of_hands_A
RaiseMax FORCE

WHEN HeadsUp
	AND SomeConditions
	AND Random <=50
	AND list_of_hands_B
RaiseMax FORCE

WHEN HeadsUp
	AND SomeConditions
	AND Random <=75
	AND list_of_hands_C
RaiseMax FORCE

WHEN HeadsUp
	AND SomeConditions
	AND list_of_hands_to_go_allin_always
RaiseMax FORCE
But according to OPPL Manual
Random Gets evaluated new each time it
gets used. So be careful if you code
sequences of random actions. If you
need a random function that stays
constant for some time you could
use the OpenHoldem symbols
What's the correct way to achieve what I need?
Do I need to declare a variable at the beginning of the script?
Alex
Site Admin
Site Admin
Posts: 3112
Joined: Sun Mar 26, 2017 5:58 pm

Re: randomizing actions

Post by Alex »

you are right, "Random" is only good when you have 2 possible scenarios.
try "randomround" instead: random number between (0.000-1.000) for the current round. Value is calculated only once in current round.

Example:

WHEN randomround<0.2 ...
WHEN randomround>=0.2 and randomround<0.5 ...
WHEN randomround>0.5 ...
rem54
Botter for life
Botter for life
Posts: 615
Joined: Fri Apr 27, 2018 5:19 am

Re: randomizing actions

Post by rem54 »

// This line executes 26% of the time 0 .... 25, (0 is in the set 100 is not) < 25 yields 25% not <= 25
WHEN HeadsUp AND SomeConditions AND Random <=25 AND list_of_hands_A RaiseMax FORCE

// This line executes 37.74% of time, 51% of the remaining 74% not handled in the prior line of code
WHEN HeadsUp AND SomeConditions AND Random <=50 AND list_of_hands_B RaiseMax FORCE

//This line executes 27.56% of the time, 76% of the remaining 36.26% of hands not already handled
WHEN HeadsUp AND SomeConditions AND Random <=75 AND list_of_hands_C RaiseMax FORCE

// This line is only evaluated 8.7% of the time
WHEN HeadsUp AND SomeConditions AND list_of_hands_to_go_allin_always RaiseMax FORCE

That's how Random waterfall steps work. Hope the explanation helps.
Alex
Site Admin
Site Admin
Posts: 3112
Joined: Sun Mar 26, 2017 5:58 pm

Re: randomizing actions

Post by Alex »

good example, rem54, thanks
zadak
Out of this world
Out of this world
Posts: 364
Joined: Sun Jul 05, 2020 8:36 pm

Re: randomizing actions

Post by zadak »

I can help you with randomizing some actions. Here is an example:

WHEN HeadsUp
AND SomeConditions
AND Random <= 10
AND list_of_hands_D
RaiseMin FORCE

WHEN HeadsUp
AND SomeConditions
AND Random <= 20
AND list_of_hands_E
RaisePot FORCE

WHEN HeadsUp
AND SomeConditions
AND Random <= 30
AND list_of_hands_F
RaiseHalfPot FORCE

WHEN HeadsUp
AND SomeConditions
AND list_of_hands_to_fold_always
Fold FORCE
beeaseful
Fish
Fish
Posts: 6
Joined: Thu Jul 16, 2020 4:45 pm

Re: randomizing actions

Post by beeaseful »

Hello, on the same topic i would like to ask something to be sure i understood everything...


WHEN SomeConditions AND Random <=50 AND list_of_hands_A RaiseMax FORCE


WHEN SomeConditions AND Random <=100 AND list_of_hands_B RaiseMax FORCE

in this example if i understand correctly, it will go all in 50% of the time with list of hands A and 50% of the time with list of hands B

Am i correct ?
Alex
Site Admin
Site Admin
Posts: 3112
Joined: Sun Mar 26, 2017 5:58 pm

Re: randomizing actions

Post by Alex »

beeaseful wrote: Tue Nov 07, 2023 10:59 pm Hello, on the same topic i would like to ask something to be sure i understood everything...


WHEN SomeConditions AND Random <=50 AND list_of_hands_A RaiseMax FORCE


WHEN SomeConditions AND Random <=100 AND list_of_hands_B RaiseMax FORCE

in this example if i understand correctly, it will go all in 50% of the time with list of hands A and 50% of the time with list of hands B

Am i correct ?
Random returns random number from 0 to 100, so in your example, it will shove 50% of time with handsA, and if not, it will always shove with handsB (because Random is always <=100). If it's what you want, then yes, correct.
You can just say:

Code: Select all

WHEN SomeConditions AND Random <=50 AND list_of_hands_A RaiseMax FORCE
WHEN SomeConditions AND list_of_hands_B RaiseMax FORCE
Post Reply