Multithreading working, BRobot seems to be failing

This commit is contained in:
davpapp 2018-03-13 11:15:08 -04:00
parent ae260edfc0
commit 488abeb1c9
6 changed files with 13 additions and 11 deletions

View File

@ -13,7 +13,7 @@ public class DropperThread implements Runnable {
@Override @Override
public void run() { public void run() {
try { try {
inventory.update(); //inventory.update();
cursor.moveAndRightlickAtCoordinatesWithRandomness(inventory.getClickCoordinatesForInventorySlot(0, 0), 15, 15); cursor.moveAndRightlickAtCoordinatesWithRandomness(inventory.getClickCoordinatesForInventorySlot(0, 0), 15, 15);
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block

View File

@ -71,6 +71,7 @@ public class IronMiner {
} }
DetectedObject closestIronOre = getClosestObjectToCharacter(ironOres); DetectedObject closestIronOre = getClosestObjectToCharacter(ironOres);
if (closestIronOre != null) { if (closestIronOre != null) {
cursor.moveAndLeftClickAtCoordinatesWithRandomness(closestIronOre.getCenterForClicking(), 10, 10); cursor.moveAndLeftClickAtCoordinatesWithRandomness(closestIronOre.getCenterForClicking(), 10, 10);
@ -85,16 +86,15 @@ public class IronMiner {
System.out.println("Both threads finished?"); System.out.println("Both threads finished?");
} }
if (count % 30 == 0) {
humanBehavior.randomlyCheckMiningXP(cursor); System.out.println("WAITING #############################################");
randomDetector.dealWithRandoms(screenCapture, cursor); Thread.sleep(5000);
}
//humanBehavior.randomlyCheckMiningXP(cursor);
//randomDetector.dealWithRandoms(screenCapture, cursor);
//dropInventoryIfFull(); //dropInventoryIfFull();
if (count % 100 == 0) {
System.out.println((System.currentTimeMillis() - startTime) / 1000);
} }
} }
System.out.println("Completed full mining session.");
}
/*private void dropOre() throws Exception { /*private void dropOre() throws Exception {
inventory.update(); inventory.update();

View File

@ -31,8 +31,9 @@ public class TrackerThread implements Runnable {
boolean oreAvailable = true; boolean oreAvailable = true;
int oreLostCount = 0; int oreLostCount = 0;
while (!objectTrackingFailure && oreLostCount < 3 && !isTimeElapsedOverLimit(miningStartTime, maxTimeToMine)) { while (!objectTrackingFailure && oreLostCount < 3 && !isTimeElapsedOverLimit(miningStartTime, maxTimeToMine)) {
BufferedImage screenCapture2 = objectDetector.captureScreenshotGameWindow(); long frameStartTime = System.currentTimeMillis();
ArrayList<DetectedObject> detectedObjects = objectDetector.getObjectsInImage(screenCapture2, 0.15); screenCapture = objectDetector.captureScreenshotGameWindow();
ArrayList<DetectedObject> detectedObjects = objectDetector.getObjectsInImage(screenCapture, 0.15);
ArrayList<DetectedObject> ironOres = objectDetector.getObjectsOfClassInList(detectedObjects, "ironOre"); ArrayList<DetectedObject> ironOres = objectDetector.getObjectsOfClassInList(detectedObjects, "ironOre");
objectTrackingFailure = ironOreTracker.update(screenCapture, boundingBox); objectTrackingFailure = ironOreTracker.update(screenCapture, boundingBox);
oreAvailable = objectDetector.isObjectPresentInBoundingBoxInImage(ironOres, boundingBox, "ironOre"); oreAvailable = objectDetector.isObjectPresentInBoundingBoxInImage(ironOres, boundingBox, "ironOre");
@ -42,7 +43,8 @@ public class TrackerThread implements Runnable {
else { else {
oreLostCount = 0; oreLostCount = 0;
} }
System.out.println("trackerThread working..."); System.out.println("Threaded tracker took " + (System.currentTimeMillis() - frameStartTime) + " milliseconds.");
//System.out.println("trackerThread working...");
} }
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block

Binary file not shown.

Binary file not shown.

Binary file not shown.