diff --git a/DivaBot/rectangle0.png b/DivaBot/rectangle0.png index ce7972b..c7c3e7a 100644 Binary files a/DivaBot/rectangle0.png and b/DivaBot/rectangle0.png differ diff --git a/DivaBot/rectangle1.png b/DivaBot/rectangle1.png index 7c832fb..cb77f87 100644 Binary files a/DivaBot/rectangle1.png and b/DivaBot/rectangle1.png differ diff --git a/DivaBot/rectangle2.png b/DivaBot/rectangle2.png index baec05f..3df74f1 100644 Binary files a/DivaBot/rectangle2.png and b/DivaBot/rectangle2.png differ diff --git a/DivaBot/rectangle3.png b/DivaBot/rectangle3.png index 25f679b..ef9b954 100644 Binary files a/DivaBot/rectangle3.png and b/DivaBot/rectangle3.png differ diff --git a/DivaBot/rectangle4.png b/DivaBot/rectangle4.png index 23a98f7..d320ffe 100644 Binary files a/DivaBot/rectangle4.png and b/DivaBot/rectangle4.png differ diff --git a/DivaBot/src/sig/FutureToneBot.java b/DivaBot/src/sig/FutureToneBot.java index 523c431..0cffd9a 100644 --- a/DivaBot/src/sig/FutureToneBot.java +++ b/DivaBot/src/sig/FutureToneBot.java @@ -221,21 +221,6 @@ public class FutureToneBot{ difficulty="H"; } } - private void GetCurrentSong() throws IOException { - BufferedImage img = ImageUtils.toCompatibleImage(MYROBOT.createScreenCapture(new Rectangle(460,426,WIDTH,HEIGHT))); - Color[] col = new Color[WIDTH*HEIGHT]; - for (int i=0;i180&& + failPixel.getGreen()<200&&failPixel.getGreen()>100&& + failPixel.getBlue()>190&&failPixel.getBlue()<240) { + result.fail = true; + } + }break; + } + + switch (result.mode) { + case MEGAMIX:{ + Color difficultyPixel = new Color(img2.getRGB(622, 110)); + result.difficulty = getDifficulty(difficultyPixel); + }break; + case FUTURETONE:{ + Color difficultyPixel = new Color(img2.getRGB(585, 70)); + result.difficulty = getFutureToneDifficulty(difficultyPixel); + }break; } - Color difficultyPixel = new Color(img2.getRGB(622, 110)); - result.difficulty = getDifficulty(difficultyPixel); - - result.mod = getMod(img2); - - //1109,435 - result.combo = extractNumbersFromImage(img2.getSubimage( - RECT_SEARCH_COMBO.x,RECT_SEARCH_COMBO.y,RECT_SEARCH_COMBO.width,RECT_SEARCH_COMBO.height),debug); - if (result.combo<0) { - return result; + //393,54 + switch (result.mode) { + case MEGAMIX:{ + result.mod = getMod(img2); + }break; + case FUTURETONE:{ + result.mod = getFutureToneMod(img2); + }break; } - result.score = extractScoreNumbersFromImage(img2.getSubimage( - RECT_SEARCH_SCORE.x,RECT_SEARCH_SCORE.y,RECT_SEARCH_SCORE.width,RECT_SEARCH_SCORE.height),debug); - if (result.score<0) { - return result; + switch (result.mode) { + case MEGAMIX:{ + //1109,435 + result.combo = extractNumbersFromImage(img2.getSubimage( + MEGAMIX_RECT_SEARCH_COMBO.x,MEGAMIX_RECT_SEARCH_COMBO.y,MEGAMIX_RECT_SEARCH_COMBO.width,MEGAMIX_RECT_SEARCH_COMBO.height),debug); + if (result.combo<0) { + return result; + } + + result.score = extractScoreNumbersFromImage(img2.getSubimage( + MEGAMIX_RECT_SEARCH_SCORE.x,MEGAMIX_RECT_SEARCH_SCORE.y,MEGAMIX_RECT_SEARCH_SCORE.width,MEGAMIX_RECT_SEARCH_SCORE.height),debug); + if (result.score<0) { + return result; + } + }break; + case FUTURETONE:{ + //1109,435 + result.combo = extractNumbersFromImage(img2.getSubimage( + FUTURETONE_RECT_SEARCH_COMBO.x,FUTURETONE_RECT_SEARCH_COMBO.y,FUTURETONE_RECT_SEARCH_COMBO.width,FUTURETONE_RECT_SEARCH_COMBO.height),debug); + if (result.combo<0) { + return result; + } + + result.score = extractFutureToneScoreNumbersFromImage(img2.getSubimage( + FUTURETONE_RECT_SEARCH_SCORE.x,FUTURETONE_RECT_SEARCH_SCORE.y,FUTURETONE_RECT_SEARCH_SCORE.width,FUTURETONE_RECT_SEARCH_SCORE.height),debug); + if (result.score<0) { + return result; + } + }break; } return result; } + private Mode getMode(BufferedImage img2) { + Color ft_pixel1 = new Color(img2.getRGB(260, 39)); + Color ft_pixel2 = new Color(img2.getRGB(86, 39)); + if (ft_pixel1.getRed()<60&&ft_pixel1.getRed()>0&& + ft_pixel1.getGreen()<90&&ft_pixel1.getGreen()>30&& + ft_pixel1.getBlue()<90&&ft_pixel1.getBlue()>30 + &&ft_pixel2.getRed()<60&&ft_pixel2.getRed()>0&& + ft_pixel2.getGreen()<90&&ft_pixel2.getGreen()>30&& + ft_pixel2.getBlue()<90&&ft_pixel2.getBlue()>30) { + return Mode.FUTURETONE; + } + return Mode.MEGAMIX; + } + + private String getFutureToneMod(BufferedImage img2) { + //393,54 HS R>125 + //423,72 HD G>100, R>125 + //454,54 SD G>100, B>125 + Color modPixel = new Color(img2.getRGB(393, 54)); + if (modPixel.getRed()>125&&modPixel.getGreen()>125&&modPixel.getBlue()>125) { + return ""; + } + if (modPixel.getRed()>125) {return "HS";} + modPixel = new Color(img2.getRGB(423, 72)); + if (modPixel.getGreen()>100&&modPixel.getRed()>125) {return "HD";} + modPixel = new Color(img2.getRGB(454, 54)); + if (modPixel.getGreen()>100&&modPixel.getBlue()>125) {return "SD";} + return ""; + } + private String getMod(BufferedImage img2) { //1082,101 HS R>125 //1113,122 HD G>100, R>125 @@ -141,6 +257,21 @@ public class TypeFace2 { return ""; } + private String getFutureToneDifficulty(Color difficultyPixel) { + String[] diffs = new String[] {"E","N","H","EX","EXEX"}; + Color[] cols = new Color[] {new Color(15,63,160),new Color(31,175,13),new Color(157,123,17),new Color(152,13,16),new Color(98,0,165),}; + int lowestDistance = Integer.MAX_VALUE; + int lowestIndex = -1; + for (int i=0;iFUTURETONE_RECT_SEARCH_PCT.width) { + int foundIndex = -1; + for (int i=0;i<10;i++) { + if (debug) { + test = new BufferedImage(18,18,BufferedImage.TYPE_INT_ARGB); + } + boolean ruleBreak=false; + + colorloop: + for (int x=0;x<18;x++) { + for (int y=0;y<18;y++) { + Color fontCol = new Color(futuretone_percentfont.getRGB(x+i*18,y)); + Color pixelCol = new Color(img.getRGB(xpointer-18+x+1, y+ypointer)); + /*if (fontCol.equals(Color.RED) && pixelCol.getRed()<50 + && pixelCol.getGreen()<150 && pixelCol.getBlue()>150) { + //Breaks a rule. + ruleBreak=true; + if (!debug) { + break colorloop; + } else { + test.setRGB(x, y, Color.RED.getRGB()); + } + } else + if (fontCol.equals(Color.GREEN) && (pixelCol.getRed()>50 + || pixelCol.getGreen()>170 || pixelCol.getBlue()<150)) { + //Breaks a rule. + ruleBreak=true; + if (!debug) { + break colorloop; + } else { + test.setRGB(x, y, Color.GREEN.getRGB()); + } + } else + if (debug) { + test.setRGB(x, y, pixelCol.getRGB()); + }*/ + + if (fontCol.equals(Color.RED)) { + if (lightColorCheck(pixelCol)) { + if (debug) { + test.setRGB(x, y, pixelCol.getRGB()); + } + } else { + ruleBreak=true; + if (!debug) { + break colorloop; + } else { + test.setRGB(x, y, Color.RED.getRGB()); + } + } + } else + if (fontCol.equals(Color.GREEN)) { + if (futureToneDarkColorCheck(pixelCol)) { + if (debug) { + test.setRGB(x, y, pixelCol.getRGB()); + } + } else { + ruleBreak=true; + if (!debug) { + break colorloop; + } else { + test.setRGB(x, y, Color.GREEN.getRGB()); + } + } + } else { + if (debug) { + test.setRGB(x, y, img.getRGB(xpointer-18+x+1, y+ypointer)); + } + } + } + } + if (!ruleBreak) { + foundIndex=i; + if (debug) { + System.out.println("Passes as "+((foundIndex+1)%10)); + } + } else + if (debug) { + ImageIO.write(test,"png",new File("debug",System.nanoTime()+"_"+((i+1)%10)+".png")); + } + } + + if (foundIndex!=-1) { + //System.out.println(" Closest Match: Index "+((shortestIndex+1)%10)+" ("+shortestDistance+")"); + if (decimal.equals("")) { + decimal = Integer.toString((foundIndex+1)%10); + } else { + decimal = Integer.toString((foundIndex+1)%10)+decimal; + } + if (debug) { + System.out.println("Input as "+((foundIndex+1)%10)); + System.out.println("-------------"); + } + xpointer-=18; + } else { + //Try shifting the xpointer slowly to the right and try again. + xpointer--; + } + } + if (decimal.length()>0) { + break trialloop; + } + ypointer++; + } + + xpointer=FUTURETONE_RECT_SEARCH_PCT2.x; + ypointer=FUTURETONE_RECT_SEARCH_PCT2.y; + trialloop: + while (ypointerFUTURETONE_RECT_SEARCH_PCT2.width) { + int foundIndex = -1; + for (int i=0;i<10;i++) { + if (debug) { + test = new BufferedImage(18,18,BufferedImage.TYPE_INT_ARGB); + } + boolean ruleBreak=false; + + colorloop: + for (int x=0;x<18;x++) { + for (int y=0;y<18;y++) { + Color fontCol = new Color(futuretone_percentfont.getRGB(x+i*18,y)); + Color pixelCol = new Color(img.getRGB(xpointer-18+x+1, y+ypointer)); + /*if (fontCol.equals(Color.RED) && pixelCol.getRed()<50 + && pixelCol.getGreen()<150 && pixelCol.getBlue()>150) { + //Breaks a rule. + ruleBreak=true; + if (!debug) { + break colorloop; + } else { + test.setRGB(x, y, Color.RED.getRGB()); + } + } else + if (fontCol.equals(Color.GREEN) && (pixelCol.getRed()>50 + || pixelCol.getGreen()>170 || pixelCol.getBlue()<150)) { + //Breaks a rule. + ruleBreak=true; + if (!debug) { + break colorloop; + } else { + test.setRGB(x, y, Color.GREEN.getRGB()); + } + } else + if (debug) { + test.setRGB(x, y, pixelCol.getRGB()); + }*/ + + if (fontCol.equals(Color.RED)) { + if (lightColorCheck(pixelCol)) { + if (debug) { + test.setRGB(x, y, pixelCol.getRGB()); + } + } else { + ruleBreak=true; + if (!debug) { + break colorloop; + } else { + test.setRGB(x, y, Color.RED.getRGB()); + } + } + } else + if (fontCol.equals(Color.GREEN)) { + if (futureToneDarkColorCheck(pixelCol)) { + if (debug) { + test.setRGB(x, y, pixelCol.getRGB()); + } + } else { + ruleBreak=true; + if (!debug) { + break colorloop; + } else { + test.setRGB(x, y, Color.GREEN.getRGB()); + } + } + } else { + if (debug) { + test.setRGB(x, y, img.getRGB(xpointer-18+x+1, y+ypointer)); + } + } + } + } + if (!ruleBreak) { + foundIndex=i; + if (debug) { + System.out.println("Passes as "+((foundIndex+1)%10)); + } + } else + if (debug) { + ImageIO.write(test,"png",new File("debug",System.nanoTime()+"_"+((i+1)%10)+".png")); + } + } + + if (foundIndex!=-1) { + //System.out.println(" Closest Match: Index "+((shortestIndex+1)%10)+" ("+shortestDistance+")"); + if (integer.equals("")) { + integer = Integer.toString((foundIndex+1)%10); + } else { + integer = Integer.toString((foundIndex+1)%10)+integer; + } + if (debug) { + System.out.println("Input as "+((foundIndex+1)%10)); + System.out.println("-------------"); + } + xpointer-=18; + } else { + //Try shifting the xpointer slowly to the right and try again. + xpointer--; + } + } + if (integer.length()>0) { + break trialloop; + } + ypointer++; + } + if (integer.length()>0&&decimal.length()>0) { + return Float.parseFloat(integer+"."+decimal); + } else { + return -1.0f; + } + } + public float extractPercentFromImage(BufferedImage img,boolean debug) throws IOException { //1180,167 //second part: 1123 String decimal = ""; String integer = ""; - xpointer=RECT_SEARCH_PCT.x; - ypointer=RECT_SEARCH_PCT.y; + xpointer=MEGAMIX_RECT_SEARCH_PCT.x; + ypointer=MEGAMIX_RECT_SEARCH_PCT.y; BufferedImage test = null; trialloop: - while (ypointerRECT_SEARCH_PCT.width) { + while (ypointerMEGAMIX_RECT_SEARCH_PCT.width) { int foundIndex = -1; for (int i=0;i<10;i++) { if (debug) { @@ -277,12 +641,12 @@ public class TypeFace2 { ypointer++; } - xpointer=RECT_SEARCH_PCT2.x; - ypointer=RECT_SEARCH_PCT2.y; + xpointer=MEGAMIX_RECT_SEARCH_PCT2.x; + ypointer=MEGAMIX_RECT_SEARCH_PCT2.y; trialloop: - while (ypointerRECT_SEARCH_PCT2.width) { + while (ypointerMEGAMIX_RECT_SEARCH_PCT2.width) { int foundIndex = -1; for (int i=0;i<10;i++) { if (debug) { @@ -403,6 +767,10 @@ public class TypeFace2 { return pixel.getRed()<110 && pixel.getGreen()<176 && pixel.getBlue()>100; } + private boolean futureToneDarkColorCheck(Color pixel) { + return pixel.getRed()<176 + && pixel.getGreen()<176 && pixel.getBlue()>100; + } public int extractNumbersFromImage(BufferedImage img) throws IOException { return extractNumbersFromImage(img,false); @@ -412,12 +780,12 @@ public class TypeFace2 { this.img=img; File f = null; BufferedImage test = null; - xpointer=RECT_SEARCH_COOL.width-1; + xpointer=MEGAMIX_RECT_SEARCH_COOL.width-1; ypointer=0; String total = ""; trialloop: while (ypointer<8) { - xpointer=RECT_SEARCH_COOL.width-1; + xpointer=MEGAMIX_RECT_SEARCH_COOL.width-1; while (xpointer>22) { int distance = 0; int foundIndex = -1; @@ -498,16 +866,106 @@ public class TypeFace2 { } } + public int extractFutureToneScoreNumbersFromImage(BufferedImage img,boolean debug) throws IOException { + this.img=img; + File f = null; + BufferedImage test = null; + xpointer=FUTURETONE_RECT_SEARCH_SCORE.width-1; + ypointer=0; + String total = ""; + trialloop: + while (ypointer<12) { + xpointer=FUTURETONE_RECT_SEARCH_SCORE.width-1; + while (xpointer>31) { + int distance = 0; + int foundIndex = -1; + //Compare the 22x21 range. + for (int i=0;i<10;i++) { + if (debug) { + test = new BufferedImage(28,27,BufferedImage.TYPE_INT_ARGB); + } + boolean ruleBreak=false; + + colorloop: + for (int x=0;x<28;x++) { + for (int y=0;y<27;y++) { + Color fontCol = new Color(futuretone_scorefont.getRGB(x+i*28,y)); + Color pixelCol = new Color(img.getRGB(xpointer-28+x+1, y+ypointer)); + if (fontCol.equals(Color.RED) && pixelCol.getRed()<200 + && pixelCol.getGreen()<200 && pixelCol.getBlue()<200 + /*pixelCol.getRed()+pixelCol.getGreen()+pixelCol.getBlue()<490*/) { + ruleBreak=true; + if (!debug) { + break colorloop; + } else { + test.setRGB(x, y, Color.RED.getRGB()); + } + } else + if (fontCol.equals(Color.GREEN) && (pixelCol.getRed()>166 + || pixelCol.getGreen()>171 || pixelCol.getBlue()>185)) { + //Breaks a rule. + ruleBreak=true; + if (!debug) { + break colorloop; + } else { + test.setRGB(x, y, Color.GREEN.getRGB()); + } + } else + if (debug) { + test.setRGB(x, y, pixelCol.getRGB()); + } + } + } + if (!ruleBreak) { + foundIndex=i; + if (debug) { + System.out.println("Passes as "+((foundIndex+1)%10)); + } + } else + if (debug) { + ImageIO.write(test,"png",new File("debug",System.nanoTime()+"_"+((i+1)%10)+".png")); + } + } + if (foundIndex!=-1) { + //System.out.println(" Closest Match: Index "+((shortestIndex+1)%10)+" ("+shortestDistance+")"); + if (total.equals("")) { + total = Integer.toString((foundIndex+1)%10); + } else { + total = Integer.toString((foundIndex+1)%10)+total; + } + if (debug) { + System.out.println("Input as "+((foundIndex+1)%10)); + System.out.println("-------------"); + } + xpointer-=28; + } else { + //Try shifting the xpointer slowly to the right and try again. + xpointer--; + } + } + if (total.length()>0) { + break trialloop; + } + ypointer++; + } + + if (total.equals("")) { + return -1; + } else { + return Integer.parseInt(total); + } + } + public int extractScoreNumbersFromImage(BufferedImage img,boolean debug) throws IOException { this.img=img; File f = null; BufferedImage test = null; - xpointer=RECT_SEARCH_SCORE.width-1; + xpointer=MEGAMIX_RECT_SEARCH_SCORE.width-1; ypointer=0; String total = ""; trialloop: while (ypointer<12) { - xpointer=RECT_SEARCH_SCORE.width-1; + xpointer=MEGAMIX_RECT_SEARCH_SCORE.width-1; while (xpointer>31) { int distance = 0; int foundIndex = -1; diff --git a/DivaBot/testsuite/test38.jpg b/DivaBot/testsuite/test38.jpg new file mode 100644 index 0000000..a25f922 Binary files /dev/null and b/DivaBot/testsuite/test38.jpg differ diff --git a/DivaBot/testsuite/test39.jpg b/DivaBot/testsuite/test39.jpg new file mode 100644 index 0000000..b88bcd5 Binary files /dev/null and b/DivaBot/testsuite/test39.jpg differ diff --git a/DivaBot/typeface4.png b/DivaBot/typeface4.png new file mode 100644 index 0000000..a498992 Binary files /dev/null and b/DivaBot/typeface4.png differ diff --git a/DivaBot/typeface5.png b/DivaBot/typeface5.png new file mode 100644 index 0000000..3f8bbb9 Binary files /dev/null and b/DivaBot/typeface5.png differ diff --git a/Release/DivaBot03.zip b/Release/DivaBot03.zip new file mode 100644 index 0000000..1202253 Binary files /dev/null and b/Release/DivaBot03.zip differ