sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #46614
Re: [Question #666773]: How to get on the road as a newcomer to Java programming
Question #666773 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/666773
RaiMan posted a new comment:
I made some changes - see //raiman ;-)
The Settings.MinSimilarity is "recognized" in the Finder.
a good start is 0.9 (as suggested).
With my code you get feedback about the scores, so you might adjust the setting as needed.
Debug.user instead of System.out.println has the advantage, that you get
a timestamp for free and can use the String.format() systematic.
import org.sikuli.script.*;
import org.sikuli.basics.Debug;
import org.sikuli.basics.Settings;
public class TestAuto {
public static double Settings.MinSimilarity = 0.9; //raiman
public static float Settings.MoveMouseDelay = 0f; //raiman
static Screen s = new Screen();
static final String n0 = "number0.png"; //raiman
static final String n1 = "number1.png"; //raiman
static final String n2 = "number2.png"; //raiman
static final String n3 = "number3.png"; //raiman
static final String n4 = "number4.png"; //raiman
static final String n5 = "number5.png"; //raiman
static final String n6 = "number6.png"; //raiman
static final String n7 = "number7.png"; //raiman
static final String n8 = "number8.png"; //raiman
static final String n9 = "number9.png"; //raiman
public static void main(String[] args) throws FindFailed,
InterruptedException {
Debug.setDebugLevel(3);
Match reRoll = s.find(new Pattern("Reroll.png"));
Match totalRollLocator = s.find(new Pattern("TotalRoll.png"));
Match strLocator = s.find(new Pattern("Strength.png").targetOffset(170, 0));
Match intLocator = s.find(new Pattern("Intelligence.png").targetOffset(220, 0));
Match wisLocator = s.find(new Pattern("Wisdom.png").targetOffset(220, 0));
// raiman: use .x and .y instead of .getX() and .getY() - shorter ;-)
Region totalRollArea = new Region(totalRollLocator.getTopRight().x, totalRollLocator.getTopRight().y, 70, 50);
Region tensDigitsArea = new Region(totalRollLocator.getTopRight().x + 30, totalRollLocator.getTopRight().y, 15, 12);
Region onesDigitsArea = new Region(totalRollLocator.getTopRight().x + 42, totalRollLocator.getTopRight().y, 17, 12);
int tensDigitsValue = 0;
int onesDigitsValue = 0;
int totalRollValue = 0;
for (int i = 0; i < 50; i++) {
// while (true) {
Match tensDigitsRoll = tensDigitsArea.findBest(n0, n1, n2, n3, n4, n5, n6, n7, n8, n9); //raiman
tensDigitsValue = tensDigitsRoll.getIndex() * 10;
//System.out.println(tensDigitsRoll.getIndex());
Debug.user("tensDigit: %d score: %f", tensDigitsValue / 10, tensDigitsRoll.getScore()); //raiman
Match onesDigitsRoll = onesDigitsArea.findBest(n0, n1, n2, n3, n4, n5, n6, n7, n8, n9); //raiman
onesDigitsValue = onesDigitsRoll.getIndex(); //raiman: moved here
//System.out.println(onesDigitsRoll.getIndex());
Debug.user("onesDigit: %d score: %f", onesDigitsValue, onesDigitsRoll.getScore()); //raiman
{
//Thread.sleep(200);
wait(0.2f); //raiman
}
totalRollValue = tensDigitsValue + onesDigitsValue;
if (totalRollValue >= 85) {
//System.out.println(totalRollValue);
Debug.user("rollValue: %d", totalRollValue); //raiman
break;
} else {
reRoll.click();
}
}
}
}
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.