This commit is contained in:
Badbird-5907
2022-07-13 14:33:06 -04:00
parent 4b6f34f9d9
commit 0ed30a0731
8 changed files with 24 additions and 18 deletions

View File

@@ -17,6 +17,6 @@ repositories {
}
dependencies {
compileOnly("io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.19-R0.1-SNAPSHOT")
compileOnly("com.mojang:authlib:3.2.38")
}

View File

@@ -2,7 +2,6 @@ package net.nuggetmc.tplus.api.agent.legacyagent.ai;
import net.nuggetmc.tplus.api.Terminator;
import net.nuggetmc.tplus.api.utils.MathUtils;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@@ -48,6 +47,6 @@ public class BotData {
Collections.sort(strings);
return "BotData{" + StringUtils.join(strings, ",") + "}";
return "BotData{" + NeuralNetwork.join(strings) + "}";
}
}

View File

@@ -3,7 +3,6 @@ package net.nuggetmc.tplus.api.agent.legacyagent.ai;
import net.md_5.bungee.api.ChatColor;
import net.nuggetmc.tplus.api.utils.ChatUtils;
import net.nuggetmc.tplus.api.utils.MathUtils;
import org.apache.commons.lang.StringUtils;
import java.util.*;
@@ -71,11 +70,19 @@ public class NeuralNetwork {
return output;
}
public static String join(Collection<String> collection) {
StringBuilder sb = new StringBuilder();
for (String s : collection) {
sb.append(s).append(", ");
}
return sb.substring(0, sb.length() - 2);
}
public String output() {
List<String> strings = new ArrayList<>();
nodes.forEach((type, node) -> strings.add(type.name().toLowerCase() + "=" + (node.check() ? ChatUtils.ON + "1" : ChatUtils.OFF + "0") + ChatColor.RESET));
Collections.sort(strings);
return "[" + StringUtils.join(strings, ", ") + "]";
return "[" + join(strings) + "]";
}
@Override
@@ -86,9 +93,9 @@ public class NeuralNetwork {
List<String> values = new ArrayList<>();
values.add("name=\"" + nodeType.name().toLowerCase() + "\"");
node.getValues().forEach((dataType, value) -> values.add(dataType.getShorthand() + "=" + MathUtils.round2Dec(value)));
strings.add("{" + StringUtils.join(values, ",") + "}");
strings.add("{" + join(values) + "}");
});
return "NeuralNetwork{nodes:[" + StringUtils.join(strings, ",") + "]}";
return "NeuralNetwork{nodes:[" + join(strings) + "]}";
}
}