Skip to content
This repository has been archived by the owner on Jul 2, 2023. It is now read-only.

Commit

Permalink
Added 'Loop Mode'
Browse files Browse the repository at this point in the history
  • Loading branch information
LongCTygo committed Mar 8, 2023
1 parent be5766a commit 43fba50
Showing 1 changed file with 39 additions and 15 deletions.
54 changes: 39 additions & 15 deletions src/Main.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,52 @@
import math.Vector2;

import puzzle.Board;
import solver.Node;
import solver.SolutionTree;

import java.util.Scanner;

public class Main {

public static void main(String[] args) {
if (args.length == 0){
throw new RuntimeException("No arguments were supplied. At least 1 seed must be given.");
throw new RuntimeException("No arguments were supplied. At least 1 argument must be given.");
}
for (String seed : args){
long startTime = System.nanoTime();
System.out.printf("------------------- Seed %s -------------------\n", seed);
try {
int s = Integer.parseInt(seed);
SolutionTree st = new SolutionTree(new Node(new Board(s)));
st.solveBFS(20,10000000,true,true);
System.out.println();
} catch (Exception ex){
System.err.printf("Exception Caught for argument %s: %s\n",seed, ex.getClass().getName());
System.err.println("Exception Message: " + ex.getMessage());
//Loop Mode
if (args[0].equals("-loop")){
Scanner scanner = new Scanner(System.in);
while (true){
System.out.print("Input your list of seeds here: ");
String input = scanner.nextLine();
if (input.isEmpty()){
System.out.println("No input received. Stopping...");
return;
}
String[] seeds = input.split(" ");
for (String seed : seeds){
solve(seed);
}
}
} else { //Normal Mode
for (String seed : args){
solve(seed);
}
long endTime = System.nanoTime();
System.out.printf("Finished in %s miliseconds.\n",(endTime-startTime) / 1000000L);
}
}

public static void solve(String seed){
long startTime = System.nanoTime();
System.out.printf("------------------- Seed '%s' -------------------\n", seed);
try {
int s = Integer.parseInt(seed);
SolutionTree st = new SolutionTree(new Node(new Board(s)));
st.solveBFS(20,10000000,true,true);
System.out.println();
} catch (Exception ex){
System.err.printf("Exception Caught for argument %s: %s\n",seed, ex.getClass().getName());
System.err.println("Exception Message: " + ex.getMessage());
System.out.println();
}
long endTime = System.nanoTime();
System.out.printf("Finished in %s miliseconds.\n",(endTime-startTime) / 1000000L);
}
}

0 comments on commit 43fba50

Please sign in to comment.