Algorithm testing continues, continue to refine all aspects. Implement
auto-rerunning of tests in debug mode.
@ -1,4 +1,4 @@
|
||||
521
|
||||
299
|
||||
1490
|
||||
842
|
||||
555
|
||||
318
|
||||
1630
|
||||
918
|
||||
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.3 KiB |
@ -33,7 +33,7 @@ public class CustomRobot extends Robot{
|
||||
return super.createScreenCapture(r);
|
||||
}
|
||||
|
||||
public void refreshScreen() {
|
||||
public void refreshScreen() throws IOException {
|
||||
//currentScreen = super.createScreenCapture(new Rectangle(418+18,204+83,912-18,586-83));
|
||||
if (CalibrationDataChanged()) {
|
||||
ReloadCalibrationData();
|
||||
@ -44,7 +44,7 @@ public class CustomRobot extends Robot{
|
||||
currentScreen = super.createScreenCapture(new Rectangle(418+18,204+83,912-18,586-83));
|
||||
}
|
||||
}
|
||||
private void ReloadCalibrationData() {
|
||||
private void ReloadCalibrationData() throws IOException {
|
||||
lastCalibrationTime=calibration_file.lastModified();
|
||||
String[] data = FileUtils.readFromFile("calibration_data.txt");
|
||||
calibration_data[0]=Integer.parseInt(data[0]);
|
||||
@ -57,7 +57,7 @@ public class CustomRobot extends Robot{
|
||||
return calibration_file.exists()&&lastCalibrationTime!=calibration_file.lastModified();
|
||||
}
|
||||
|
||||
public void refreshScoreScreen() {
|
||||
public void refreshScoreScreen() throws IOException {
|
||||
if (CalibrationDataChanged()) {
|
||||
ReloadCalibrationData();
|
||||
}
|
||||
|
@ -126,6 +126,7 @@ public class DrawCanvas extends JPanel implements KeyListener{
|
||||
artist = obj.getString("artist");*/
|
||||
if (MyRobot.p.songname!=null) {
|
||||
SongInfo currentSong = SongInfo.getByTitle(MyRobot.p.songname);
|
||||
FileUtils.writetoFile(new String[] {MyRobot.p.songname}, "testencode.txt");
|
||||
if (currentSong!=null) {
|
||||
if (currentSong.rating.has(difficulty)) {
|
||||
difficultyRating = currentSong.rating.getDouble(difficulty);
|
||||
|
@ -193,7 +193,11 @@ public class FutureToneBot{
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
MYROBOT.refreshScreen();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean OnResultsScreen() {
|
||||
|
@ -292,7 +292,7 @@ public class MyRobot{
|
||||
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+""
|
||||
+ "_"+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));
|
||||
results.add(new Result(selectedSong.title,difficulty,data.cool,data.fine,data.safe,data.sad,data.worst,data.percent,data.mod,data.combo,data.score,data.fail));
|
||||
SoundUtils.playSound("collect_item.wav");
|
||||
//gotoxy(800,64);
|
||||
//click();
|
||||
@ -305,7 +305,8 @@ public class MyRobot{
|
||||
MYROBOT.keyRelease(KeyEvent.VK_CONTROL);
|
||||
}
|
||||
} catch (IOException|NumberFormatException|IndexOutOfBoundsException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
} else {
|
||||
if (results.size()>0) {
|
||||
@ -393,9 +394,9 @@ public class MyRobot{
|
||||
|
||||
private boolean OnResultsScreen() throws IOException {
|
||||
//r.x-418, r.y-204
|
||||
ImageIO.write(MYROBOT.createScreenCapture(new Rectangle(31,230,40,40)),"png",new File("color1.png"));
|
||||
/*ImageIO.write(MYROBOT.createScreenCapture(new Rectangle(31,230,40,40)),"png",new File("color1.png"));
|
||||
ImageIO.write(MYROBOT.createScreenCapture(new Rectangle(31,196,40,40)),"png",new File("color2.png"));
|
||||
ImageIO.write(MYROBOT.createScreenCapture(new Rectangle(483,256,40,40)),"png",new File("color3.png"));
|
||||
ImageIO.write(MYROBOT.createScreenCapture(new Rectangle(483,256,40,40)),"png",new File("color3.png"));*/
|
||||
Color c1 = new Color(MYROBOT.createScreenCapture(new Rectangle(31,230,40,40)).getRGB(0, 0));
|
||||
Color c2 = new Color(MYROBOT.createScreenCapture(new Rectangle(31,196,40,40)).getRGB(0, 0));
|
||||
Color c3 = new Color(MYROBOT.createScreenCapture(new Rectangle(483,256,40,40)).getRGB(0, 0));
|
||||
@ -535,7 +536,11 @@ public class MyRobot{
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
//BufferedImage img = ImageUtils.toCompatibleImage(MYROBOT.createScreenCapture(new Rectangle(460,426,WIDTH,HEIGHT)));
|
||||
//Buffered img ImageUtils.toCompatibleImage(
|
||||
try {
|
||||
MYROBOT.refreshScreen();
|
||||
} catch (IOException e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
BufferedImage img = null;
|
||||
try {
|
||||
ImageIO.write(img=MYROBOT.createScreenCapture(new Rectangle(812,380,WIDTH,HEIGHT)),"png",new File("test.png"));
|
||||
@ -549,7 +554,11 @@ public class MyRobot{
|
||||
}
|
||||
}
|
||||
SongData.saveSongToFile(NEWSONGS[currentSong],col);
|
||||
try {
|
||||
SongData.loadSongsFromFile();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
currentSong+=1;
|
||||
if (currentSong>=NEWSONGS.length) {
|
||||
System.out.println("DONE!");
|
||||
@ -619,6 +628,14 @@ public class MyRobot{
|
||||
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("test19.png",4,2,2,0,95,0.42f,"EXEX","HS",2,4130,true);
|
||||
RunTest("test20.png",3,1,1,2,58,0.75f,"EX","HS",2,7810,true);
|
||||
RunTest("test21.png",13,19,15,6,41,2.16f,"EX","HS",5,17860,true);
|
||||
RunTest("test22.png",49,37,21,15,26,4.68f,"EX","HS",10,42210,true);
|
||||
RunTest("test23.png",10,20,10,7,72,3.85f,"EXEX","HS",11,20050,true);
|
||||
RunTest("test24.png",35,29,19,22,11,7.85f,"N","HD",17,29600,true);
|
||||
RunTest("test25.png",175,75,13,10,32,50.84f,"E","SD",26,122670,false);
|
||||
RunTest("test26.png",29,24,6,7,35,3.12f,"EXEX","HS",26,28100,true);
|
||||
RunTest("test27.png",45,35,8,6,22,7.00f,"EX","HS",27,69780,true);
|
||||
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);
|
||||
@ -689,12 +706,27 @@ public class MyRobot{
|
||||
assert data.worst == _worst : "Expected worst count to be "+_worst+", got "+data.worst;
|
||||
assert data.percent == _percent : "Expected percent to be "+_percent+", got "+data.percent;
|
||||
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.mod.equals(_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;
|
||||
} catch(AssertionError e) {
|
||||
System.err.println("\t"+e.getMessage()+" "+"("+(System.currentTimeMillis()-startTime)+"ms)!");
|
||||
if (!debug) {
|
||||
System.out.print("Automatically running in debug mode");
|
||||
FileUtils.deleteFile("debug");
|
||||
File f = new File("debug");
|
||||
f.mkdir();
|
||||
while (!f.exists()) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
f.mkdir();
|
||||
} catch (InterruptedException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
RunTest(_img,_cool,_fine,_safe,_sad,_worst,_percent,_difficulty,_mod,_combo,_score,_fail,true);
|
||||
}
|
||||
System.exit(1);
|
||||
}
|
||||
System.out.println("\tPassed ("+(System.currentTimeMillis()-startTime)+"ms)!");
|
||||
@ -721,7 +753,8 @@ public class MyRobot{
|
||||
MYROBOT = new CustomRobot();
|
||||
MYROBOT.refreshScreen();
|
||||
} catch (Exception e) {
|
||||
JOptionPane.showOptionDialog(null, "Can't build the robot!", "Error", -1, 1, null, null, this);
|
||||
e.printStackTrace();
|
||||
JOptionPane.showOptionDialog(null, e.getMessage(), "Error", -1, 1, null, null, this);
|
||||
System.exit(1);
|
||||
}
|
||||
X = SCREEN_X / 2;
|
||||
|
@ -33,6 +33,12 @@ public class Result {
|
||||
this.combo=combo;
|
||||
this.score=score;
|
||||
}
|
||||
public Result(String song,String diff,int cool,int fine,int safe,int sad,int worst,float percent,String mod,int combo, int score,boolean fail) {
|
||||
this(song,diff,cool,fine,safe,sad,worst,percent,fail);
|
||||
this.combo=combo;
|
||||
this.score=score;
|
||||
this.mod=mod;
|
||||
}
|
||||
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("%")
|
||||
@ -41,8 +47,9 @@ public class Result {
|
||||
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())
|
||||
.append(",").append(combo).append(",").append(score).toString();
|
||||
.append(",\"").append(difficulty).append("\",\"").append(mod).append("\",").append(combo).append(",").append(score).append(",")
|
||||
.append(Boolean.toString(fail).toLowerCase())
|
||||
.toString();
|
||||
}
|
||||
public String toString() {
|
||||
return displayDebug();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package sig;
|
||||
import java.awt.Color;
|
||||
import java.io.IOException;
|
||||
|
||||
import sig.utils.FileUtils;
|
||||
import sig.utils.ImageUtils;
|
||||
@ -70,7 +71,7 @@ public class SongData {
|
||||
}
|
||||
FileUtils.logToFile(sb.toString(),"colorData");
|
||||
}
|
||||
public static void loadSongsFromFile() {
|
||||
public static void loadSongsFromFile() throws IOException {
|
||||
String[] data = FileUtils.readFromFile("colorData");
|
||||
MyRobot.SONGS = new SongData[data.length];
|
||||
for (int i=0;i<data.length;i++) {
|
||||
|
@ -40,15 +40,15 @@ public class TypeFace2 {
|
||||
|
||||
final static int XOFFSET = 8;
|
||||
|
||||
final static Rectangle RECT_SEARCH_COOL=new Rectangle(866+XOFFSET,260,100+XOFFSET,22);
|
||||
final static Rectangle RECT_SEARCH_FINE=new Rectangle(866+XOFFSET,294,100+XOFFSET,22);
|
||||
final static Rectangle RECT_SEARCH_SAFE=new Rectangle(866+XOFFSET,329,100+XOFFSET,22);
|
||||
final static Rectangle RECT_SEARCH_SAD=new Rectangle(866+XOFFSET,364,100+XOFFSET,22);
|
||||
final static Rectangle RECT_SEARCH_WORST=new Rectangle(866+XOFFSET,400,100+XOFFSET,22);
|
||||
final static Rectangle RECT_SEARCH_PCT=new Rectangle(1182+XOFFSET,165,1132,168);
|
||||
final static Rectangle RECT_SEARCH_PCT2=new Rectangle(1123+XOFFSET,165,1051,168);
|
||||
final static Rectangle RECT_SEARCH_SCORE=new Rectangle(859+XOFFSET,578,250+XOFFSET,32);
|
||||
final static Rectangle RECT_SEARCH_COMBO=new Rectangle(1010+XOFFSET,435,100+XOFFSET,20);
|
||||
final static Rectangle RECT_SEARCH_COOL=new Rectangle(866+XOFFSET,260,100+XOFFSET+1,22+8);
|
||||
final static Rectangle RECT_SEARCH_FINE=new Rectangle(866+XOFFSET,294,100+XOFFSET+1,22+8);
|
||||
final static Rectangle RECT_SEARCH_SAFE=new Rectangle(866+XOFFSET,329,100+XOFFSET+1,22+8);
|
||||
final static Rectangle RECT_SEARCH_SAD=new Rectangle(866+XOFFSET,364,100+XOFFSET+1,22+8);
|
||||
final static Rectangle RECT_SEARCH_WORST=new Rectangle(866+XOFFSET,400,100+XOFFSET+1,22+8);
|
||||
final static Rectangle RECT_SEARCH_PCT=new Rectangle(1182+XOFFSET,163,1132,8);
|
||||
final static Rectangle RECT_SEARCH_PCT2=new Rectangle(1123+XOFFSET,163,1051,8);
|
||||
final static Rectangle RECT_SEARCH_SCORE=new Rectangle(859+XOFFSET,578-2,250+XOFFSET+1,32+10);
|
||||
final static Rectangle RECT_SEARCH_COMBO=new Rectangle(1010+XOFFSET,435-2,100+XOFFSET+1,22+8);
|
||||
|
||||
public Result getAllData(BufferedImage img, boolean debug) throws IOException,NumberFormatException,IndexOutOfBoundsException {
|
||||
BufferedImage img2 = ImageUtils.toBufferedImage(img.getScaledInstance(1280 , 720, Image.SCALE_SMOOTH));
|
||||
@ -158,7 +158,7 @@ public class TypeFace2 {
|
||||
BufferedImage test = null;
|
||||
|
||||
trialloop:
|
||||
while (ypointer<RECT_SEARCH_PCT.height) {
|
||||
while (ypointer<RECT_SEARCH_PCT.height+RECT_SEARCH_PCT.y) {
|
||||
xpointer=RECT_SEARCH_PCT.x;
|
||||
while (xpointer>RECT_SEARCH_PCT.width) {
|
||||
int foundIndex = -1;
|
||||
@ -268,7 +268,7 @@ public class TypeFace2 {
|
||||
xpointer=RECT_SEARCH_PCT2.x;
|
||||
ypointer=RECT_SEARCH_PCT2.y;
|
||||
trialloop:
|
||||
while (ypointer<RECT_SEARCH_PCT2.height) {
|
||||
while (ypointer<RECT_SEARCH_PCT2.height+RECT_SEARCH_PCT2.y) {
|
||||
xpointer=RECT_SEARCH_PCT2.x;
|
||||
while (xpointer>RECT_SEARCH_PCT2.width) {
|
||||
int foundIndex = -1;
|
||||
@ -401,7 +401,7 @@ public class TypeFace2 {
|
||||
ypointer=0;
|
||||
String total = "";
|
||||
trialloop:
|
||||
while (ypointer<4) {
|
||||
while (ypointer<8) {
|
||||
xpointer=RECT_SEARCH_COOL.width-1;
|
||||
while (xpointer>22) {
|
||||
int distance = 0;
|
||||
@ -491,7 +491,7 @@ public class TypeFace2 {
|
||||
ypointer=0;
|
||||
String total = "";
|
||||
trialloop:
|
||||
while (ypointer<4) {
|
||||
while (ypointer<8) {
|
||||
xpointer=RECT_SEARCH_SCORE.width-1;
|
||||
while (xpointer>31) {
|
||||
int distance = 0;
|
||||
|
@ -2,6 +2,7 @@ package sig.utils;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
@ -34,27 +35,24 @@ import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class FileUtils {
|
||||
public static String[] readFromFile(String filename) {
|
||||
public static String[] readFromFile(String filename) throws IOException {
|
||||
File file = new File(filename);
|
||||
//System.out.println(file.getAbsolutePath());
|
||||
List<String> contents= new ArrayList<String>();
|
||||
if (file.exists()) {
|
||||
try(
|
||||
FileReader fw = new FileReader(filename);
|
||||
BufferedReader bw = new BufferedReader(fw);)
|
||||
{
|
||||
String readline = bw.readLine();
|
||||
FileInputStream in = new FileInputStream(file);
|
||||
InputStreamReader isr = new InputStreamReader(in,Charset.forName("UTF-8"));
|
||||
BufferedReader br = new BufferedReader(isr);
|
||||
String readline = br.readLine();
|
||||
do {
|
||||
if (readline!=null) {
|
||||
//System.out.println(readline);
|
||||
contents.add(readline);
|
||||
readline = bw.readLine();
|
||||
readline = br.readLine();
|
||||
}} while (readline!=null);
|
||||
fw.close();
|
||||
bw.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
br.close();
|
||||
isr.close();
|
||||
in.close();
|
||||
}
|
||||
return contents.toArray(new String[contents.size()]);
|
||||
}
|
||||
@ -272,8 +270,9 @@ public class FileUtils {
|
||||
}
|
||||
OutputStream out = new FileOutputStream(file,true);
|
||||
Writer writer = new OutputStreamWriter(out, StandardCharsets.UTF_8);
|
||||
PrintWriter pw = new PrintWriter(writer);
|
||||
|
||||
PrintWriter pw = new PrintWriter(writer);
|
||||
//pw.print('\uFEFF');
|
||||
pw.println(message);
|
||||
pw.flush();
|
||||
pw.close();
|
||||
@ -290,9 +289,10 @@ public class FileUtils {
|
||||
file.createNewFile();
|
||||
}
|
||||
|
||||
FileWriter fw = new FileWriter(file,false);
|
||||
PrintWriter pw = new PrintWriter(fw);
|
||||
|
||||
OutputStream out = new FileOutputStream(file,true);
|
||||
Writer writer = new OutputStreamWriter(out, StandardCharsets.UTF_8);
|
||||
PrintWriter pw = new PrintWriter(writer);
|
||||
pw.print('\uFEFF');
|
||||
for (String s : data) {
|
||||
pw.println(s);
|
||||
}
|
||||
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |