split up singular and quantized single parent priority allocators

This commit is contained in:
Leijurv
2018-10-31 13:30:37 -07:00
parent e7a09c34ea
commit 24bb0c541c
6 changed files with 35 additions and 12 deletions
@@ -17,7 +17,7 @@
package tenor;
public interface ISingleParentPriorityAllocator extends IQuantizedTask {
public interface ISingleParentQuantizedPriorityAllocator extends IQuantizedTask {
@Override
default IQuantityRelationship priority() {
if (parentTasks().size() != 1) {
@@ -0,0 +1,28 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package tenor;
public interface ISingleParentSingularPriorityAllocator extends ISingularTask {
@Override
default double priority() {
if (parentTasks().size() != 1) {
throw new IllegalStateException();
}
return parentTasks().get(0).allocatedPriority();
}
}
@@ -17,10 +17,10 @@
package tenor.game;
import tenor.ISingularChildTaskRelationship;
import tenor.ISingleParentSingularPriorityAllocator;
import tenor.SingularTaskLeaf;
public class ActuallyCraftTask extends SingularTaskLeaf {
public class ActuallyCraftTask extends SingularTaskLeaf implements ISingleParentSingularPriorityAllocator {
public final CraftingTask parent;
@@ -33,9 +33,4 @@ public class ActuallyCraftTask extends SingularTaskLeaf {
public double cost() {
return 420;
}
@Override
public double priority() {
return parentTasks().stream().mapToDouble(ISingularChildTaskRelationship::allocatedPriority).sum();
}
}
@@ -19,7 +19,7 @@ package tenor.game;
import tenor.*;
public class AquireCraftingItems extends QuantizedTaskNode implements IClaimProvider, ISingleParentPriorityAllocator {
public class AquireCraftingItems extends QuantizedTaskNode implements IClaimProvider, ISingleParentQuantizedPriorityAllocator {
final CraftingTask parent;
+1 -1
View File
@@ -22,7 +22,7 @@ import tenor.*;
import java.util.List;
public class CraftingTask extends QuantizedTaskNode implements ISingleParentPriorityAllocator {
public class CraftingTask extends QuantizedTaskNode implements ISingleParentQuantizedPriorityAllocator {
int outputQuantity;
List<Tuple<AquireItemTask, Integer>> recipe;
+2 -2
View File
@@ -18,10 +18,10 @@
package tenor.game;
import tenor.IQuantityRelationship;
import tenor.ISingleParentPriorityAllocator;
import tenor.ISingleParentQuantizedPriorityAllocator;
import tenor.QuantizedTaskLeaf;
public class MineTask extends QuantizedTaskLeaf implements ISingleParentPriorityAllocator {
public class MineTask extends QuantizedTaskLeaf implements ISingleParentQuantizedPriorityAllocator {
final AquireItemTask parent;