Pulled out constants and paths into a separate file
This commit is contained in:
parent
04f997e044
commit
33761e183a
|
@ -14,8 +14,4 @@ public class Constants {
|
|||
public static final int INVENTORY_SLOT_HEIGHT = 254 / 7;
|
||||
public static final int INVENTORY_NUM_ROWS = 4;
|
||||
public static final int INVENTORY_NUM_COLUMNS = 7;
|
||||
|
||||
public static final String INVENTORY_TEST_DIRECTORY_PATH = "/home/dpapp/Desktop/RunescapeAI/Tests/Inventory/";
|
||||
public static final String INVENTORY_ITEMS_TEST_DIRECTORY_PATH = "/home/dpapp/Desktop/RunescapeAI/Tests/ItemNameRecognition/";
|
||||
public static final String INVENTORY_ITEMS_DIRECTORY_PATH = "/home/dpapp/Desktop/RunescapeAI/Items/";
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class Cursor {
|
|||
|
||||
public Cursor() throws AWTException {
|
||||
System.out.println("Initializing cursor...");
|
||||
initializeCursorPathsByDistanceFromFile("/home/dpapp/GhostMouse/coordinates.txt");
|
||||
initializeCursorPathsByDistanceFromFile(Paths.CURSOR_COORDINATES_FILE_PATH);
|
||||
|
||||
robot = new Robot();
|
||||
randomizer = new Randomizer();
|
||||
|
|
|
@ -18,7 +18,6 @@ class CursorTest {
|
|||
@Test
|
||||
void testMoveCursorToCoordinatesHelper() throws Exception {
|
||||
initialize();
|
||||
//cursor.displayCursorPaths();
|
||||
|
||||
testThetaBetweenPoints();
|
||||
testFindNearestPathLengthThatExists();
|
||||
|
@ -32,7 +31,6 @@ class CursorTest {
|
|||
int closestLength = cursor.findNearestPathLengthThatExists(i);
|
||||
assertTrue(closestLength >= closestLengthForPreviousValue);
|
||||
closestLengthForPreviousValue = closestLength;
|
||||
//System.out.println("Closest path to length " + i + " is " + closestLength);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.tensorflow.Graph;
|
||||
import org.tensorflow.Session;
|
||||
import org.tensorflow.Tensor;
|
||||
import org.tensorflow.TensorFlow;
|
||||
|
||||
public class HelloTF {
|
||||
|
||||
public static void test() throws IOException {
|
||||
//Dataset
|
||||
float[] x = new float[]{1};
|
||||
float[] y = x;
|
||||
|
||||
//Setting parameters
|
||||
String modelDir = "/home/dpapp/tensorflow-1.5.0/models/raccoon_dataset/results/checkpoint_23826";
|
||||
|
||||
//Reading the graph
|
||||
byte[] graphDef = Files.readAllBytes(Paths.get(modelDir, "frozen_graph_inference.pb"));
|
||||
|
||||
Tensor input = Tensor.create(0.5f);
|
||||
|
||||
float results = -99999f;
|
||||
try (Graph g = new Graph()) {
|
||||
g.importGraphDef(graphDef);
|
||||
try (Session s = new Session(g);
|
||||
Tensor result = s.runner().feed("input", input).fetch("output").run().get(0)) {
|
||||
results = result.floatValue();
|
||||
}
|
||||
}
|
||||
System.out.println("Expected: " + x + "\tPredicted: " + results);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println("Running helloTF");
|
||||
try (Graph g = new Graph()) {
|
||||
final String value = "Hello from " + TensorFlow.version();
|
||||
|
||||
// Construct the computation graph with a single operation, a constant
|
||||
// named "MyConst" with a value "value".
|
||||
try (Tensor t = Tensor.create(value.getBytes("UTF-8"))) {
|
||||
// The Java API doesn't yet include convenience functions for adding operations.
|
||||
g.opBuilder("Const", "MyConst").setAttr("dtype", t.dataType()).setAttr("value", t).build();
|
||||
}
|
||||
|
||||
// Execute the "MyConst" operation in a Session.
|
||||
try (Session s = new Session(g);
|
||||
Tensor output = s.runner().fetch("MyConst").run().get(0)) {
|
||||
System.out.println(new String(output.bytesValue(), "UTF-8"));
|
||||
}
|
||||
}
|
||||
|
||||
test();
|
||||
}
|
||||
}
|
|
@ -36,7 +36,7 @@ public class Inventory {
|
|||
}
|
||||
|
||||
private void initializeItems() throws IOException {
|
||||
items = new InventoryItems(Constants.INVENTORY_ITEMS_DIRECTORY_PATH);
|
||||
items = new InventoryItems(Paths.INVENTORY_ITEMS_DIRECTORY_PATH);
|
||||
}
|
||||
|
||||
public void update() throws IOException {
|
||||
|
|
|
@ -17,13 +17,13 @@ class InventoryItemsTest {
|
|||
String testingItemDirectoryPath;
|
||||
|
||||
public void initialize() throws IOException {
|
||||
items = new InventoryItems(Constants.INVENTORY_ITEMS_DIRECTORY_PATH);
|
||||
items = new InventoryItems(Paths.INVENTORY_ITEMS_DIRECTORY_PATH);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNameOfItemFromImage() throws IOException {
|
||||
initialize();
|
||||
for (File itemFile : items.getListOfFilesFromItemDirectory(Constants.INVENTORY_ITEMS_TEST_DIRECTORY_PATH)) {
|
||||
for (File itemFile : items.getListOfFilesFromItemDirectory(Paths.INVENTORY_ITEMS_TEST_DIRECTORY_PATH)) {
|
||||
if (itemFile.isFile()) {
|
||||
BufferedImage itemImage = ImageIO.read(itemFile);
|
||||
String expectedItemName = getItemNameForTest(itemFile.getName());
|
||||
|
@ -35,7 +35,7 @@ class InventoryItemsTest {
|
|||
@Test
|
||||
public void testIsImageThisItem() throws IOException {
|
||||
initialize();
|
||||
for (File itemFile : items.getListOfFilesFromItemDirectory(Constants.INVENTORY_ITEMS_TEST_DIRECTORY_PATH)) {
|
||||
for (File itemFile : items.getListOfFilesFromItemDirectory(Paths.INVENTORY_ITEMS_TEST_DIRECTORY_PATH)) {
|
||||
if (itemFile.isFile()) {
|
||||
BufferedImage itemImage = ImageIO.read(itemFile);
|
||||
String expectedItemName = getItemNameForTest(itemFile.getName());
|
||||
|
|
|
@ -83,7 +83,7 @@ class InventoryTest {
|
|||
}
|
||||
|
||||
public BufferedImage loadBufferedImage(String fileName) throws IOException {
|
||||
File itemFile = new File(Constants.INVENTORY_TEST_DIRECTORY_PATH + fileName);
|
||||
File itemFile = new File(Paths.INVENTORY_TEST_DIRECTORY_PATH + fileName);
|
||||
BufferedImage itemImage = ImageIO.read(itemFile);
|
||||
return itemImage;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
public class Paths {
|
||||
public static final String INVENTORY_TEST_DIRECTORY_PATH = "/home/dpapp/Desktop/RunescapeAI/Tests/Inventory/";
|
||||
public static final String INVENTORY_ITEMS_TEST_DIRECTORY_PATH = "/home/dpapp/Desktop/RunescapeAI/Tests/ItemNameRecognition/";
|
||||
public static final String INVENTORY_ITEMS_DIRECTORY_PATH = "/home/dpapp/Desktop/RunescapeAI/Items/";
|
||||
|
||||
public static final String CURSOR_COORDINATES_FILE_PATH = "/home/dpapp/GhostMouse/coordinates.txt";
|
||||
|
||||
public static final String TENSORFLOW_MODEL_DIRECTORY = "/home/dpapp/tensorflow-1.5.0/models/raccoon_dataset/results/checkpoint_23826/saved_model/";
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue