← Back to team overview

sikuli-driver team mailing list archive

[Bug 1275728] Re: [request] want to select randomly from a list of matches (e.g. findAll())

 

I would suggest that Sikuli doesn't need to re-invent the wheel here,
python already has a lot of ways of shuffling a list. E.g if you have:

    matches=findAll(pat)

Adding just one line (plus an import) will give you what you want:

    from random import shuffle

    matches=findAll(pat)
    shuffle(matches)

Simples :-)

-- 
You received this bug notification because you are a member of Sikuli
Drivers, which is subscribed to Sikuli.
https://bugs.launchpad.net/bugs/1275728

Title:
  [request] want to select randomly from a list of matches (e.g.
  findAll())

Status in Sikuli:
  In Progress

Bug description:
  *** workaround on the Python level (SikuliX script):
  import random
  click(random.choice(list(<some_region>.findAll(<some-image-or-pattern>)))))

  ----------------------------------------------------------

  I need sikuli to choose randomly from its image recognition findings,
  how is that possible?

  My code in this case is:

   exists("autoSpectate.png",9999) # Wait for Spectate
   click("autoSpectate-1.png") # Click on Spectate

  There are normally a few "Spectate"s, but it mostly clicks on the same
  one.

   Is there a possiblility to make it randomized intentionally?

  Thanks!
  ---------------------------------------------------------------
  Seem to be a good idea to develop.
  Look at the question to find the actual workaround.

To manage notifications about this bug go to:
https://bugs.launchpad.net/sikuli/+bug/1275728/+subscriptions


References