From 6775027239c8d8498b71998f78ac849f1378e4d4 Mon Sep 17 00:00:00 2001 From: GlennFolker Date: Mon, 2 Nov 2020 10:11:43 +0700 Subject: [PATCH] =?UTF-8?q?c=CD=A0h=CC=99a=CC=8C=E2=80=8E=E2=80=8E?= =?UTF-8?q?=E2=80=8F=E2=80=8E=E2=80=8Fn=E2=80=8F=CC=B6g=E2=80=8E=CC=A6?= =?UTF-8?q?=E2=80=8Fe=E2=80=8E=CD=8F=E2=80=8F=20=E2=80=8E=E2=80=8Es?= =?UTF-8?q?=E2=80=8F=E2=80=8F=CD=ACt=E2=80=8E=CD=9C=E2=80=8F=E2=80=8Ey?= =?UTF-8?q?=E2=80=8F=CC=95l=E2=80=8E=CC=89=E2=80=8F=E2=80=8E=E2=80=8Ee?= =?UTF-8?q?=E2=80=8F=E2=80=8F=CC=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/namegen/NameGen.java | 62 +++++++++++++++------------------------- 1 file changed, 23 insertions(+), 39 deletions(-) diff --git a/src/namegen/NameGen.java b/src/namegen/NameGen.java index 4d5898b..71e5137 100644 --- a/src/namegen/NameGen.java +++ b/src/namegen/NameGen.java @@ -4,8 +4,10 @@ import java.awt.*; import java.awt.datatransfer.*; import java.io.*; +import java.util.*; public class NameGen{ + private static Random rand = new Random(); private static boolean exit = false; public static synchronized void main(String[] args){ @@ -49,62 +51,44 @@ public static synchronized void name(BufferedReader reader) throws IOException{ String name = reader.readLine().replace("\\n", Character.toString('\n')); StringBuilder result = new StringBuilder(); - int last, num = 0; - for(int iteration = 0; iteration < 3; iteration++){ - for(int i = 0; i < name.length(); i++){ - last = num; - - int a = name.codePointAt((i - 1 + name.length()) % name.length()); - int b = name.codePointAt((i + 1 + name.length()) % name.length()); - int n = name.codePointAt(i); - - num = (n << a >> b) ^ (n >> a << b); - - for(int h = 0; h < 2; h++){ - int f = name.codePointAt(Math.abs((num + name.length()) % name.length())); - - if(num <= last){ - num ^= f; - }else{ - num >>= f; - } - } + for(int i = 0; i < name.length(); i++){ + int min = 0x0300; + int max = 0x036F; + int range = max - min; - int seed = 768 + (num % 111); - int seedB = 710 + (num % 19); - int seedC = num <= last ? seed : seedB; + rand.setSeed(i); + int seed = min + rand.nextInt(range + 1); - char c = name.charAt(i); + char c = name.charAt(i); - result.append(Character.toString(c)); - if(!Character.isWhitespace(c)){ - result.append(Character.toString(seedC)); - } + result.append(Character.toString(c)); + if(!Character.isWhitespace(c)){ + result.append(Character.toString(seed)); } + } + int iterations = 3, freq = iterations * 2; + + for(int it = 0; it < iterations; it++){ name = result.toString(); result.setLength(0); - } - int iterations = 3, freq = iterations * 2; - for(int iteration = 0; iteration < iterations; iteration++){ for(int i = 0; i < name.length(); i++){ char c = name.charAt(i); - result.append(Character.toString(c)); - - if((i + iteration % (freq + 1)) == freq){ - String a = Character.toString(8206) + Character.toString(c) + Character.toString(8207); - a = Character.toString(8238) + a + Character.toString(8234); + if(i % (freq + 1) == freq){ + CharSequence a = Character.toString(8206) + Character.toString(c) + Character.toString(8207); result.append(a); + }else{ + result.append(Character.toString(c)); } } - - name = result.toString(); - result.setLength(0); } + name = result.toString(); + result.setLength(0); + boolean success = setClipboardString(name); if(success){ Log.log(LogLevel.info, "Generated name has been copied to clipboard!");