This commit is contained in:
mrbesen 2017-05-26 09:28:53 +02:00
parent 7cf4f9aeb0
commit 42fc334ed4
3 changed files with 50 additions and 9 deletions

View File

@ -31,6 +31,8 @@ public class Clicker implements Runnable{
private boolean doubleplayout = true;
private int truppenwait = 180;
private int randomness = 15;
private int mincolordistance = 35;
private void sleep( int ms) {
if(skipbattle)
@ -137,6 +139,7 @@ public class Clicker implements Runnable{
sleep(9000);//9 sec-loading screen
//checken, ob Arena wechsel pop-up
while(checkOK(arena_switch, rob,arena_view)) {
System.out.println("Arena found, clicking");
clickL(rob, arena_switch);
sleep(2000);
}
@ -264,16 +267,16 @@ public class Clicker implements Runnable{
for (int y = 0; y < 20; y++) {
int color = img.getRGB(x, y);
int red = (color & 0x00ff0000) >> 16;
int green = (color & 0x0000ff00) >> 8;
int blue = color & 0x000000ff;
double distance = Math.sqrt(Math.pow((blue - goalcolor.getBlue()), 2)
int green = (color & 0x0000ff00) >> 8;
int blue = color & 0x000000ff;
double distance = Math.sqrt(Math.pow((blue - goalcolor.getBlue()), 2)
+ Math.pow((red - goalcolor.getRed()), 2) + Math.pow((green - goalcolor.getGreen()), 2));//calculate the distance between the goalcolor and the test color
if (distance < 25)
if (distance < mincolordistance)
count++;
}
}
// System.out.println("checking ok takes: " + (System.currentTimeMillis() - start));//some performance checking
// System.out.println("counts: " + count);//some performance checking
return count > 70;
}
@ -301,7 +304,7 @@ public class Clicker implements Runnable{
* @param c Color
* @param colornum nummber (0=ok-button, 1=arena_view-button)
*/
public void setColor(Color c, int colornum) {
public void setColor(Color c, int colornum, int minimumdistance) {
switch(colornum) {
case 0:
ok_button = c;
@ -310,6 +313,8 @@ public class Clicker implements Runnable{
arena_view = c;
break;
}
if(mincolordistance < minimumdistance)
mincolordistance = minimumdistance;
System.out.println(colornum + ": "+c.getRed() + " " + c.getGreen() + " " + c.getBlue());
}
}

View File

@ -5,6 +5,9 @@ import java.awt.Color;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.image.BufferedImage;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
public class PosColSelector extends PosSelector {
@ -40,7 +43,40 @@ public class PosColSelector extends PosSelector {
blue /= count;
green /= count;
Color c = new Color(red, green, blue);
ui.bot.setColor(c,colornum);
//calculate distances:
List<Integer> dist = new LinkedList<Integer>();
for (int x = 0; x < 20; x++) {
for (int y = 0; y < 20; y++) {
int color = img.getRGB(x, y);
int redf = (color & 0x00ff0000) >> 16;
int greenf = (color & 0x0000ff00) >> 8;
int bluef = color & 0x000000ff;
double distance = Math.sqrt(Math.pow((bluef - c.getBlue()), 2)
+ Math.pow((redf - c.getRed()), 2) + Math.pow((greenf - c.getGreen()), 2));
dist.add((int) distance);
// System.out.println(distance);
}
}
dist.sort(new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
if(o1 < o2)
return -1;
if(o1== o2)
return 0;
if(o1 > o2)
return 1;
return 0;
}
});
int miniumdistance = dist.get(150);//at least the first 100 tests should fit
// int maximumdistance = dist.get(dist.size()-1);
System.out.println("minimum distance: " + miniumdistance );
ui.bot.setColor(c,colornum, miniumdistance);
ui.bot.set(p, num);
} catch(AWTException e) {
e.printStackTrace();
}

View File

@ -214,10 +214,10 @@ public class UI implements ActionListener {
slider[1].setValue(Integer.parseInt(split[1]));
} else if(num == 104) {
Color c = new Color(Integer.parseInt(split[1]), Integer.parseInt(split[2]), Integer.parseInt(split[3]));
bot.setColor(c, 1);
bot.setColor(c, 1,35);
} else if(num == 105) {
Color c = new Color(Integer.parseInt(split[1]), Integer.parseInt(split[2]), Integer.parseInt(split[3]));
bot.setColor(c, 0);
bot.setColor(c, 0,35);
}
} else //standard Point Obj.
bot.set(new Point(split[1]), num);