Start a loop from a specific point

Asked by Martin

Hi everyone,

I'm playing roulette on a casino game and I want to create a while loop to place bets.

****the challenge:

Restart the script from the beginning (#point A) every time I win.
Starting with bet 1 (img3) and chips are placed on a number (i.e. number 3)
--Round 1:
#3 win: restart the script from the beginning.
#3 lose: place another bet (bet 2=img4)
--Round 2:
#3 win: restart the script from the beginning.
#3 lose: place another bet (bet 3=img5)
--etc...
Before placing bets, there is a waiting time which ends when "img2" appears.
The script ends after bet 3 if #3 lose.

****the problem:

Seems like my script doesn't recognize the condition (img1) and place the same bet (bet 1) over and over again.

****the script:

While True: #Point A
 if not exists(img1, 0):
  wait(img2, FOREVER)
  click(img3)
  continue
 else:
  if exists(img1, 0):
  wait(img2, FOREVER)
  click(img4)
  break
While True: #Point B
 if not exists(img1, 0):
  wait(img2, FOREVER)
  click(img3)
  continue # Want to restart from point A, not point B
 else:
  if exists(img1, 0):
  wait(img2, FOREVER)
  click(img5)
  break

#etc….

Can you help me please?

Thank you!

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

If I understand right:

while True: #Point A
    gotoPointA = False
 if not exists(img1, 0):
  wait(img2, FOREVER)
  click(img3)
  continue
 else:
  if exists(img1, 0):
  wait(img2, FOREVER)
  click(img4)
        while True: #Point B
         if not exists(img1, 0):
          wait(img2, FOREVER)
          click(img3)
          # continue # Want to restart from point A, not point B
          gotoPointA = True
          break
         else:
          if exists(img1, 0):
          wait(img2, FOREVER)
          click(img5)
          break
        if gotoPointA: continue

Revision history for this message
Martin (darknemesis-377) said :
#2

Thanks RaiMan, that solved my question.

Revision history for this message
Martin (darknemesis-377) said :
#3

Wow Raiman, you're a genius man!!! Thanks a lot! This totally solved my problem.

Revision history for this message
RaiMan (raimund-hocke) said :
#4

Thanks for feedback.

But genius is too much.
If you would have had the deep knowledge about the stuff in and around Sikuli, that I have now, then you would not have asked ;-)

Be sure, things will improve with your scripting efforts.

Feel free to come back whenever needed.