mirror of
https://github.com/davpapp/PowerMiner
synced 2024-11-15 14:05:04 -05:00
Tested Dropping, improved randomization and SMART drop
This commit is contained in:
parent
ee0efadb37
commit
f2d9d52711
110
src/Cursor.java
110
src/Cursor.java
@ -73,18 +73,23 @@ public class Cursor {
|
|||||||
return randomizer.nextGaussianWithinRange(MINIMUM_CLICK_LENGTH, MAXIMUM_CLICK_LENGTH);
|
return randomizer.nextGaussianWithinRange(MINIMUM_CLICK_LENGTH, MAXIMUM_CLICK_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getRandomClickReleaseLength() {
|
||||||
|
return randomizer.nextGaussianWithinRange(MINIMUM_CLICK_LENGTH + 5, MAXIMUM_CLICK_LENGTH + 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void leftClickCursor() throws InterruptedException {
|
public void leftClickCursor() throws InterruptedException {
|
||||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||||
Thread.sleep(getRandomClickLength());
|
Thread.sleep(getRandomClickLength());
|
||||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||||
Thread.sleep(getRandomClickLength());
|
Thread.sleep(getRandomClickReleaseLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rightClickCursor() throws InterruptedException {
|
public void rightClickCursor() throws InterruptedException {
|
||||||
robot.mousePress(InputEvent.BUTTON3_DOWN_MASK);
|
robot.mousePress(InputEvent.BUTTON3_DOWN_MASK);
|
||||||
Thread.sleep(20 + getRandomClickLength());
|
Thread.sleep(getRandomClickLength() + 20);
|
||||||
robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK);
|
robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK);
|
||||||
Thread.sleep(getRandomClickLength());
|
Thread.sleep(getRandomClickReleaseLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void moveAndLeftClickAtCoordinates(Point goalPoint) throws Exception {
|
public void moveAndLeftClickAtCoordinates(Point goalPoint) throws Exception {
|
||||||
@ -99,15 +104,25 @@ public class Cursor {
|
|||||||
|
|
||||||
public Point moveAndLeftClickAtCoordinatesWithRandomness(Point goalPoint, int xTolerance, int yTolerance) throws Exception {
|
public Point moveAndLeftClickAtCoordinatesWithRandomness(Point goalPoint, int xTolerance, int yTolerance) throws Exception {
|
||||||
Point randomizedGoalPoint = randomizePoint(goalPoint, xTolerance, yTolerance);
|
Point randomizedGoalPoint = randomizePoint(goalPoint, xTolerance, yTolerance);
|
||||||
moveCursorToCoordinates(randomizedGoalPoint);
|
moveAndLeftClickAtCoordinates(randomizedGoalPoint);
|
||||||
leftClickCursor();
|
return randomizedGoalPoint; // Return the point we moved to in case we need precise movement afterwards
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point moveAndLeftClickAtCoordinatesWithRandomness(Point goalPoint, int xToleranceLeft, int xToleranceRight, int yTolerance) throws Exception {
|
||||||
|
Point randomizedGoalPoint = randomizePoint(goalPoint, xToleranceLeft, xToleranceRight, yTolerance);
|
||||||
|
moveAndLeftClickAtCoordinates(randomizedGoalPoint);
|
||||||
return randomizedGoalPoint; // Return the point we moved to in case we need precise movement afterwards
|
return randomizedGoalPoint; // Return the point we moved to in case we need precise movement afterwards
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point moveAndRightlickAtCoordinatesWithRandomness(Point goalPoint, int xTolerance, int yTolerance) throws Exception {
|
public Point moveAndRightlickAtCoordinatesWithRandomness(Point goalPoint, int xTolerance, int yTolerance) throws Exception {
|
||||||
Point randomizedGoalPoint = randomizePoint(goalPoint, xTolerance, yTolerance);
|
Point randomizedGoalPoint = randomizePoint(goalPoint, xTolerance, yTolerance);
|
||||||
moveCursorToCoordinates(randomizedGoalPoint);
|
moveAndRightClickAtCoordinates(randomizedGoalPoint);
|
||||||
rightClickCursor();
|
return randomizedGoalPoint; // Return the point we moved to in case we need precise movement afterwards
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point moveAndRightlickAtCoordinatesWithRandomness(Point goalPoint, int xToleranceLeft, int xToleranceRight, int yTolerance) throws Exception {
|
||||||
|
Point randomizedGoalPoint = randomizePoint(goalPoint, xToleranceLeft, xToleranceRight, yTolerance);
|
||||||
|
moveAndRightClickAtCoordinates(randomizedGoalPoint);
|
||||||
return randomizedGoalPoint; // Return the point we moved to in case we need precise movement afterwards
|
return randomizedGoalPoint; // Return the point we moved to in case we need precise movement afterwards
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,15 +130,14 @@ public class Cursor {
|
|||||||
Point startingPoint = getCurrentCursorPoint();
|
Point startingPoint = getCurrentCursorPoint();
|
||||||
int distanceToMoveCursor = getDistanceBetweenPoints(startingPoint, goalPoint);
|
int distanceToMoveCursor = getDistanceBetweenPoints(startingPoint, goalPoint);
|
||||||
double angleToRotateCursorPathTo = getThetaBetweenPoints(startingPoint, goalPoint);
|
double angleToRotateCursorPathTo = getThetaBetweenPoints(startingPoint, goalPoint);
|
||||||
System.out.println("R:" + distanceToMoveCursor + ", theta:" + angleToRotateCursorPathTo);
|
|
||||||
if (distanceToMoveCursor == 0) {
|
if (distanceToMoveCursor == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CursorPath cursorPathWithDistanceSet = chooseCursorPathToFollowBasedOnDistance(distanceToMoveCursor);
|
CursorPath cursorPathWithDistanceSet = chooseCursorPathToFollowBasedOnDistance(distanceToMoveCursor);
|
||||||
CursorPath cursorPathWithDistanceAndAngleSet = cursorPathWithDistanceSet.getRotatedCopyOfCursorPath(angleToRotateCursorPathTo);
|
CursorPath cursorPathWithDistanceAndAngleSet = cursorPathWithDistanceSet.getRotatedCopyOfCursorPath(angleToRotateCursorPathTo);
|
||||||
System.out.println("Rotated the points: ");
|
|
||||||
//cursorPathWithDistanceAndAngleSet.displayCursorPoints();
|
|
||||||
followCursorPath(cursorPathWithDistanceAndAngleSet, startingPoint);
|
followCursorPath(cursorPathWithDistanceAndAngleSet, startingPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,50 +163,45 @@ public class Cursor {
|
|||||||
|
|
||||||
private CursorPath chooseCursorPathToFollowBasedOnDistance(int distanceToMoveCursor) throws Exception {
|
private CursorPath chooseCursorPathToFollowBasedOnDistance(int distanceToMoveCursor) throws Exception {
|
||||||
int newDistanceToMoveCursor = findNearestPathLengthThatExists(distanceToMoveCursor);
|
int newDistanceToMoveCursor = findNearestPathLengthThatExists(distanceToMoveCursor);
|
||||||
double scaleToFactorBy = getScaleToFactorBy(newDistanceToMoveCursor, distanceToMoveCursor);
|
|
||||||
System.out.println("new distance to follow cursor is: " + newDistanceToMoveCursor + " from scaling by " + scaleToFactorBy);
|
|
||||||
ArrayList<CursorPath> cursorPathsWithSameDistance = cursorPathsByDistance.get(newDistanceToMoveCursor);
|
ArrayList<CursorPath> cursorPathsWithSameDistance = cursorPathsByDistance.get(newDistanceToMoveCursor);
|
||||||
|
|
||||||
CursorPath scaledCursorPath = cursorPathsWithSameDistance.get(random.nextInt(cursorPathsWithSameDistance.size())).getScaledCopyOfCursorPath(scaleToFactorBy);
|
CursorPath randomlyChosenCursorPath = cursorPathsWithSameDistance.get(random.nextInt(cursorPathsWithSameDistance.size()));
|
||||||
|
if (newDistanceToMoveCursor == distanceToMoveCursor) {
|
||||||
|
return randomlyChosenCursorPath;
|
||||||
|
}
|
||||||
|
|
||||||
return scaledCursorPath;
|
double scaleToFactorBy = getScaleToFactorBy(newDistanceToMoveCursor, distanceToMoveCursor);
|
||||||
//return cursorPathsByDistance.get(newDistanceToMoveCursor).get(indexOfRandomPathToFollow);//scaledCursorPath;
|
return randomlyChosenCursorPath.getScaledCopyOfCursorPath(scaleToFactorBy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int findNearestPathLengthThatExists(int distanceToMoveCursor) throws Exception {
|
public int findNearestPathLengthThatExists(int distanceToMoveCursor) throws Exception {
|
||||||
int offset = 0;
|
int closestShorterPathLength = Integer.MIN_VALUE;
|
||||||
boolean reachedMinimumLimit = false;
|
int closestLongerPathLength = Integer.MAX_VALUE;
|
||||||
boolean reachedMaximumLimit = false;
|
for (int i = distanceToMoveCursor; i >= 0; i--) {
|
||||||
while (cursorPathsByDistance.get(distanceToMoveCursor + offset).size() == 0) {
|
if (cursorPathsByDistance.get(i).size() > 0) {
|
||||||
// Go up
|
closestShorterPathLength = i;
|
||||||
if (distanceToMoveCursor + Math.abs(offset) + 1 >= NUMBER_OF_DISTANCES) {
|
break;
|
||||||
reachedMaximumLimit = true;
|
|
||||||
}
|
|
||||||
if (distanceToMoveCursor - Math.abs(offset) - 1 < 0) {
|
|
||||||
reachedMinimumLimit = true;
|
|
||||||
}
|
|
||||||
if (reachedMaximumLimit && reachedMinimumLimit) {
|
|
||||||
throw new Exception("No paths exist.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (offset < 0) {
|
|
||||||
if (!reachedMaximumLimit) {
|
|
||||||
offset = -offset + 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
offset--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!reachedMinimumLimit) {
|
|
||||||
offset = -offset - 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
offset++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return distanceToMoveCursor + offset;
|
for (int i = distanceToMoveCursor; i < 2203; i++) {
|
||||||
|
if (cursorPathsByDistance.get(i).size() > 0) {
|
||||||
|
closestLongerPathLength = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (closestShorterPathLength == Integer.MIN_VALUE && closestLongerPathLength == Integer.MAX_VALUE) {
|
||||||
|
throw new Exception("No paths of any size exist.");
|
||||||
|
}
|
||||||
|
else if (closestShorterPathLength == Integer.MIN_VALUE) {
|
||||||
|
return closestLongerPathLength;
|
||||||
|
}
|
||||||
|
else if (closestLongerPathLength == Integer.MAX_VALUE) {
|
||||||
|
return closestShorterPathLength;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return (Math.abs(distanceToMoveCursor - closestShorterPathLength) <= Math.abs(distanceToMoveCursor - closestLongerPathLength)) ? closestShorterPathLength : closestLongerPathLength;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getScaleToFactorBy(int newDistanceToMoveCursor, int distanceToMoveCursor) {
|
private double getScaleToFactorBy(int newDistanceToMoveCursor, int distanceToMoveCursor) {
|
||||||
@ -209,14 +218,15 @@ public class Cursor {
|
|||||||
return new Point(goalPoint.x + randomizer.nextGaussianWithinRange(-xTolerance, xTolerance), goalPoint.y + randomizer.nextGaussianWithinRange(-yTolerance, yTolerance));
|
return new Point(goalPoint.x + randomizer.nextGaussianWithinRange(-xTolerance, xTolerance), goalPoint.y + randomizer.nextGaussianWithinRange(-yTolerance, yTolerance));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Point randomizePoint(Point goalPoint, int xToleranceLeft, int xToleranceRight, int yTolerance) {
|
||||||
|
Randomizer randomizer = new Randomizer();
|
||||||
|
return new Point(goalPoint.x + randomizer.nextGaussianWithinRange(-xToleranceLeft, xToleranceRight), goalPoint.y + randomizer.nextGaussianWithinRange(-yTolerance, yTolerance));
|
||||||
|
}
|
||||||
|
|
||||||
public void displayCursorPaths() {
|
public void displayCursorPaths() {
|
||||||
for (int i = 0; i < NUMBER_OF_DISTANCES; i++) {
|
for (int i = 0; i < NUMBER_OF_DISTANCES; i++) {
|
||||||
System.out.println("There are " + cursorPathsByDistance.get(i).size() + " paths of size " + i);
|
System.out.println("There are " + cursorPathsByDistance.get(i).size() + " paths of size " + i);
|
||||||
}
|
}
|
||||||
System.out.println("--------------");
|
System.out.println("--------------");
|
||||||
/*for (int i = 0; i < cursorPathsByDistance.get(1).size(); i++) {
|
|
||||||
cursorPathsByDistance.get(1).get(i).displayCursorPoints();
|
|
||||||
}*/
|
|
||||||
//cursorPathsByDistance.get(0).get(0).displayCursorPoints();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -101,7 +101,7 @@ public class CursorPath {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCursorPathTimespanReasonable() {
|
private boolean isCursorPathTimespanReasonable() {
|
||||||
return (this.timespan > 50 && this.timespan < 400);
|
return (this.timespan > 50 && this.timespan < 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCursorPathDistanceReasonable() {
|
private boolean isCursorPathDistanceReasonable() {
|
||||||
@ -109,7 +109,7 @@ public class CursorPath {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCursorPathNumPointsReasonable() {
|
private boolean isCursorPathNumPointsReasonable() {
|
||||||
return (this.cursorPoints.size() > 0 && this.cursorPoints.size() < 80);
|
return (this.cursorPoints.size() > 0 && this.cursorPoints.size() < 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<CursorPoint> getCursorPathPoints() {
|
public ArrayList<CursorPoint> getCursorPathPoints() {
|
||||||
|
@ -8,13 +8,13 @@ public class CursorTask {
|
|||||||
|
|
||||||
|
|
||||||
// Human drop time: 29 seconds
|
// Human drop time: 29 seconds
|
||||||
// Measured: 30 seconds, 29 seconds
|
// Measured: 30 seconds, 29 seconds, 28
|
||||||
public void optimizedDropAllItemsInInventory(Cursor cursor, Inventory inventory) throws InterruptedException {
|
public void optimizedDropAllItemsInInventory(Cursor cursor, Inventory inventory) throws Exception {
|
||||||
for (int row = 0; row < 4; row++) {
|
for (int row = 0; row < 4; row++) {
|
||||||
Point coordinatesToClick = dropItem(cursor, inventory, row, 0);
|
Point coordinatesToClick = dropItem(cursor, inventory, row, 0);
|
||||||
for (int column = 1; column < 7; column++) {
|
for (int column = 1; column < 7; column++) {
|
||||||
if (distanceBetweenPoints(coordinatesToClick, inventory.getClickCoordinatesCoordinatesForInventorySlot(row, column)) > 12) {
|
if (distanceBetweenPoints(coordinatesToClick, inventory.getClickCoordinatesForInventorySlot(row, column)) > 12) {
|
||||||
coordinatesToClick = inventory.getClickCoordinatesCoordinatesForInventorySlot(row, column);
|
coordinatesToClick = inventory.getClickCoordinatesForInventorySlot(row, column);
|
||||||
}
|
}
|
||||||
rightClickItemSlot(cursor, coordinatesToClick);
|
rightClickItemSlot(cursor, coordinatesToClick);
|
||||||
coordinatesToClick = leftClickDropOption(cursor, coordinatesToClick, column);
|
coordinatesToClick = leftClickDropOption(cursor, coordinatesToClick, column);
|
||||||
@ -26,7 +26,7 @@ public class CursorTask {
|
|||||||
return (int) (Math.hypot(a.x - b.x, a.y - b.y));
|
return (int) (Math.hypot(a.x - b.x, a.y - b.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dropAllItemsInInventory(Cursor cursor, Inventory inventory) throws InterruptedException {
|
public void dropAllItemsInInventory(Cursor cursor, Inventory inventory) throws Exception {
|
||||||
for (int row = 0; row < 4; row++) {
|
for (int row = 0; row < 4; row++) {
|
||||||
for (int column = 0; column < 7; column++) {
|
for (int column = 0; column < 7; column++) {
|
||||||
dropItem(cursor, inventory, row, column);
|
dropItem(cursor, inventory, row, column);
|
||||||
@ -35,22 +35,22 @@ public class CursorTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Point dropItem(Cursor cursor, Inventory inventory, int row, int column) throws InterruptedException {
|
public Point dropItem(Cursor cursor, Inventory inventory, int row, int column) throws Exception {
|
||||||
Point coordinatesToRightClick = inventory.getClickCoordinatesCoordinatesForInventorySlot(row, column);
|
Point coordinatesToRightClick = inventory.getClickCoordinatesForInventorySlot(row, column);
|
||||||
Point clickedCoordinates = rightClickItemSlotWithRandomness(cursor, coordinatesToRightClick);
|
Point clickedCoordinates = rightClickItemSlotWithRandomness(cursor, coordinatesToRightClick);
|
||||||
return leftClickDropOption(cursor, clickedCoordinates, column);
|
return leftClickDropOption(cursor, clickedCoordinates, column);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rightClickItemSlot(Cursor cursor, Point coordinatesToRightClick) throws InterruptedException {
|
public void rightClickItemSlot(Cursor cursor, Point coordinatesToRightClick) throws Exception {
|
||||||
cursor.moveAndRightClickAtCoordinates(coordinatesToRightClick);
|
cursor.moveAndRightClickAtCoordinates(coordinatesToRightClick);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point rightClickItemSlotWithRandomness(Cursor cursor, Point coordinatesToRightClick) throws InterruptedException {
|
public Point rightClickItemSlotWithRandomness(Cursor cursor, Point coordinatesToRightClick) throws Exception {
|
||||||
Point clickedCoordinates = cursor.moveAndRightlickAtCoordinatesWithRandomness(coordinatesToRightClick, 6, 6);
|
Point clickedCoordinates = cursor.moveAndRightlickAtCoordinatesWithRandomness(coordinatesToRightClick, 6, 6);
|
||||||
return clickedCoordinates;
|
return clickedCoordinates;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Point leftClickDropOption(Cursor cursor, Point coordinatesToLeftClick, int column) throws InterruptedException {
|
private Point leftClickDropOption(Cursor cursor, Point coordinatesToLeftClick, int column) throws Exception {
|
||||||
Point offsetCoordinatesToLeftClick = coordinatesToLeftClick;
|
Point offsetCoordinatesToLeftClick = coordinatesToLeftClick;
|
||||||
if (column < 6) {
|
if (column < 6) {
|
||||||
offsetCoordinatesToLeftClick.y += DROP_OFFSET;
|
offsetCoordinatesToLeftClick.y += DROP_OFFSET;
|
||||||
@ -58,6 +58,7 @@ public class CursorTask {
|
|||||||
else {
|
else {
|
||||||
offsetCoordinatesToLeftClick.y = DROP_BOTTOM_ROW;
|
offsetCoordinatesToLeftClick.y = DROP_BOTTOM_ROW;
|
||||||
}
|
}
|
||||||
return cursor.moveAndLeftClickAtCoordinatesWithRandomness(offsetCoordinatesToLeftClick, 10, 6);
|
System.out.println("foudn where to click...");
|
||||||
|
return cursor.moveAndLeftClickAtCoordinatesWithRandomness(offsetCoordinatesToLeftClick, 13, 10, 6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,12 @@ class CursorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void testFindNearestPathLengthThatExists() throws Exception {
|
void testFindNearestPathLengthThatExists() throws Exception {
|
||||||
|
int closestLengthForPreviousValue = 0;
|
||||||
for (int i = 0; i < 2203; i++) {
|
for (int i = 0; i < 2203; i++) {
|
||||||
int closestLength = cursor.findNearestPathLengthThatExists(i);
|
int closestLength = cursor.findNearestPathLengthThatExists(i);
|
||||||
System.out.println("Closest path to length " + i + " is " + closestLength);
|
assertTrue(closestLength >= closestLengthForPreviousValue);
|
||||||
|
closestLengthForPreviousValue = closestLength;
|
||||||
|
//System.out.println("Closest path to length " + i + " is " + closestLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public class Inventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initializeItems() throws IOException {
|
private void initializeItems() throws IOException {
|
||||||
items = new InventoryItems("/home/dpapp/Desktop/RunescapeAIPics/Items/");
|
items = new InventoryItems("/home/dpapp/Desktop/RunescapeAI/Items/");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update() throws IOException {
|
public void update() throws IOException {
|
||||||
@ -89,7 +89,7 @@ public class Inventory {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point getClickCoordinatesCoordinatesForInventorySlot(int row, int column) {
|
public Point getClickCoordinatesForInventorySlot(int row, int column) {
|
||||||
Point centerOfInventorySlot = inventorySlots[row][column].getClickablePointWithinItemSlot();
|
Point centerOfInventorySlot = inventorySlots[row][column].getClickablePointWithinItemSlot();
|
||||||
int x = INVENTORY_OFFSET_WIDTH + row * INVENTORY_SLOT_WIDTH + centerOfInventorySlot.x;
|
int x = INVENTORY_OFFSET_WIDTH + row * INVENTORY_SLOT_WIDTH + centerOfInventorySlot.x;
|
||||||
int y = INVENTORY_OFFSET_HEIGHT + column * INVENTORY_SLOT_HEIGHT + centerOfInventorySlot.y;
|
int y = INVENTORY_OFFSET_HEIGHT + column * INVENTORY_SLOT_HEIGHT + centerOfInventorySlot.y;
|
||||||
|
@ -18,8 +18,8 @@ class InventoryItemsTest {
|
|||||||
|
|
||||||
public void initialize() throws IOException {
|
public void initialize() throws IOException {
|
||||||
System.out.println("running initialize...");
|
System.out.println("running initialize...");
|
||||||
items = new InventoryItems("/home/dpapp/Desktop/RunescapeAIPics/Items/");
|
items = new InventoryItems("/home/dpapp/Desktop/RunescapeAI/Items/");
|
||||||
this.testingItemDirectoryPath = "/home/dpapp/Desktop/RunescapeAIPics/Tests/ItemNameRecognition/";
|
this.testingItemDirectoryPath = "/home/dpapp/Desktop/RunescapeAI/Tests/ItemNameRecognition/";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -16,7 +16,7 @@ class InventoryTest {
|
|||||||
|
|
||||||
public void initialize() throws AWTException, IOException {
|
public void initialize() throws AWTException, IOException {
|
||||||
inventory = new Inventory();
|
inventory = new Inventory();
|
||||||
this.testingInventoryDirectoryPath = "/home/dpapp/Desktop/RunescapeAIPics/Tests/Inventory/";
|
this.testingInventoryDirectoryPath = "/home/dpapp/Desktop/RunescapeAI/Tests/Inventory/";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -11,10 +11,12 @@ public class Randomizer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int nextGaussianWithinRange(double rangeBegin, double rangeEnd) {
|
public int nextGaussianWithinRange(double rangeBegin, double rangeEnd) {
|
||||||
double rangeMean = (rangeEnd - rangeBegin) / 2.0;
|
double rangeMean = (rangeEnd + rangeBegin) / 2.0;
|
||||||
double rangeSTD = (rangeEnd - rangeMean) / 3.0;
|
double rangeSTD = (rangeEnd - rangeMean) / 3.0;
|
||||||
double result = random.nextGaussian() * rangeSTD + rangeMean;
|
double result = random.nextGaussian() * rangeSTD + rangeMean;
|
||||||
while (result > rangeEnd || result < rangeBegin) {
|
while (result > rangeEnd || result < rangeBegin) {
|
||||||
|
System.out.println("Gaussian result out of range...");
|
||||||
|
System.out.println(rangeMean + ", std: " + rangeSTD);
|
||||||
result = random.nextGaussian() * rangeSTD + rangeMean;
|
result = random.nextGaussian() * rangeSTD + rangeMean;
|
||||||
}
|
}
|
||||||
return (int) result;
|
return (int) result;
|
||||||
|
@ -14,9 +14,10 @@ public class WillowChopper {
|
|||||||
inventory = new Inventory();
|
inventory = new Inventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() throws IOException, InterruptedException {
|
public void run() throws Exception {
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
Thread.sleep(250);
|
||||||
/*
|
/*
|
||||||
if (character.isCharacterEngaged()) {
|
if (character.isCharacterEngaged()) {
|
||||||
// DO NOTHING
|
// DO NOTHING
|
||||||
@ -29,7 +30,9 @@ public class WillowChopper {
|
|||||||
*/
|
*/
|
||||||
inventory.update();
|
inventory.update();
|
||||||
if (inventory.isInventoryFull()) {
|
if (inventory.isInventoryFull()) {
|
||||||
cursorTask.dropAllItemsInInventory(cursor, inventory);
|
System.out.println("Inventory is full! Dropping...");
|
||||||
|
cursorTask.optimizedDropAllItemsInInventory(cursor, inventory);
|
||||||
|
//cursorTask.dropAllItemsInInventory(cursor, inventory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,9 @@ import java.net.URL;
|
|||||||
|
|
||||||
public class main {
|
public class main {
|
||||||
|
|
||||||
public static void main(String[] args) throws AWTException, InterruptedException, IOException {
|
public static void main(String[] args) throws Exception {
|
||||||
|
WillowChopper willowChopper = new WillowChopper();
|
||||||
|
willowChopper.run();
|
||||||
/*Cursor cursor = new Cursor();
|
/*Cursor cursor = new Cursor();
|
||||||
CursorTask cursorTask = new CursorTask();
|
CursorTask cursorTask = new CursorTask();
|
||||||
Inventory inventory = new Inventory();
|
Inventory inventory = new Inventory();
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user