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

first step to pave pathetic the path to universality WiP #116

Draft
wants to merge 44 commits into
base: production
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
2a5dcfc
build(deps): bump org.apache.maven.plugins:maven-javadoc-plugin
dependabot[bot] Dec 9, 2024
b176b80
Merge pull request #113 from Metaphoriker/dependabot/maven/trunk/org.…
Metaphoriker Dec 10, 2024
bc955ea
feat: allowingFailFast and respective logic has been removed
Metaphoriker Dec 12, 2024
354eb89
Merge remote-tracking branch 'origin/trunk' into trunk
Metaphoriker Dec 12, 2024
75958fe
feat: experimental prioritizing feature has been removed
Metaphoriker Dec 12, 2024
b659d13
refact: pathetic-nms is now pathetic-provider and all NMS modules hav…
Metaphoriker Dec 13, 2024
b997c5e
fix: removed withAllowingFailFast method from example module
Metaphoriker Dec 13, 2024
2d7010e
feat: allowingFallback is now true by default
Metaphoriker Dec 13, 2024
cbc9bea
refact: moved spigot provider resolving into SpigotChunkDataProviderR…
Metaphoriker Dec 13, 2024
5336b2e
fix: fixed relativePath in poms
Metaphoriker Dec 13, 2024
3cbdd2d
feat: implemented a way to hook into the pathfinding process
Metaphoriker Dec 14, 2024
d39a12f
refact: PathingStartFindEvent now also has the respective PathfinderC…
Metaphoriker Dec 14, 2024
611f080
refact: pathetic-model is now pathetic-engine
Metaphoriker Dec 15, 2024
33c3066
refact: pathetic-model is now pathetic-engine
Metaphoriker Dec 15, 2024
5398136
refact: SnapshotManager is now BlockProvider
Metaphoriker Dec 15, 2024
40fc3e3
chore: major refactorings
Metaphoriker Dec 15, 2024
8507be1
refact: BlockProvider has been moved to provider package
Metaphoriker Dec 15, 2024
5868110
refact: BukkitPathfinderFactory now no longer takes an initializer - …
Metaphoriker Dec 15, 2024
54a6557
chore: add TODO comment for later
Metaphoriker Dec 15, 2024
43de6fe
build(deps): bump com.google.guava:guava from 33.3.1-jre to 33.4.0-jre
dependabot[bot] Dec 17, 2024
ef1a9a9
Merge pull request #115 from Metaphoriker/dependabot/maven/trunk/com.…
Metaphoriker Dec 17, 2024
8265e69
Delete LICENSE
Metaphoriker Dec 17, 2024
50d3499
Create LICENSE
Metaphoriker Dec 17, 2024
6189a6a
refact: parking the ChunkDataProvider in the provider module, will be…
Metaphoriker Dec 17, 2024
a03f172
feat: remove bukkit-specific path filters from api
Metaphoriker Dec 17, 2024
ab83784
refact: removed javax annotations
Metaphoriker Dec 17, 2024
214883d
chore: README changes
Metaphoriker Dec 17, 2024
900cd4d
feat: the event system and bStats have been removed
Metaphoriker Dec 17, 2024
af89988
refact: make sure that there are now event-leftovers and correctly us…
Metaphoriker Dec 17, 2024
94d930a
refact: remove bStats dependency
Metaphoriker Dec 17, 2024
dae6b68
refact: broken up the dependencies for a better overview for now
Metaphoriker Dec 17, 2024
4b6c9be
feat: added BukkitBlockInformation as a BlockInformation implementati…
Metaphoriker Dec 17, 2024
9cfb926
feat: added BukkitBlockInformation as a BlockInformation implementati…
Metaphoriker Dec 17, 2024
b5cd9a7
Update README.md
Metaphoriker Dec 17, 2024
596d121
Merge pull request #117 from Metaphoriker/Metaphoriker-patch-1
Metaphoriker Dec 17, 2024
f9457b6
Merge remote-tracking branch 'origin/trunk' into trunk
Metaphoriker Dec 17, 2024
904db05
chore: update README
Metaphoriker Dec 17, 2024
83136cc
chore: example and provider module is now in its respective parent mo…
Metaphoriker Dec 19, 2024
b7e9582
chore: important changes to the structure
Metaphoriker Dec 19, 2024
eda9d47
refact: only including stuff which is actually needed by guava
Metaphoriker Dec 19, 2024
35ebe6b
chore: example and provider poms now have relativePaths
Metaphoriker Dec 19, 2024
1ea9f15
feat: PatheticTest is now pathetic-example
Metaphoriker Dec 19, 2024
4fdaa5d
feat: remove build from bukkit module
Metaphoriker Dec 19, 2024
7627067
refact: move classes into engine package
Metaphoriker Dec 19, 2024
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
695 changes: 21 additions & 674 deletions LICENSE

Large diffs are not rendered by default.

46 changes: 40 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

<h1>Pathetic - A Pathfinding library for Minecraft</h1>

<p>A high-performance, backwards-compatible, and asynchronous easy-to-use pathfinding library written in Java.
<br> Pathetic leverages the <b>A* algorithm</b> with customizable heuristics for real-time pathfinding in <b>Spigot/Paper </b>environments.</p>
<p>A high-performance, backwards-compatible, and asynchronous easy-to-use pathfinding library written in Java for 3D environments.
<br> Pathetic leverages the <b>A* algorithm</b> with customizable heuristics for real-time pathfinding.</p>

<h2>Key Features</h2>

Expand All @@ -23,7 +23,7 @@

<h2>Installation</h2>

To integrate pathetic into your project, follow the following steps:
To integrate pathetic into your bukkit project, follow the following steps:
<br>
*(We advise you to relocate pathetic)*

Expand All @@ -40,7 +40,7 @@ To integrate pathetic into your project, follow the following steps:

<dependency>
<groupId>com.github.Metaphoriker.pathetic</groupId>
<artifactId>pathetic-mapping</artifactId>
<artifactId>pathetic-bukkit</artifactId>
<version>VERSION</version>
</dependency>
```
Expand All @@ -55,13 +55,47 @@ allprojects {
}

dependencies {
implementation 'com.github.Metaphoriker.pathetic:pathetic-mapping:VERSION'
implementation 'com.github.Metaphoriker.pathetic:pathetic-bukkit:VERSION'
}
```

<h3>Manual Pathetic</h3>
If you want to leverage pathetic for your own implementation, you can use the following dependency:

<h4>Maven</h4>

```xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependency>
<groupId>de.metaphoriker</groupId>
<artifactId>pathetic-engine</artifactId>
<version>VERSION</version>
</dependency>
```

<h4>Gradle</h4>

```groovy
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}

dependencies {
implementation 'de.metaphoriker:pathetic-engine:VERSION'
}
```

<h2>Example Usage</h2>

<p>See the <a href="https://github.com/Metaphoriker/pathetic/tree/trunk/pathetic-example">pathetic-example</a> module for a detailed example usage.</p>
<p>See the <a href="https://github.com/Metaphoriker/pathetic/tree/trunk/pathetic-example">pathetic-example</a> module for a detailed bukkit example.</p>

<h2>Documentation</h2>

Expand Down
6 changes: 2 additions & 4 deletions pathetic-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
<version>3.3.1</version>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.36</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import java.util.List;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nullable;

import de.metaphoriker.pathetic.api.pathing.hook.PathfinderHook;
import de.metaphoriker.pathetic.api.pathing.result.PathState;
import lombok.NonNull;
import de.metaphoriker.pathetic.api.pathing.filter.PathFilter;
Expand All @@ -27,7 +27,7 @@ public interface Pathfinder {
CompletionStage<PathfinderResult> findPath(
@NonNull PathPosition start,
@NonNull PathPosition target,
@Nullable List<@NonNull PathFilter> filters);
List<@NonNull PathFilter> filters);

/**
* Tries to find a Path between the two {@link PathPosition}'s provided with the given
Expand All @@ -52,8 +52,8 @@ CompletionStage<PathfinderResult> findPath(
CompletionStage<PathfinderResult> findPath(
@NonNull PathPosition start,
@NonNull PathPosition target,
@Nullable List<PathFilter> sharedFilters,
@Nullable List<@NonNull PathFilterStage> filterStages);
List<@NonNull PathFilter> sharedFilters,
List<@NonNull PathFilterStage> filterStages);

/**
* Aborts the running pathfinding process.
Expand All @@ -62,4 +62,11 @@ CompletionStage<PathfinderResult> findPath(
* will be {@link PathState#ABORTED}.
*/
void abort();

/**
* Registers a {@link PathfinderHook} that will be called on every step of the pathfinding process.
* This can be used to modify the pathfinding process or to collect data.
* @param hook The hook to register.
*/
void registerPathfindingHook(PathfinderHook hook);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package de.metaphoriker.pathetic.api.pathing;

import de.metaphoriker.pathetic.api.pathing.configuration.PathfinderConfiguration;

/**
* A factory class for creating {@link Pathfinder} instances.
*
* @param <I> The type of {@link PathfinderInitializer} used to initialize the pathfinder.
*/
public abstract class PathfinderFactory<I extends PathfinderInitializer> {

protected final I initializer;

/**
* Creates a new {@link PathfinderFactory} with the given initializer.
*
* @param initializer The initializer to use for initializing the pathfinder.
*/
public PathfinderFactory(I initializer) {
this.initializer = initializer;
}

/**
* Creates a new {@link Pathfinder} instance with the given configuration.
*
* @param configuration The configuration for the pathfinder.
* @return A new {@link Pathfinder} instance.
*/
public abstract Pathfinder createPathfinder(PathfinderConfiguration configuration);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package de.metaphoriker.pathetic.api.pathing;

import de.metaphoriker.pathetic.api.pathing.configuration.PathfinderConfiguration;

/**
* An interface for initializing {@link Pathfinder} instances.
*/
public interface PathfinderInitializer {

/**
* Initializes the given {@link Pathfinder} with the given {@link PathfinderConfiguration}.
*
* @param pathfinder The pathfinder to initialize.
* @param configuration The configuration for the pathfinder.
*/
void initialize(Pathfinder pathfinder, PathfinderConfiguration configuration);
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package de.metaphoriker.pathetic.api.pathing.configuration;

import de.metaphoriker.pathetic.api.annotation.Experimental;
import de.metaphoriker.pathetic.api.pathing.Pathfinder;
import de.metaphoriker.pathetic.api.pathing.filter.PathFilterStage;
import de.metaphoriker.pathetic.api.wrapper.PathPosition;
import java.util.List;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -30,7 +25,7 @@
*
* @default 5000
*/
@Builder.Default int maxIterations = 5000;

Check warning on line 28 in pathetic-api/src/main/java/de/metaphoriker/pathetic/api/pathing/configuration/PathfinderConfiguration.java

View workflow job for this annotation

GitHub Actions / qodana

Field can be made 'static'

Field `maxIterations` may be 'static'

/**
* The maximum permissible length of a calculated path (in blocks). Use this to constrain long
Expand All @@ -45,43 +40,19 @@
*/
boolean async;

/**
* If set to true, the pathfinding process will terminate immediately if either the start or
* target or both are unreachable.
*
* <p>NOTE: This prevents fallback strategies.
* @deprecated Will be removed in future releases
*/
@Deprecated
boolean allowingFailFast;

/**
* If pathfinding fails, this parameter determines whether the algorithm should fall back to the
* last successfully calculated path. This can help maintain progress, but might use an outdated
* path.
*/
boolean allowingFallback;
@Builder.Default boolean allowingFallback = true;

Check warning on line 48 in pathetic-api/src/main/java/de/metaphoriker/pathetic/api/pathing/configuration/PathfinderConfiguration.java

View workflow job for this annotation

GitHub Actions / qodana

Field can be made 'static'

Field `allowingFallback` may be 'static'

/**
* Controls whether chunks should be loaded or generated as needed during the pathfinding process.
* This is essential for exploring uncharted areas, but may impact performance.
*/
boolean loadingChunks;

/**
* Determines whether the pathfinding algorithm should see PathFilterStages as prioritization,
* instead of filtering. This means that the pathfinding algorithm will prioritize paths that pass
* the filters over paths that do not.
*
* <p>Setting this to true will no longer take the {@link PathFilterStage}s into the validation
* process. Shared filters must still be passed.
*
* <p>{@link Pathfinder#findPath(PathPosition, PathPosition, List, List)}
*
* @experimental This feature is experimental and may be subject to change.
*/
@Experimental @Builder.Default boolean prioritizing = false;

/**
* The set of weights used to calculate heuristics within the A* algorithm. These influence the
* pathfinding priority for distance, elevation changes, smoothness, and diagonal movement.
Expand All @@ -90,16 +61,6 @@
*/
@Builder.Default HeuristicWeights heuristicWeights = HeuristicWeights.NATURAL_PATH_WEIGHTS;

/**
* Determines whether the pathfinding algorithm should collect statistics about the pathfinding
* process. This can be useful for debugging and performance tuning.
*
* <p>Help us improve the API by providing feedback with the collected statistics!
*
* @default true
*/
@Builder.Default boolean bStats = true;

/**
* @return A new {@link PathfinderConfiguration} with default parameters but async.
*/
Expand Down Expand Up @@ -129,7 +90,6 @@
.maxIterations(pathfinderConfiguration.maxIterations)
.maxLength(pathfinderConfiguration.maxLength)
.async(pathfinderConfiguration.async)
.allowingFailFast(pathfinderConfiguration.allowingFailFast)
.allowingFallback(pathfinderConfiguration.allowingFallback)
.loadingChunks(pathfinderConfiguration.loadingChunks)
.heuristicWeights(pathfinderConfiguration.heuristicWeights)
Expand Down
Loading
Loading