Posts: 1

Threads: 1

Joined: Apr 2018

Basically I want to make it randomly choose between 2 keys. Left and Right (L R). I know how to do it with numbers but not with keys.

However if you're feeling extra froggy. I'd love to do it where it randomizes between Left and Right and gives a 60% advantage to right. So basically out of 10 times, it would select right 6 times. I know I could just write it to pick left 4 times in a row and then right 6 times in a row, but I want the random element.

Posts: 560

Threads: 192

Joined: Jul 2012

I do not know if my method is valid / correct, this is my approach.

If someone else can provide better example please do so, I also could learn from it.

Macro

Macro3

`;;....................................................`

;;. METHOD 1: 50/50 chance of either LEFT or RIGHT

;;....................................................

out

_s.RandomString(1 1 "0-1")

if(_s="1")

,out "Key left (method 1)"

,;key L ;; press key left

,;key (VK_LEFT) ;; other method of pressing key left (choose this or the above one)

if(_s="0")

,out "Key right (method 1)"

,;key R ;; press key right

,;key (VK_RIGHT) ;; other method of pressing key right (choose this or the above one)

;;....................................................

;;. METHOD 2: 60, gives 60 percent chance to LEFT

;;. (If you want to give 60 percent chance to RIGHT then switch the 2 lines 24/25 and 27/28

;;....................................................

int percent=60

_s.RandomString(1 2 "0-9") ;; generate a random string between 0 and 9 BUT it is 2 lenght so it is in essence between 0-99

int i=val(_s)+1 ;; convert to integer and because we generated between 0-99, we add +1 then result will be 1-100

if(i<=60)

,out "Key left (method 2, 60 percent given to LEFT)"

,;key L ;; press key left

,;key (VK_LEFT) ;; other method of pressing key left (choose this or the above one)

else

,out "Key right (method 2, 60 percent given to LEFT)"

,;key R ;; press key right

,;key (VK_RIGHT) ;; other method of pressing key right (choose this or the above one)

Posts: 10,650

Threads: 123

Joined: Dec 2002

Macro

Macro3049

`out`

spe 50

int percentRight

rep 100

,double r=RandomNumber

,if(r>0.6) key L

,else key R; percentRight+1

out percentRight