diff --git a/README.md b/README.md index 6157b0f..f161ebb 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,32 @@ -# Countroll -A java program to make counting bots a bit more interesting + +# Countroll - Description + +Countroll is designed to make using counting bots a bit more interesting. It turns integers into complex, unreadable +mathematical expressions, perfect for showing off your mathematical knowledge to you friends! +Countroll uses the following operators to make your integer as complex as possible + +- Addition | + +- Subtraction | + +- Multiplication | * +- Division | / +- Square Root | sqrt() +- Exponentiation | ^ + +## Compatibility + +Countroll is currently only compatible with [Numselli's counting bot](https://counting.numselli.xyz/), although I hope to be able to support more counting bots soon! + +## Usage + +1. Compile the Java program from the source, or download a Precompiled Jar +2. Execute it through the command-line `java -jar Countroll-.jar` +3. Enter a target integer. (Whole number ie: 1, 16, 4096) +4. Copy the outputed expression and use it wherever you'd like! + +# Compiling +Make sure you have Java 17 or higher installed on your system! +1. Clone the repo `$ git clone https://github.com/thetrouper/Countroll/` +2. Change directory to the repo `$ cd Countroll` +3. Build with gradle `$ ./gradlew build` +4. Build will be output to `/Countroll/build/libs` + diff --git a/src/main/java/me/trouper/Functions/Utils.java b/src/main/java/me/trouper/Functions/Utils.java new file mode 100644 index 0000000..4e09b06 --- /dev/null +++ b/src/main/java/me/trouper/Functions/Utils.java @@ -0,0 +1,18 @@ +package me.trouper.Functions; + +import me.trouper.Main; + +import java.awt.*; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; + +public class Utils { + public static void copyToClip(String text) { + StringSelection parsed = new StringSelection(text); + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + clipboard.setContents(parsed,null); + } + public static void verbose(String text) { + if (Main.verbose) System.out.println(text); + } +} diff --git a/src/main/java/me/trouper/Main.java b/src/main/java/me/trouper/Main.java index 89af6b0..6bb8095 100644 --- a/src/main/java/me/trouper/Main.java +++ b/src/main/java/me/trouper/Main.java @@ -1,27 +1,41 @@ package me.trouper; import me.trouper.Functions.Complexers; +import me.trouper.Functions.Utils; import java.util.Random; import java.util.Scanner; import static me.trouper.Functions.Eval.*; +import static me.trouper.Functions.Utils.verbose; public class Main { - + public static boolean verbose; + public static boolean deep; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); + boolean doCopy = false; + + + for (String arg : args) { + switch (arg) { + case "--copy" -> doCopy = true; + case "--verbose" -> verbose = true; + case "--deep" -> deep = true; + } + } while (true) { System.out.print("Enter Target Integer: "); if (scanner.hasNextInt()) { int target = scanner.nextInt(); - String expression = obfInt(target); + String expression = obfInt(target,deep); double output = eval(expression); System.out.println("\nTarget Integer: " + target); if (output == target) { System.out.println("Expression Verified Correct: \n" + expression); + if (doCopy) Utils.copyToClip(expression); } else { System.out.println("!!!! INCORRECT !!!! \n" + expression); } @@ -34,12 +48,13 @@ public class Main { scanner.close(); } - public static String obfInt(int target) { + public static String obfInt(int target, boolean deep) { + if (deep) System.out.println("Deep Obfuscation is still in development!"); StringBuilder expression = new StringBuilder(); Random random = new Random(); int initializer = random.nextInt(9)+1; - System.out.println("Initializing Expression: " + initializer); + verbose("Initializing Expression: " + initializer); expression.append(initializer); int cubeCount = 0; @@ -56,6 +71,7 @@ public class Main { int eval = (int) eval(expression.toString()); int ri = random.nextInt(9)+1; int op = random.nextInt(2); + boolean mult = false; if (!isInt(eval(expression.toString()))) { System.out.println("Something went horribly wrong, Here is the relevant info." + @@ -66,24 +82,26 @@ public class Main { break; } - System.out.println("Random: " + ri); - System.out.println("Current: " + eval(expression.toString())); + verbose("Random: " + ri); + verbose("Current: " + eval(expression.toString())); if (isPerfectSquare(eval)) { perfectCount++; - System.out.println("PERFECT SQUARE TIME! (" + perfectCount+ ")"); + verbose("PERFECT SQUARE TIME! (" + perfectCount+ ")"); expression.insert(0,"sqrt(").append(")"); eval = (int) eval(expression.toString()); } if (target - eval > 1000) { + mult = true; cubeCount++; - System.out.println("Enormous than (" + cubeCount + ")"); + verbose("Enormous than (" + cubeCount + ")"); expression.append("+").append(Complexers.power(ri,3)); } else if (target - eval > 100) { factorCount++; - System.out.println("Large than (" + factorCount + ")"); + verbose("Large than (" + factorCount + ")"); expression.append("+").append(Complexers.multiply(ri,10)); + continue; } if (eval < target) { @@ -93,8 +111,8 @@ public class Main { } else { rootCount++; } - expression.append("+").append((op == 0) ? Complexers.divide(ri) : Complexers.root(ri)); - System.out.println("Less than (" + addCount + ")"); + expression.append((mult) ? "*" : "+").append((op == 0) ? Complexers.divide(ri) : Complexers.root(ri)); + verbose("Less than (" + addCount + ")"); } if (eval > target) { @@ -107,19 +125,19 @@ public class Main { expression.insert(0,"(").append(")"); expression.append("-").append((op == 0) ? Complexers.divide(ri) : Complexers.root(ri)); - System.out.println("Greater than (" + subCount + ")"); + verbose("Greater than (" + subCount + ")"); } } - System.out.println("Broke out of loop. Value: " + eval(expression.toString())); - System.out.println("Expression: " + expression.toString()); - System.out.println("Statistics: " + + verbose("Broke out of loop. Value: " + eval(expression.toString())); + verbose("Expression: " + expression); + System.out.println("\n\n\n\nStatistics: " + "\nCubes: " + cubeCount + "\nFactors: " + factorCount + "\nAdditions: " + addCount + "\nSubtractions: " + subCount + "\nRoots Taken: " + rootCount + - "\nDivisors " + divideCount + + "\nDivisors: " + divideCount + "\nPerfect Squares Found: " + perfectCount + "\nTotal steps taken: " + total); return expression.toString();