Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed drone-ai #56

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7f00001
Fixed drone-ai
Zelaux Jan 29, 2025
2ce6c6a
Fixed Drone AI
Zelaux Jan 31, 2025
ebca1fb
Added chained mined resources delivery
Zelaux Jan 31, 2025
6eac2f7
AI fix#2
Zelaux Feb 5, 2025
4e9320b
addeed internal gradle plugin
Zelaux Feb 5, 2025
87063f7
Fixed utility drone ai#3
Zelaux Feb 6, 2025
f650408
Fixed missing anchor pos
Zelaux Feb 6, 2025
a9072c4
Merge remote-tracking branch 'origin/master' into drone-ai-fix
Zelaux Feb 6, 2025
fcfe97b
AI fix#5
Zelaux Feb 7, 2025
fdb26d7
DroneAI added leaving the build plan if he is outside the owner
Zelaux Feb 8, 2025
e3d5529
DroneAI added infinite range in sandbox
Zelaux Feb 8, 2025
7a2ee1e
DroneAI better positioning
Zelaux Feb 8, 2025
ebb870e
Merge remote-tracking branch 'origin/drone-ai-fix' into drone-ai-fix
Zelaux Feb 8, 2025
6c84f17
Drone AI fixed NPE
Zelaux Feb 9, 2025
a76d710
Added DebugDraw hot key
Zelaux Feb 9, 2025
419b78b
DroneAI better movement
Zelaux Feb 9, 2025
aac3c23
DroneAI fixed unit rotation
Zelaux Feb 10, 2025
40e285b
DroneAI better attacker movement
Zelaux Feb 10, 2025
145103a
DroneAI better builder movement
Zelaux Feb 12, 2025
ffbaaeb
actionDroneMono became a drone...
Zelaux Feb 15, 2025
50b8f71
Now drones will always have DroneAI
Zelaux Feb 15, 2025
c9c2467
author me
Zelaux Feb 15, 2025
90a7dd0
small refactor OlGeometry.java
Zelaux Feb 15, 2025
5c93333
DebugDraw disabled on headless
Zelaux Feb 16, 2025
2289094
New Drone API
Zelaux Feb 16, 2025
274d0a4
Sync fix#1
Zelaux Feb 16, 2025
dbd1c3a
Fixed AutoImpl npe
Zelaux Feb 16, 2025
6a11e90
Sync fix#2
Zelaux Feb 16, 2025
a5cabbd
Sync fix#3
Zelaux Feb 16, 2025
88c135e
Fixed chained transfer
Feb 18, 2025
89d9ff5
Now drone is building when the resources are not enough
Feb 18, 2025
659f81f
Formatting AttackDroneAI.java
Feb 19, 2025
a8fb5ee
Moved OlGeometry into omaloon.math
Feb 19, 2025
bcfed91
Better Attacker movement & Added test
Feb 19, 2025
0a25349
Fixed unit rotation
Feb 20, 2025
17bde11
Better zelaux core version
Feb 20, 2025
6e30978
Fixed unit rotation
Zelaux Feb 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import bytelogic.lombok.util.*;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.tree.*;
import com.sun.tools.javac.tree.JCTree.*;
import lombok.*;
import lombok.core.*;
import lombok.javac.*;
Expand Down Expand Up @@ -112,14 +113,16 @@ public void visitType(JavacNode typeNode, JCTree.JCClassDecl type){
if(!autoImplClasses.contains(canonicalFullname(typeNode))) return;

InfoAndPos[] interfaceInfos = StreamEx
.of(type.implementing)
.ofNullable(type.implementing)
.flatMap(StreamEx::of)
.mapToEntry(Function.identity())
.mapKeys(Object::toString)
.filterKeys(string -> !string.contains("<")) //TODO Generic implement
.mapKeys(it -> Paths.fullifyName(typeNode, it, interfacesLibrary))
.mapKeys(CollectedHierarchyInfo::interfaceInfo)
.nonNullKeys()
.mapKeys(simpleInterfaceToAutoImpl::get)
.nonNullKeys()
.flatMapKeys(StreamEx::of)
.distinctKeys()
.mapKeyValue(InfoAndPos::new)
Expand All @@ -135,19 +138,15 @@ public void visitType(JavacNode typeNode, JCTree.JCClassDecl type){

private void implement(InterfaceInfo info, @NonNull JCTree.JCExpression producer, JavacNode typeNode, JCTree.JCClassDecl type){
AutoImplInformation information = info.get(ImplMarker.isAutoImpl);
Map<AST.Kind, Map<String, List<JavacNode>>> childrenMap = StreamEx
Map<AST.Kind, List<JavacNode>> childrenMap = StreamEx
.of(typeNode.down().iterator())
.mapToEntry(LombokNode::getKind, Function.identity())
.sortedBy(Map.Entry::getKey)
.collapseKeys()
.mapValues(StreamEx::of)
.mapValues(it -> it.mapToEntry(JavacNode::getName, Function.identity()))
.mapValues(it -> it.collapseKeys().sortedBy(Map.Entry::getKey).toMap())
.toMap();
Map<String, JavacNode> fields = EntryStream
.of(childrenMap.getOrDefault(AST.Kind.FIELD, new HashMap<>()))
.mapValues(it -> it.get(0))
.toMap();
Map<String, JavacNode> fields = StreamEx
.of(childrenMap.getOrDefault(AST.Kind.FIELD, Collections.emptyList()))
.toMap(JavacNode::getName,Function.identity());
for(Map.Entry<String, AutoImplInformation.FieldInfo> entry : information.fields.entrySet()){
JavacNode existed = fields.get(entry.getKey());
AutoImplInformation.FieldInfo fieldInfo = entry.getValue();
Expand Down Expand Up @@ -184,7 +183,6 @@ private void implement(InterfaceInfo info, @NonNull JCTree.JCExpression producer
Map<String, JavacNode> methods = EntryStream
.of(childrenMap.get(AST.Kind.METHOD))
.values()
.flatMap(StreamEx::of)
.mapToEntry(it -> Util.methodDesc(it, (JCTree.JCMethodDecl)it.get()), Function.identity())
.toMap();

Expand Down
66 changes: 55 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import arc.util.OS
import arc.util.serialization.Jval
import de.undercouch.gradle.tasks.download.Download
import ent.EntityAnnoExtension
import mmc.JarMindustryTask
import org.jetbrains.kotlin.gradle.plugin.KaptExtension
import java.io.BufferedWriter

buildscript {
Expand Down Expand Up @@ -36,6 +38,7 @@ val asmLib: (String) -> Any = {

val arcVersion: String by project
val arcLibraryVersion: String by project
val zelauxCoreVersion: String by project
val mindustryVersion: String by project
val mindustryBEVersion: String by project
val entVersion: String by project
Expand All @@ -57,7 +60,11 @@ fun arc(module: String): String {
}

fun arcLibrary(module: String): String {
return "com.github.Zelaux.ArcLibrary$module:$arcLibraryVersion"
return "com.github.Zelaux.ArcLibrary:${module.trim(':').replace(':', '-')}:$arcLibraryVersion"
}

fun zelauxCore(module: String): String {
return "com.github.Zelaux.MindustryModCore:${module.trim(':').replace(':', '-')}:$zelauxCoreVersion"
}

fun mindustry(module: String): String {
Expand All @@ -70,8 +77,13 @@ fun entity(module: String): String {

extra.set("asmLib", asmLib)
project(":") {
apply {
from("tests/setup-tests.gradle")
}
apply(plugin = "java")
sourceSets["main"].java.setSrcDirs(listOf(layout.projectDirectory.dir("src")))
sourceSets["test"].java.setSrcDirs(listOf(layout.projectDirectory.dir("tests/test")))
sourceSets["test"].resources.setSrcDirs(listOf(layout.projectDirectory.dir("tests/resources")))

configurations.configureEach {
// Resolve the correct Mindustry dependency, and force Arc version.
Expand Down Expand Up @@ -117,6 +129,13 @@ project(":") {
}

project(":") {
//sometimes task checkKotlinGradlePluginConfigurationErrors are missing...
// tasks.register("checkKotlinGradlePluginConfigurationErrors1"){ }
tasks.register("mindustryJar", JarMindustryTask::class) {
dependsOn(tasks.getByPath("jar"))
group = "build"
}

apply(plugin = "com.github.GlennFolker.EntityAnno")
configure<EntityAnnoExtension> {
modName = project.properties["modName"].toString()
Expand All @@ -127,6 +146,13 @@ project(":") {
genSrcPackage = modGenSrc
genPackage = modGen
}
configure<KaptExtension> {
arguments {
arg("ROOT_DIRECTORY", project.rootDir.canonicalPath)
arg("rootPackage", "ol")
arg("classPrefix", "Ol")
}
}

//Added debuging diring compilation to debug annotation processors
tasks.withType(JavaCompile::class).configureEach {
Expand All @@ -139,21 +165,39 @@ project(":") {
)
}
dependencies {
compileOnly("org.projectlombok:lombok:1.18.32")
annotationProcessor("org.projectlombok:lombok:1.18.32")
annotationProcessor(asmLib("annotations:debug-print"))
annotationProcessor(project(":annotations"))

// Use the entity generation annotation processor.
compileOnly(entity(":entity"))
add("kapt", entity(":entity"))

compileOnly("org.jetbrains:annotations:24.0.1")

compileOnly(mindustry(":core"))
compileOnly(arc(":arc-core"))
implementation(arcLibrary(":graphics-draw3d"))
implementation(arcLibrary(":graphics-dashDraw"))
implementation(arcLibrary(":graphics-extendedDraw"))
var kaptAnno = listOf(
entity(":entity"),
zelauxCore(":annotations:remote")
)
kaptAnno.forEach {
compileOnly(it) {
this.isTransitive = false;
}
add("kapt", it)
}
arrayOf(
"org.jetbrains:annotations:24.0.1",
mindustry(":core"),
arc(":arc-core"),
).forEach {
compileOnly(it);
testImplementation(it);
}
arrayOf(
arcLibrary(":graphics:drawText"),
arcLibrary(":graphics-draw3d"),
arcLibrary(":graphics-dashDraw"),
arcLibrary(":graphics-extendedDraw"),
).forEach {
implementation(it)
testImplementation(it)
}
}

val jar = tasks.named<Jar>("jar") {
Expand Down
22 changes: 22 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@


apply plugin: 'groovy'
apply plugin: 'java'


repositories{
mavenCentral()
maven { url 'https://raw.githubusercontent.com/Zelaux/MindustryRepo/master/repository' }
}
println "root: "+getRootDir()
dependencies{
compileOnly gradleApi()
compileOnly localGroovy()
compileOnly("org.jetbrains:annotations:24.0.1")
implementation 'commons-io:commons-io:2.6'



compileOnly 'org.projectlombok:lombok:1.18.30'
annotationProcessor 'org.projectlombok:lombok:1.18.30'
}
Binary file added buildSrc/build/libs/buildSrc.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions buildSrc/build/tmp/jar/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Manifest-Version: 1.0

Binary file added buildSrc/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions buildSrc/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
172 changes: 172 additions & 0 deletions buildSrc/gradlew
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
#!/usr/bin/env sh

##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn () {
echo "$*"
}

die () {
echo
echo "$*"
echo
exit 1
}

# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi

# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option

if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi

# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "$@"
Loading