Sikuli fight script works slow

Asked by Wiw3K kisu on 2012-08-15

Hey, i wonder why my script works sloooowlyyy it waits bunch ammount of time and sometimes stops working no idea why,.
If anyone can check it :)

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:
Best RaiMan (raimund-hocke) said : #1

LOL (sorry ;-), I really waited on that question :-)
... since it is clear: it is a game bot and they must be as fast as possible.

--1: All your searches are on the whole screen.
This means, that every search can take up to 1 sec depending on your machine.
Restrict the searches to regions, where you expect the target to be and your search time could be decreased to 1/10

--2. you use exists() very often
If it does not find, then it only gives up after the standard 3 seconds waiting time (which makes sense in normal workflows, where you click something and wait for the next image to appear).
So in cases, where you only want to know if something is there or not (this is why we have exists), simply use
exists(image, 0)
and it will do only one search and come back immediately if not found.
Due to a bug, if search fails it returns earliest after 0.3 seconds, even if the search was done in some milliseconds.
If you want to squeeze this:
Settings.WaitScanRate = 10
which makes it to return earliest after 0.1 seconds, which should be sufficient

--3: mouse movement
the mouse movement is animated and every mouse move takes 0.5 seconds (standard).
If you do not want that:
Settings.MoveMouseDelay = 0

--4: use what you already found (did not check, wether it applies in your case)
many people script this
wait("some-button.png", 10)

this adds another search for the same visual object with the click, so this is better:
wait("some-button.png", 10)
which simply clicks the match, that was found with the wait before and might save you 1 second.

Last but not least:
Just scanning the docs and the faqs, might give you the one or other hint, what is possible and how to do it efficiently.

Wiw3K kisu (kisu1337) said : #2

Thanks RaiMan, that solved my question.

patrick (patrick-cresham) said : #3

Hint 3 & 4 helped me a lot, thanks