This repository has been archived by the owner on Jul 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |