Added combo and score detection for song select.

secondmonitor
sigonasr2 4 years ago
parent 64d67417af
commit 90613ea4ba
  1. 5
      DivaBot/colorData
  2. 89
      DivaBot/src/sig/MyRobot.java
  3. 14
      DivaBot/src/sig/Result.java
  4. 7
      DivaBot/src/sig/TestMain.java
  5. 102
      DivaBot/src/sig/TypeFace2.java

File diff suppressed because one or more lines are too long

@ -81,7 +81,7 @@ public class MyRobot{
static SongData SONGS[];
//static String SONGNAMES[] = new String[] {"Yellow","The secret garden","Tell Your World","愛言葉","Weekender Girl","歌に形はないけれど","えれくとりっく・えんじぇぅ","神曲","カンタレラ","巨大少女","クローバー♣クラブ","恋スルVOC@LOID","桜ノ雨","39","深海シティアンダーグラウンド","深海少女","積乱雲グラフィティ","千年の独奏歌","ダブルラリアット","ハジメテノオト","初めての恋が終わる時","packaged","Palette","FREELY TOMORROW","from Y to Y","みくみくにしてあげる♪","メルト","モノクロ∞ブルースカイ","ゆめゆめ","16 -out of the gravity-","ACUTE","インタビュア","LOL -lots of laugh-","Glory 3usi9","soundless voice","ジェミニ","白い雪のプリンセスは","スキキライ","タイムマシン","Dear","DECORATOR","トリコロール・エア・ライン","Nostalogic","Hand in Hand","Fire◎Flower","ブラック★ロックシューター","メテオ","ワールドイズマイン","アマツキツネ","erase or zero","エレクトロサチュレイタ","on the rocks","からくりピエロ","カラフル×メロディ","Catch the Wave","キャットフード","サマーアイドル","shake it!","Just Be Friends","スイートマジック","SPiCa -39's Giving Day Edition-","番凩","テレカクシ思春期","天樂","どういうことなの!?","東京テディベア","どりーみんチュチュ","トリノコシティ","ネトゲ廃人シュプレヒコール","No Logic","ハイハハイニ","はじめまして地球人さん","*ハロー、プラネット。 (I.M.PLSE-EDIT)","Hello, Worker","忘却心中","magnet","右肩の蝶","結ンデ開イテ羅刹ト骸","メランコリック","リモコン","ルカルカ★ナイトフィーバー","炉心融解","WORLD'S END UMBRELLA","アカツキアライヴァル","アゲアゲアゲイン","1925","え?あぁ、そう。","エイリアンエイリアン","ODDS&ENDS","君の体温","こっち向いて Baby","壊セ壊セ","39みゅーじっく!","サンドリヨン","SING&SMILE","スノーマン","DYE","なりすましゲンガー","ヒバナ","ヒビカセ","ブラックゴールド","ミラクルペイント","指切り","ありふれたせかいせいふく","アンハッピーリフレイン","大江戸ジュリアナイト","ゴーストルール","こちら、幸福安心委員会です。","孤独の果て -extend edition-","ジターバグ","Sweet Devil","砂の惑星","テオ","初音ミクの消失 -DEAD END-","秘密警察","妄想スケッチ","リンちゃんなう!","ローリンガール","ロキ","ロミオとシンデレラ","エンヴィキャットウォーク","骸骨楽団とリリア","サイハテ","ジグソーパズル","千本桜","ピアノ×フォルテ×スキャンダル","Blackjack","ぽっぴっぽー","裏表ラバーズ","Sadistic.Music∞Factory","デンパラダイム","二次元ドリームフィーバー","ネガポジ*コンティニューズ","初音ミクの激唱","ワールズエンド・ダンスホール","ココロ","システマティック・ラヴ","Knife","二息歩行","PIANOGIRL","夢喰い白黒バク","ブレス・ユア・ブレス","恋は戦争","あなたの歌姫","Starduster","StargazeR","リンリンシグナル","Rosary Pale","多重未来のカルテット~QUARTET THEME~","LIKE THE WIND","AFTER BURNER"};
static SongInfo SONGNAMES[] = new SongInfo[] {};
static String NEWSONGS[] = new String[] {"ワールドイズマイン"};
static String NEWSONGS[] = new String[] {"裏表ラバーズ"};
int SCREEN_X;
int SCREEN_Y;
int WINDOW_X;
@ -112,7 +112,7 @@ public class MyRobot{
static String difficulty = "H"; //H=Hard EX=Extreme EXEX=Extra Extreme
static boolean recordedResults=false;
int lastcool,lastfine,lastsafe,lastsad,lastworst;
int lastcool,lastfine,lastsafe,lastsad,lastworst,lastcombo,lastscore;
float lastpercent;
boolean lastfail;
long lastSongSelectTime = System.currentTimeMillis();
@ -225,13 +225,14 @@ public class MyRobot{
try {
Result data = typeface1.getAllData(MYROBOT.createScoreScreenCapture());
//ImageIO.write(MYROBOT.createNormalScreenCapture(new Rectangle(418,204,1227,690)),"png",new File("test.png"));
if (data.cool==-1 || data.fine==-1 || data.safe==-1 || data.sad==-1 || data.worst==-1 || data.percent<0f || data.percent>110f) {
if (data.cool==-1 || data.fine==-1 || data.safe==-1 || data.sad==-1 || data.worst==-1 || data.percent<0f || data.percent>110f || data.combo==-1 || data.score==-1) {
System.out.println("Waiting for results to populate...");
} else
if (data.fail!=lastfail || data.cool!=lastcool || lastfine!=data.fine || lastsafe!=data.safe || lastsad!=data.sad || lastworst!=data.worst /*|| lastpercent!=percent*/){
System.out.println("Results for "+selectedSong.title+" "+difficulty+": "+data.cool+"/"+data.fine+"/"+data.safe+"/"+data.sad+"/"+data.worst+" "+data.percent+"%");
if ((data.combo!=lastcombo || data.fail!=lastfail || data.cool!=lastcool || lastfine!=data.fine || lastsafe!=data.safe || lastsad!=data.sad || lastworst!=data.worst)
&& data.score!=lastscore /*|| lastpercent!=percent*/){
//System.out.println("Results for "+selectedSong.title+" "+difficulty+": "+data.cool+"/"+data.fine+"/"+data.safe+"/"+data.sad+"/"+data.worst+" "+data.percent+"%");
System.out.println("Results for "+selectedSong.title+" "+difficulty+": "+data.cool+"/"+data.fine+"/"+data.safe+"/"+data.sad+"/"+data.worst+" "+data.percent+"%");
System.out.println("Results for "+selectedSong.title+" "+difficulty+": "+data.display());
File songFolder = new File(selectedSong.title+"/"+difficulty);
if (!songFolder.exists()) {
songFolder.mkdirs();
@ -247,9 +248,12 @@ public class MyRobot{
lastsad=data.sad;
lastworst=data.worst;
lastpercent=data.percent;
lastcombo=data.combo;
lastscore=data.score;
lastfail=data.fail;
new File("scoreimage.png").renameTo(new File(playFolder,selectedSong.title+"_"+difficulty+"play_"+data.cool+"_"+data.fine+"_"+data.safe+"_"+data.sad+"_"+data.worst+"_"+data.percent+".png"));
results.add(new Result(selectedSong.title,difficulty,data.cool,data.fine,data.safe,data.sad,data.worst,data.percent,data.fail));
new File("scoreimage.png").renameTo(new File(playFolder,selectedSong.title+"_"+difficulty+"play_"+data.cool+"_"+data.fine+"_"+data.safe+"_"+data.sad+"_"+data.worst+"_"+data.percent+""
+ "_"+data.combo+"_"+data.score+".png"));
results.add(new Result(selectedSong.title,difficulty,data.cool,data.fine,data.safe,data.sad,data.worst,data.percent,data.combo,data.score,data.fail));
SoundUtils.playSound("collect_item.wav");
//gotoxy(800,64);
//click();
@ -285,7 +289,9 @@ public class MyRobot{
params.add(new BasicNameValuePair("worst", Integer.toString(r.worst)));
params.add(new BasicNameValuePair("percent", Float.toString(r.percent)));
params.add(new BasicNameValuePair("fail", Boolean.toString(r.fail)));
params.add(new BasicNameValuePair("mod", "HS"));
params.add(new BasicNameValuePair("mod", r.mod));
params.add(new BasicNameValuePair("combo", Integer.toString(r.combo)));
params.add(new BasicNameValuePair("gameScore", Integer.toString(r.score)));
try {
httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
} catch (UnsupportedEncodingException e) {
@ -409,7 +415,8 @@ public class MyRobot{
try {
typeface1 = new TypeFace2(
ImageIO.read(new File("typeface.png")),
ImageIO.read(new File("typeface2.png"))
ImageIO.read(new File("typeface2.png")),
ImageIO.read(new File("typeface3.png"))
);
} catch (IOException e1) {
e1.printStackTrace();
@ -454,40 +461,40 @@ public class MyRobot{
selectedSong=new SongData("LIKE THE WIND",new Color[] {});
difficulty="H";
RunTest("test1.jpg",393,127,28,10,48,72.28f,"EXEX","",false);
RunTest("test2.jpg",518,144,17,3,23,81.94f,"H","",false);
RunTest("test3.jpg",646,54,1,0,0,103.06f,"EX","",false);
RunTest("test4.jpg",518,64,0,0,0,102.57f,"H","",false);
RunTest("test5.jpg",276,58,3,0,0,89.64f,"E","",false);
RunTest("test6.jpg",448,129,17,7,42,79.22f,"EXEX","",false);
RunTest("test7.jpg",419,227,28,7,20,75.76f,"EX","",false);
RunTest("test8.jpg",567,26,0,0,0,104.31f,"EX","",false);
RunTest("test9.jpg",197,51,0,0,0,100.02f,"H","",false);
RunTest("test10.jpg",486,245,46,22,59,65.34f,"H","SD",false);
RunTest("test11.jpg",0,0,0,0,159,0.00f,"EX","SD",true);
RunTest("test12.jpg",0,0,0,0,79,0.08f,"EX","HD",true);
RunTest("test13.jpg",245,19,4,0,2,87.04f,"E","",false);
RunTest("test14.png",623,39,1,0,0,100.83f,"EXEX","HS",false);
RunTest("test15.png",540,57,1,0,3,98.05f,"EX","HS",false);
RunTest("test16.png",320,46,2,0,4,93.26f,"EXEX","HS",false);
RunTest("test17.png",431,30,3,0,3,100.51f,"EXEX","HS",false);
RunTest("test18.png",427,86,5,1,4,92.45f,"EX","HS",false);
RunTest("testimage.png",371,40,3,4,3,97.63f,"EX","HS",false);
RunTest("testimage2.png",942,71,1,0,3,97.02f,"EXEX","",false);
RunTest("testimage3.png",546,52,0,0,0,101.77f,"EX","",false);
RunTest("testimage4.png",279,81,16,2,3,75.40f,"N","",false);
RunTest("testimage5.png",276,184,6,1,11,82.16f,"EXEX","HS",false);
RunTest("testimage6.png",455,60,2,0,8,93.48f,"EXEX","HS",false);
RunTest("testimage7.png",452,128,8,2,16,88.28f,"EXEX","HS",false);
RunTest("testimage8.png",229,38,2,0,13,83.25f,"EXEX","HS",false);
RunTest("testimage9.png",413,70,1,0,21,82.66f,"EXEX","HS",false);
RunTest("test1.jpg",393,127,28,10,48,72.28f,"EXEX","",85,577160,false);
RunTest("test2.jpg",518,144,17,3,23,81.94f,"H","",98,580090,false);
RunTest("test3.jpg",646,54,1,0,0,103.06f,"EX","",691,666410,false);
RunTest("test4.jpg",518,64,0,0,0,102.57f,"H","",582,470770,false);
RunTest("test5.jpg",276,58,3,0,0,89.64f,"E","",215,238240,false);
RunTest("test6.jpg",448,129,17,7,42,79.22f,"EXEX","",90,760770,false);
RunTest("test7.jpg",419,227,28,7,20,75.76f,"EX","",154,473340,false);
RunTest("test8.jpg",567,26,0,0,0,104.31f,"EX","",593,569500,false);
RunTest("test9.jpg",197,51,0,0,0,100.02f,"H","",248,194700,false);
RunTest("test10.jpg",486,245,46,22,59,65.34f,"H","SD",89,495850,false);
RunTest("test11.jpg",0,0,0,0,159,0.00f,"EX","SD",0,0,true);
RunTest("test12.jpg",0,0,0,0,79,0.08f,"EX","HD",0,580,true);
RunTest("test13.jpg",245,19,4,0,2,87.04f,"E","",103,179360,false);
RunTest("test14.png",623,39,1,0,0,100.83f,"EXEX","HS",350,869180,false);
RunTest("test15.png",540,57,1,0,3,98.05f,"EX","HS",225,602000,false);
RunTest("test16.png",320,46,2,0,4,93.26f,"EXEX","HS",135,463170,false);
RunTest("test17.png",431,30,3,0,3,100.51f,"EXEX","HS",386,581700,false);
RunTest("test18.png",427,86,5,1,4,92.45f,"EX","HS",136,526740,false);
RunTest("testimage.png",371,40,3,4,3,97.63f,"EX","HS",233,523750,false);
RunTest("testimage2.png",942,71,1,0,3,97.02f,"EXEX","",714,951020,false);
RunTest("testimage3.png",546,52,0,0,0,101.77f,"EX","",598,567430,false);
RunTest("testimage4.png",279,81,16,2,3,75.40f,"N","",85,228100,false);
RunTest("testimage5.png",276,184,6,1,11,82.16f,"EXEX","HS",78,549870,false);
RunTest("testimage6.png",455,60,2,0,8,93.48f,"EXEX","HS",272,532470,false);
RunTest("testimage7.png",452,128,8,2,16,88.28f,"EXEX","HS",146,773150,false);
RunTest("testimage8.png",229,38,2,0,13,83.25f,"EXEX","HS",65,300120,false);
RunTest("testimage9.png",413,70,1,0,21,82.66f,"EXEX","HS",94,443050,false);
}
void RunTest(String _img,int _cool,int _fine, int _safe, int _sad, int _worst, float _percent,String _difficulty,String _mod,boolean _fail) throws IOException {
RunTest(_img,_cool,_fine,_safe,_sad,_worst,_percent,_difficulty,_mod,_fail,false);
void RunTest(String _img,int _cool,int _fine, int _safe, int _sad, int _worst, float _percent,String _difficulty,String _mod,int _combo,int _score,boolean _fail) throws IOException {
RunTest(_img,_cool,_fine,_safe,_sad,_worst,_percent,_difficulty,_mod,_combo,_score,_fail,false);
}
void RunTest(String _img,int _cool,int _fine, int _safe, int _sad, int _worst, float _percent,String _difficulty,String _mod,boolean _fail,boolean debug) throws IOException {
void RunTest(String _img,int _cool,int _fine, int _safe, int _sad, int _worst, float _percent,String _difficulty,String _mod,int _combo,int _score,boolean _fail,boolean debug) throws IOException {
System.out.println("Running test "+_img);
long startTime = System.currentTimeMillis();
String testdir="testsuite";
@ -514,6 +521,8 @@ public class MyRobot{
assert data.fail == _fail : "Expected fail to be "+_fail+", got "+data.fail;
assert data.mod == _mod : "Expected mod to be "+_mod+", got "+data.mod;
assert data.difficulty == _difficulty : "Expected difficulty to be "+_difficulty+", got "+data.difficulty;
assert data.combo == _combo : "Expected combo to be "+_combo+", got "+data.combo;
assert data.score == _score : "Expected score to be "+_score+", got "+data.score;
System.out.println(" Passed ("+(System.currentTimeMillis()-startTime)+"ms)!");
}

@ -10,6 +10,7 @@ public class Result {
float percent;
boolean fail;
String mod;
int combo,score;
public Result(String song,String diff,int cool,int fine,int safe,int sad,int worst,float percent) {
this.songName=song;
this.difficulty=diff;
@ -20,18 +21,27 @@ public class Result {
this.worst=worst;
this.percent=percent;
this.mod="";
this.combo=-1;
this.score=-1;
}
public Result(String song,String diff,int cool,int fine,int safe,int sad,int worst,float percent,boolean fail) {
this(song,diff,cool,fine,safe,sad,worst,percent);
this.fail=fail;
}
public Result(String song,String diff,int cool,int fine,int safe,int sad,int worst,float percent,int combo, int score,boolean fail) {
this(song,diff,cool,fine,safe,sad,worst,percent,fail);
this.combo=combo;
this.score=score;
}
public String display() {
return new StringBuilder(Integer.toString(cool)).append("/").append(fine)
.append("/").append(safe).append("/").append(sad).append("/").append(worst).append(" ").append(percent).append("%").toString();
.append("/").append(safe).append("/").append(sad).append("/").append(worst).append(" ").append(percent).append("%")
.append(" ").append(combo).append(" ").append(score).toString();
}
public String displayDebug() {
return new StringBuilder(Integer.toString(cool)).append(",").append(fine)
.append(",").append(safe).append(",").append(sad).append(",").append(worst).append(",").append(percent).append("f")
.append(",\"").append(difficulty).append("\",\"").append(mod).append("\",").append(Boolean.toString(fail).toLowerCase()).toString();
.append(",\"").append(difficulty).append("\",\"").append(mod).append("\",").append(Boolean.toString(fail).toLowerCase())
.append(",").append(combo).append(",").append(score).toString();
}
}

@ -15,14 +15,15 @@ public class TestMain {
TypeFace2 font = new TypeFace2(
ImageIO.read(new File("typeface.png")),
ImageIO.read(new File("typeface2.png"))
ImageIO.read(new File("typeface2.png")),
ImageIO.read(new File("typeface3.png"))
);
/*CustomRobot r = new CustomRobot();
Thread.sleep(3000);
r.refreshScoreScreen();
ImageIO.write(r.scoreCurrentScreen,"png",new File("testsuite","liveimage.png"));*/
System.out.println(font.getAllData(ImageIO.read(new File("testsuite","test18.png")),false).display());
System.out.println(font.getAllData(ImageIO.read(new File("testsuite","test18.png")),true).displayDebug());
System.out.println(font.getAllData(ImageIO.read(new File("testsuite","test16.png")),false).display());
System.out.println(font.getAllData(ImageIO.read(new File("testsuite","test16.png")),true).displayDebug());
//System.out.println(font.getAllData(ImageIO.read(new File("testsuite","test14.png"))).display());
/*System.out.println(font.getAllData(ImageIO.read(new File("testimage.png"))).display());
System.out.println(font.getAllData(ImageIO.read(new File("testimage2.png"))).display());

@ -18,13 +18,16 @@ public class TypeFace2 {
BufferedImage img;
BufferedImage font;
BufferedImage percentfont;
BufferedImage scorefont;
int xpointer = 99;
int ypointer = 0;
public static final int THRESHOLD = 30000;
public TypeFace2(BufferedImage font,BufferedImage percentfont) {
public TypeFace2(BufferedImage font,BufferedImage percentfont,
BufferedImage scorefont) {
this.font=font;
this.percentfont = percentfont;
this.scorefont = scorefont;
File debugdir = new File("debug");
debugdir.mkdirs();
@ -80,6 +83,13 @@ public class TypeFace2 {
result.mod = getMod(img2);
//1109,435
result.combo = extractNumbersFromImage(img2.getSubimage(
1010,435,100,20),debug);
result.score = extractScoreNumbersFromImage(img2.getSubimage(
859,578,250,32),debug);
return result;
}
@ -433,4 +443,94 @@ public class TypeFace2 {
return Integer.parseInt(total);
}
}
public int extractScoreNumbersFromImage(BufferedImage img,boolean debug) throws IOException {
this.img=img;
File f = null;
BufferedImage test = null;
xpointer=249;
ypointer=0;
String total = "";
trialloop:
while (ypointer<4) {
xpointer=249;
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(30,28,BufferedImage.TYPE_INT_ARGB);
}
boolean ruleBreak=false;
colorloop:
for (int x=0;x<30;x++) {
for (int y=0;y<28;y++) {
Color fontCol = new Color(scorefont.getRGB(x+i*30,y));
Color pixelCol = new Color(img.getRGB(xpointer-30+x+1, y+ypointer));
if (fontCol.equals(Color.RED) && pixelCol.getRed()<170
&& pixelCol.getGreen()<170 && pixelCol.getBlue()<170) {
//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()>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-=30;
} 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);
}
}
}

Loading…
Cancel
Save