made bools and sets Arithmetic as well, did the documentation
This commit is contained in:
parent
99a1ad6528
commit
6fdee9e541
14 changed files with 263 additions and 99 deletions
|
@ -34,4 +34,15 @@ public interface Arithmetic {
|
|||
HexPattern REPLACE = HexPattern.fromAngles("wqaeaqw", HexDir.NORTH_WEST);
|
||||
HexPattern CONS = HexPattern.fromAngles("ddewedd", HexDir.SOUTH_EAST);
|
||||
HexPattern UNCONS = HexPattern.fromAngles("aaqwqaa", HexDir.SOUTH_WEST);
|
||||
|
||||
// Boolean Logic, Comparisons, & Sets
|
||||
HexPattern AND = HexPattern.fromAngles("wdw", HexDir.NORTH_EAST);
|
||||
HexPattern OR = HexPattern.fromAngles("waw", HexDir.SOUTH_EAST);
|
||||
HexPattern XOR = HexPattern.fromAngles("dwa", HexDir.NORTH_WEST);
|
||||
HexPattern GREATER = HexPattern.fromAngles("e", HexDir.SOUTH_EAST);
|
||||
HexPattern LESS = HexPattern.fromAngles("q", HexDir.SOUTH_WEST);
|
||||
HexPattern GREATER_EQ = HexPattern.fromAngles("ee", HexDir.SOUTH_EAST);
|
||||
HexPattern LESS_EQ = HexPattern.fromAngles("qq", HexDir.SOUTH_WEST);
|
||||
HexPattern NOT = HexPattern.fromAngles("dw", HexDir.NORTH_WEST);
|
||||
HexPattern UNIQUE = HexPattern.fromAngles("aweaqa", HexDir.NORTH_EAST);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package at.petrak.hexcasting.common.casting.arithmetic
|
||||
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.Arithmetic
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.Arithmetic.*
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.engine.InvalidOperatorException
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.operator.Operator
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.operator.Operator.downcast
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.operator.OperatorBinary
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.operator.OperatorUnary
|
||||
import at.petrak.hexcasting.api.casting.iota.DoubleIota
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.math.HexPattern
|
||||
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes.DOUBLE
|
||||
import java.util.function.LongBinaryOperator
|
||||
import java.util.function.LongUnaryOperator
|
||||
import kotlin.math.roundToLong
|
||||
|
||||
object BitwiseSetArithmetic : Arithmetic {
|
||||
private val OPS = listOf(
|
||||
AND,
|
||||
OR,
|
||||
XOR,
|
||||
NOT
|
||||
)
|
||||
|
||||
override fun arithName() = "bitwise_set_ops"
|
||||
|
||||
override fun opTypes() = OPS
|
||||
|
||||
override fun getOperator(pattern: HexPattern): Operator = when (pattern) {
|
||||
AND -> make2 { x, y -> x and y }
|
||||
OR -> make2 { x, y -> x or y }
|
||||
XOR -> make2 { x, y -> x xor y }
|
||||
NOT -> make1 { x -> x.inv() }
|
||||
else -> throw InvalidOperatorException("$pattern is not a valid operator in Arithmetic $this.")
|
||||
}
|
||||
|
||||
private fun make1(op: LongUnaryOperator): OperatorUnary = OperatorUnary(DoubleArithmetic.ACCEPTS)
|
||||
{ i: Iota -> DoubleIota(op.applyAsLong(downcast(i, DOUBLE).double.roundToLong()).toDouble()) }
|
||||
|
||||
private fun make2(op: LongBinaryOperator): OperatorBinary = OperatorBinary(DoubleArithmetic.ACCEPTS)
|
||||
{ i: Iota, j: Iota -> DoubleIota(
|
||||
op.applyAsLong(
|
||||
downcast(i, DOUBLE).double.roundToLong(),
|
||||
downcast(j, DOUBLE).double.roundToLong()
|
||||
).toDouble()) }
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package at.petrak.hexcasting.common.casting.arithmetic
|
||||
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.Arithmetic
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.Arithmetic.*
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.engine.InvalidOperatorException
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.operator.Operator
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.operator.OperatorBinary
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.operator.OperatorUnary
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.predicates.IotaMultiPredicate
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.predicates.IotaPredicate
|
||||
import at.petrak.hexcasting.api.casting.iota.BooleanIota
|
||||
import at.petrak.hexcasting.api.casting.iota.DoubleIota
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.math.HexPattern
|
||||
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes.*
|
||||
import it.unimi.dsi.fastutil.booleans.BooleanBinaryOperator
|
||||
import it.unimi.dsi.fastutil.booleans.BooleanUnaryOperator
|
||||
import java.util.function.BiFunction
|
||||
|
||||
object BoolArithmetic : Arithmetic {
|
||||
private val OPS = listOf(
|
||||
AND,
|
||||
OR,
|
||||
XOR,
|
||||
GREATER,
|
||||
LESS,
|
||||
GREATER_EQ,
|
||||
LESS_EQ,
|
||||
NOT,
|
||||
ABS
|
||||
)
|
||||
|
||||
override fun arithName(): String = "bool_math"
|
||||
|
||||
override fun opTypes() = OPS
|
||||
|
||||
override fun getOperator(pattern: HexPattern): Operator = when (pattern) {
|
||||
AND -> make2 { a, b -> a and b }
|
||||
OR -> make2 { a, b -> a or b }
|
||||
XOR -> make2 { a, b -> a xor b }
|
||||
GREATER -> makeComp { x, y -> x > y }
|
||||
LESS -> makeComp { x, y -> x < y }
|
||||
GREATER_EQ -> makeComp { x, y -> DoubleIota.tolerates(x, y) || x >= y }
|
||||
LESS_EQ -> makeComp { x, y -> DoubleIota.tolerates(x, y) || x <= y }
|
||||
NOT -> make1 { a -> !a }
|
||||
ABS -> OperatorUnary(ALL_BOOLS) { i: Iota -> DoubleIota( if (Operator.downcast(i, BOOLEAN).bool) 1.0 else 0.0 ) }
|
||||
else -> throw InvalidOperatorException("$pattern is not a valid operator in Arithmetic $this.")
|
||||
}
|
||||
val ALL_BOOLS: IotaMultiPredicate = IotaMultiPredicate.all(IotaPredicate.ofType(BOOLEAN))
|
||||
|
||||
private fun make1(op: BooleanUnaryOperator): OperatorUnary {
|
||||
return OperatorUnary(ALL_BOOLS) { i: Iota -> BooleanIota(op.apply(Operator.downcast(i, BOOLEAN).bool)) }
|
||||
}
|
||||
private fun make2(op: BooleanBinaryOperator): OperatorBinary {
|
||||
return OperatorBinary(ALL_BOOLS) { i: Iota, j: Iota -> BooleanIota(op.apply(Operator.downcast(i, BOOLEAN).bool, Operator.downcast(j, BOOLEAN).bool)) }
|
||||
}
|
||||
private fun makeComp(op: BiFunction<Double, Double, Boolean>): OperatorBinary {
|
||||
return OperatorBinary(DoubleArithmetic.ACCEPTS)
|
||||
{ i: Iota, j: Iota -> BooleanIota(op.apply(Operator.downcast(i, DOUBLE).double, Operator.downcast(j, DOUBLE).double)) }
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package at.petrak.hexcasting.common.casting.arithmetic
|
|||
import at.petrak.hexcasting.api.casting.SpellList
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.Arithmetic
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.Arithmetic.*
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.engine.InvalidOperatorException
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.operator.Operator
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.operator.Operator.downcast
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.operator.OperatorBinary
|
||||
|
@ -16,6 +17,7 @@ import at.petrak.hexcasting.api.casting.iota.ListIota
|
|||
import at.petrak.hexcasting.api.casting.math.HexPattern
|
||||
import at.petrak.hexcasting.common.casting.arithmetic.operator.list.*
|
||||
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes.LIST
|
||||
import java.util.function.BinaryOperator
|
||||
|
||||
object ListArithmetic : Arithmetic {
|
||||
private val OPS = listOf(
|
||||
|
@ -37,13 +39,13 @@ object ListArithmetic : Arithmetic {
|
|||
|
||||
override fun opTypes(): Iterable<HexPattern> = OPS
|
||||
|
||||
override fun getOperator(pattern: HexPattern): Operator? {
|
||||
override fun getOperator(pattern: HexPattern): Operator {
|
||||
return when (pattern) {
|
||||
INDEX -> OperatorIndex
|
||||
SLICE -> OperatorSlice
|
||||
APPEND -> OperatorAppend
|
||||
UNAPPEND -> OperatorUnappend
|
||||
ADD -> OperatorConcat
|
||||
ADD -> make2 { list0, list1 -> list0 + list1 }
|
||||
ABS -> OperatorUnary(all(IotaPredicate.ofType(LIST))) { iota: Iota -> DoubleIota(downcast(iota, LIST).list.size().toDouble()) }
|
||||
REV -> OperatorUnary(all(IotaPredicate.ofType(LIST))) { iota: Iota -> ListIota(downcast(iota, LIST).list.toList().asReversed()) }
|
||||
INDEX_OF -> OperatorIndexOf
|
||||
|
@ -51,7 +53,12 @@ object ListArithmetic : Arithmetic {
|
|||
REPLACE -> OperatorReplace
|
||||
CONS -> OperatorBinary(pair(IotaPredicate.ofType(LIST), IotaPredicate.TRUE)) { list, iota -> ListIota(SpellList.LPair(iota, downcast(list, LIST).list)) }
|
||||
UNCONS -> OperatorUnCons
|
||||
else -> null
|
||||
else -> throw InvalidOperatorException("$pattern is not a valid operator in Arithmetic $this.")
|
||||
}
|
||||
}
|
||||
|
||||
private fun make2(op: BinaryOperator<List<Iota>>): OperatorBinary = OperatorBinary(all(IotaPredicate.ofType(LIST)))
|
||||
{ i: Iota, j: Iota -> ListIota(
|
||||
op.apply(downcast(i, LIST).list.toList(), downcast(j, LIST).list.toList())
|
||||
) }
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package at.petrak.hexcasting.common.casting.arithmetic
|
||||
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.Arithmetic
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.Arithmetic.*
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.engine.InvalidOperatorException
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.operator.Operator
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.operator.Operator.*
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.operator.OperatorBinary
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.predicates.IotaMultiPredicate.*
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.predicates.IotaPredicate
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.iota.ListIota
|
||||
import at.petrak.hexcasting.api.casting.math.HexPattern
|
||||
import at.petrak.hexcasting.common.casting.arithmetic.operator.list.OperatorUnique
|
||||
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes.LIST
|
||||
import java.util.function.BinaryOperator
|
||||
|
||||
object ListSetArithmetic : Arithmetic {
|
||||
private val OPS = listOf(
|
||||
AND,
|
||||
OR,
|
||||
XOR,
|
||||
UNIQUE
|
||||
)
|
||||
|
||||
override fun arithName() = "list_set_ops"
|
||||
|
||||
override fun opTypes() = OPS
|
||||
|
||||
override fun getOperator(pattern: HexPattern): Operator = when (pattern) {
|
||||
AND -> make2 { list0, list1 -> list0.filter { x -> list1.any { Iota.tolerates(x, it) } } }
|
||||
OR -> make2 { list0, list1 -> list0 + list1.filter { x -> list0.none { Iota.tolerates(x, it) } } }
|
||||
XOR -> make2 { list0, list1 -> list0.filter { x0 -> list1.none {Iota.tolerates(x0, it) } } + list1.filter { x1 -> list0.none { Iota.tolerates(x1, it) } } }
|
||||
UNIQUE -> OperatorUnique
|
||||
else -> throw InvalidOperatorException("$pattern is not a valid operator in Arithmetic $this.")
|
||||
}
|
||||
|
||||
|
||||
private fun make2(op: BinaryOperator<List<Iota>>): OperatorBinary = OperatorBinary(all(IotaPredicate.ofType(LIST)))
|
||||
{ i: Iota, j: Iota -> ListIota(
|
||||
op.apply(downcast(i, LIST).list.toList(), downcast(j, LIST).list.toList())
|
||||
) }
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package at.petrak.hexcasting.common.casting.arithmetic;
|
||||
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.Arithmetic;
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.engine.InvalidOperatorException;
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.predicates.IotaMultiPredicate;
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.predicates.IotaPredicate;
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.operator.*;
|
||||
|
@ -66,7 +67,7 @@ public enum Vec3Arithmetic implements Arithmetic {
|
|||
} else if (pattern.equals(MOD)) {
|
||||
return make2Fallback(pattern);
|
||||
}
|
||||
return null;
|
||||
throw new InvalidOperatorException(pattern + " is not a valid operator in Arithmetic " + this + ".");
|
||||
}
|
||||
public static OperatorUnary make1Double(Function<Vec3, Double> op) {
|
||||
return new OperatorUnary(ACCEPTS, i -> new DoubleIota(op.apply(downcast(i, VEC3).getVec3())));
|
||||
|
|
|
@ -6,14 +6,21 @@ import at.petrak.hexcasting.api.casting.arithmetic.predicates.IotaPredicate
|
|||
import at.petrak.hexcasting.api.casting.asActionResult
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.common.casting.arithmetic.operator.nextList
|
||||
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes.*
|
||||
import at.petrak.hexcasting.common.casting.operators.math.bit.OpToSet
|
||||
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes.LIST
|
||||
|
||||
object OperatorConcat : Operator(2, IotaMultiPredicate.all(IotaPredicate.ofType(LIST))) {
|
||||
object OperatorUnique : Operator(1, IotaMultiPredicate.all(IotaPredicate.ofType(LIST))) {
|
||||
override fun apply(iotas: Iterable<Iota>): Iterable<Iota> {
|
||||
val it = iotas.iterator().withIndex()
|
||||
val lhs = it.nextList(arity).toMutableList()
|
||||
val rhs = it.nextList(arity)
|
||||
lhs.addAll(rhs)
|
||||
return lhs.asActionResult
|
||||
val list = it.nextList(OpToSet.argc)
|
||||
val out = mutableListOf<Iota>()
|
||||
|
||||
for (subiota in list) {
|
||||
if (out.none { Iota.tolerates(it, subiota) }) {
|
||||
out.add(subiota)
|
||||
}
|
||||
}
|
||||
|
||||
return out.asActionResult
|
||||
}
|
||||
}
|
|
@ -27,7 +27,6 @@ import at.petrak.hexcasting.common.casting.operators.lists.*;
|
|||
import at.petrak.hexcasting.common.casting.operators.local.OpPeekLocal;
|
||||
import at.petrak.hexcasting.common.casting.operators.local.OpPushLocal;
|
||||
import at.petrak.hexcasting.common.casting.operators.math.*;
|
||||
import at.petrak.hexcasting.common.casting.operators.math.bit.*;
|
||||
import at.petrak.hexcasting.common.casting.operators.math.logic.*;
|
||||
import at.petrak.hexcasting.common.casting.operators.math.trig.*;
|
||||
import at.petrak.hexcasting.common.casting.operators.raycast.OpBlockAxisRaycast;
|
||||
|
@ -144,13 +143,13 @@ public class HexActions {
|
|||
new OperationAction(HexPattern.fromAngles("waaw", HexDir.NORTH_EAST)));
|
||||
public static final ActionRegistryEntry SUB = make("sub",
|
||||
new OperationAction(HexPattern.fromAngles("wddw", HexDir.NORTH_WEST)));
|
||||
public static final ActionRegistryEntry MUL_DOT = make("mul_dot",
|
||||
public static final ActionRegistryEntry MUL_DOT = make("mul",
|
||||
new OperationAction(HexPattern.fromAngles("waqaw", HexDir.SOUTH_EAST)));
|
||||
public static final ActionRegistryEntry DIV_CROSS = make("div_cross",
|
||||
public static final ActionRegistryEntry DIV_CROSS = make("div",
|
||||
new OperationAction(HexPattern.fromAngles("wdedw", HexDir.NORTH_EAST)));
|
||||
public static final ActionRegistryEntry ABS_LEN = make("abs_len",
|
||||
public static final ActionRegistryEntry ABS = make("abs",
|
||||
new OperationAction(HexPattern.fromAngles("wqaqw", HexDir.NORTH_EAST)));
|
||||
public static final ActionRegistryEntry POW_PROJ = make("pow_proj",
|
||||
public static final ActionRegistryEntry POW_PROJ = make("pow",
|
||||
new OperationAction(HexPattern.fromAngles("wedew", HexDir.NORTH_WEST)));
|
||||
public static final ActionRegistryEntry FLOOR = make("floor",
|
||||
new OperationAction(HexPattern.fromAngles("ewq", HexDir.EAST)));
|
||||
|
@ -167,23 +166,23 @@ public class HexActions {
|
|||
// == Logic ==
|
||||
|
||||
public static final ActionRegistryEntry AND = make("and",
|
||||
new ActionRegistryEntry(HexPattern.fromAngles("wdw", HexDir.NORTH_EAST), OpBoolAnd.INSTANCE));
|
||||
new OperationAction(HexPattern.fromAngles("wdw", HexDir.NORTH_EAST)));
|
||||
public static final ActionRegistryEntry OR = make("or",
|
||||
new ActionRegistryEntry(HexPattern.fromAngles("waw", HexDir.SOUTH_EAST), OpBoolOr.INSTANCE));
|
||||
new OperationAction(HexPattern.fromAngles("waw", HexDir.SOUTH_EAST)));
|
||||
public static final ActionRegistryEntry XOR = make("xor",
|
||||
new ActionRegistryEntry(HexPattern.fromAngles("dwa", HexDir.NORTH_WEST), OpBoolXor.INSTANCE));
|
||||
public static final ActionRegistryEntry GREATER = make("greater", new ActionRegistryEntry(
|
||||
HexPattern.fromAngles("e", HexDir.SOUTH_EAST), new OpCompare(false, (a, b) -> a > b)
|
||||
));
|
||||
public static final ActionRegistryEntry LESS = make("less", new ActionRegistryEntry(
|
||||
HexPattern.fromAngles("q", HexDir.SOUTH_WEST), new OpCompare(false, (a, b) -> a < b)
|
||||
));
|
||||
public static final ActionRegistryEntry GREATER_EQ = make("greater_eq", new ActionRegistryEntry(
|
||||
HexPattern.fromAngles("ee", HexDir.SOUTH_EAST), new OpCompare(true, (a, b) -> a >= b)
|
||||
));
|
||||
public static final ActionRegistryEntry LESS_EQ = make("less_eq", new ActionRegistryEntry(
|
||||
HexPattern.fromAngles("qq", HexDir.SOUTH_WEST), new OpCompare(true, (a, b) -> a <= b)
|
||||
));
|
||||
new OperationAction(HexPattern.fromAngles("dwa", HexDir.NORTH_WEST)));
|
||||
public static final ActionRegistryEntry GREATER = make("greater", new OperationAction(
|
||||
HexPattern.fromAngles("e", HexDir.SOUTH_EAST))
|
||||
);
|
||||
public static final ActionRegistryEntry LESS = make("less", new OperationAction(
|
||||
HexPattern.fromAngles("q", HexDir.SOUTH_WEST))
|
||||
);
|
||||
public static final ActionRegistryEntry GREATER_EQ = make("greater_eq", new OperationAction(
|
||||
HexPattern.fromAngles("ee", HexDir.SOUTH_EAST))
|
||||
);
|
||||
public static final ActionRegistryEntry LESS_EQ = make("less_eq", new OperationAction(
|
||||
HexPattern.fromAngles("qq", HexDir.SOUTH_WEST))
|
||||
);
|
||||
public static final ActionRegistryEntry EQUALS = make("equals",
|
||||
new ActionRegistryEntry(HexPattern.fromAngles("ad", HexDir.EAST), new OpEquality(false)));
|
||||
public static final ActionRegistryEntry NOT_EQUALS = make("not_equals",
|
||||
|
@ -192,8 +191,6 @@ public class HexActions {
|
|||
new ActionRegistryEntry(HexPattern.fromAngles("dw", HexDir.NORTH_WEST), OpBoolNot.INSTANCE));
|
||||
public static final ActionRegistryEntry BOOL_COERCE = make("bool_coerce",
|
||||
new ActionRegistryEntry(HexPattern.fromAngles("aw", HexDir.NORTH_EAST), OpCoerceToBool.INSTANCE));
|
||||
public static final ActionRegistryEntry BOOL_TO_NUMBER = make("bool_to_number",
|
||||
new ActionRegistryEntry(HexPattern.fromAngles("awd", HexDir.SOUTH_EAST), OpBoolToNumber.INSTANCE));
|
||||
public static final ActionRegistryEntry IF = make("if",
|
||||
new ActionRegistryEntry(HexPattern.fromAngles("awdd", HexDir.SOUTH_EAST), OpBoolIf.INSTANCE));
|
||||
|
||||
|
@ -219,20 +216,12 @@ public class HexActions {
|
|||
public static final ActionRegistryEntry LOGARITHM = make("logarithm",
|
||||
new ActionRegistryEntry(HexPattern.fromAngles("eqaqe", HexDir.NORTH_WEST), OpLog.INSTANCE));
|
||||
public static final ActionRegistryEntry MODULO = make("modulo",
|
||||
new ActionRegistryEntry(HexPattern.fromAngles("addwaad", HexDir.NORTH_EAST), OpModulo.INSTANCE));
|
||||
new OperationAction(HexPattern.fromAngles("addwaad", HexDir.NORTH_EAST)));
|
||||
|
||||
// == Sets ==
|
||||
|
||||
public static final ActionRegistryEntry BIT$AND = make("bit/and",
|
||||
new ActionRegistryEntry(HexPattern.fromAngles("wdweaqa", HexDir.NORTH_EAST), OpAnd.INSTANCE));
|
||||
public static final ActionRegistryEntry BIT$OR = make("bit/or",
|
||||
new ActionRegistryEntry(HexPattern.fromAngles("waweaqa", HexDir.SOUTH_EAST), OpOr.INSTANCE));
|
||||
public static final ActionRegistryEntry BIT$XOR = make("bit/xor",
|
||||
new ActionRegistryEntry(HexPattern.fromAngles("dwaeaqa", HexDir.NORTH_WEST), OpXor.INSTANCE));
|
||||
public static final ActionRegistryEntry BIT$NOT = make("bit/not",
|
||||
new ActionRegistryEntry(HexPattern.fromAngles("dweaqa", HexDir.NORTH_WEST), OpNot.INSTANCE));
|
||||
public static final ActionRegistryEntry BIT$TO_SET = make("bit/to_set",
|
||||
new ActionRegistryEntry(HexPattern.fromAngles("aweaqa", HexDir.NORTH_EAST), OpToSet.INSTANCE));
|
||||
public static final ActionRegistryEntry UNIQUE = make("unique",
|
||||
new OperationAction(HexPattern.fromAngles("aweaqa", HexDir.NORTH_EAST)));
|
||||
|
||||
// == Spells ==
|
||||
|
||||
|
|
|
@ -2,9 +2,7 @@ package at.petrak.hexcasting.common.lib.hex;
|
|||
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.Arithmetic;
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.engine.ArithmeticEngine;
|
||||
import at.petrak.hexcasting.common.casting.arithmetic.DoubleArithmetic;
|
||||
import at.petrak.hexcasting.common.casting.arithmetic.ListArithmetic;
|
||||
import at.petrak.hexcasting.common.casting.arithmetic.Vec3Arithmetic;
|
||||
import at.petrak.hexcasting.common.casting.arithmetic.*;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -40,6 +38,9 @@ public class HexArithmetics {
|
|||
public static DoubleArithmetic DOUBLE = make("double", DoubleArithmetic.INSTANCE);
|
||||
public static Vec3Arithmetic VEC3 = make("vec3", Vec3Arithmetic.INSTANCE);
|
||||
public static ListArithmetic LIST = make("list", ListArithmetic.INSTANCE);
|
||||
public static BoolArithmetic BOOL = make("bool", BoolArithmetic.INSTANCE);
|
||||
public static ListSetArithmetic LIST_SET = make("list_set", ListSetArithmetic.INSTANCE);
|
||||
public static BitwiseSetArithmetic BITWISE_SET = make("bitwise_set", BitwiseSetArithmetic.INSTANCE);
|
||||
|
||||
private static <T extends Arithmetic> T make(String name, T arithmetic) {
|
||||
var old = ARITHMETICS.put(modLoc(name), arithmetic);
|
||||
|
|
|
@ -378,8 +378,9 @@
|
|||
"circle/impetus_dir": "Lodestone Reflection",
|
||||
"circle/bounds/min": "Lesser Fold Reflection",
|
||||
"circle/bounds/max": "Greater Fold Reflection",
|
||||
|
||||
|
||||
"append": "Integration Distillation",
|
||||
"unappend": "Derivation Distillation",
|
||||
"concat": "Combination Distillation",
|
||||
"index": "Selection Distillation",
|
||||
"list_size": "Abacus Purification",
|
||||
|
@ -426,11 +427,7 @@
|
|||
"fisherman/copy": "Fisherman's Gambit II",
|
||||
"swizzle": "Swindler's Gambit",
|
||||
|
||||
"bit/and": "Intersection Distillation",
|
||||
"bit/or": "Unifying Distillation",
|
||||
"bit/xor": "Exclusionary Distillation",
|
||||
"bit/not": "Inversion Purification",
|
||||
"bit/to_set": "Uniqueness Purification",
|
||||
"unique": "Uniqueness Purification",
|
||||
"and": "Conjunction Distillation",
|
||||
"or": "Disjunction Distillation",
|
||||
"xor": "Exclusion Distillation",
|
||||
|
@ -443,15 +440,14 @@
|
|||
"not_equals": "Inequality Distillation",
|
||||
"not": "Negation Purification",
|
||||
"bool_coerce": "Augur's Purification",
|
||||
"bool_to_number": "Numerologist's Purification",
|
||||
"if": "Augur's Exaltation",
|
||||
|
||||
"add": "Additive Distillation",
|
||||
"sub": "Subtractive Distillation",
|
||||
"mul_dot": "Multiplicative Dstl.",
|
||||
"div_cross": "Division Dstl.",
|
||||
"abs_len": "Length Purification",
|
||||
"pow_proj": "Power Distillation",
|
||||
"mul": "Multiplicative Dstl.",
|
||||
"div": "Division Dstl.",
|
||||
"abs": "Length Purification",
|
||||
"pow": "Power Distillation",
|
||||
"floor": "Floor Purification",
|
||||
"ceil": "Ceiling Purification",
|
||||
"modulo": "Modulus Distillation",
|
||||
|
@ -561,8 +557,8 @@
|
|||
"zone_entity/not_item": "Zone Dstl.: Non-Item",
|
||||
"zone_entity/not_player": "Zone Dstl.: Non-Player",
|
||||
"zone_entity/not_living": "Zone Dstl.: Non-Living",
|
||||
"mul_dot": "Multiplicative Dstl.",
|
||||
"div_cross": "Division Dstl.",
|
||||
"mul": "Multiplicative Dstl.",
|
||||
"div": "Division Dstl.",
|
||||
"arcsin": "Inverse Sine Prfn.",
|
||||
"arccos": "Inverse Cosine Prfn.",
|
||||
"arctan": "Inverse Tangent Prfn.",
|
||||
|
@ -1141,14 +1137,14 @@
|
|||
"math.add.2": "As such:$(li)With two numbers at the top of the stack, combines them into their sum.$(li)With a number and a vector, removes the number from the stack and adds it to each element of the vector.$(li)With two vectors, combines them by summing corresponding components into a new vector (i.e. [1, 2, 3] + [0, 4, -1] = [1, 6, 2]).",
|
||||
"math.sub.1": "Perform subtraction.",
|
||||
"math.sub.2": "As such:$(li)With two numbers at the top of the stack, combines them into their difference.$(li)With a number and a vector, removes the number from the stack and subtracts it from each element of the vector.$(li)With two vectors, combines them by subtracting each component.$(br2)In all cases, the top of the stack or its components are subtracted $(italic)from/$ the second-from-the-top.",
|
||||
"math.mul_dot.1": "Perform multiplication or the dot product.",
|
||||
"math.mul_dot.2": "As such:$(li)With two numbers, combines them into their product.$(li)With a number and a vector, removes the number from the stack and multiplies each component of the vector by that number.$(li)With two vectors, combines them into their $(l:https://www.mathsisfun.com/algebra/vectors-dot-product.html)dot product/$.",
|
||||
"math.div_cross.1": "Perform division or the cross product.",
|
||||
"math.div_cross.2": "As such:$(li)With two numbers, combines them into their quotient.$(li)With a number and a vector, removes the number and divides it by each element of the vector.$(li)With two vectors, combines them into their $(l:https://www.mathsisfun.com/algebra/vectors-cross-product.html)cross product/$.$(br2)In the first and second cases, the top of the stack or its components comprise the dividend, and the second-from-the-top or its components are the divisor.$(p)WARNING: Never divide by zero!",
|
||||
"math.abs_len.1": "Compute the absolute value or length.",
|
||||
"math.abs_len.2": "Replaces a number with its absolute value, or a vector with its length.",
|
||||
"math.pow_proj.1": "Perform exponentiation or vector projection.",
|
||||
"math.pow_proj.2": "With two numbers, combines them by raising the first to the power of the second.$(li)With a number and a vector, removes the number and raises each component of the vector to the number's power.$(li)With two vectors, combines them into the $(l:https://en.wikipedia.org/wiki/Vector_projection)vector projection/$ of the top of the stack onto the second-from-the-top.$(br2)In the first and second cases, the first argument or its components are the base, and the second argument or its components are the exponent.",
|
||||
"math.mul.1": "Perform multiplication or the dot product.",
|
||||
"math.mul.2": "As such:$(li)With two numbers, combines them into their product.$(li)With a number and a vector, removes the number from the stack and multiplies each component of the vector by that number.$(li)With two vectors, combines them into their $(l:https://www.mathsisfun.com/algebra/vectors-dot-product.html)dot product/$.",
|
||||
"math.div.1": "Perform division or the cross product.",
|
||||
"math.div.2": "As such:$(li)With two numbers, combines them into their quotient.$(li)With a number and a vector, removes the number and divides it by each element of the vector.$(li)With two vectors, combines them into their $(l:https://www.mathsisfun.com/algebra/vectors-cross-product.html)cross product/$.$(br2)In the first and second cases, the top of the stack or its components comprise the dividend, and the second-from-the-top or its components are the divisor.$(p)WARNING: Never divide by zero!",
|
||||
"math.abs.1": "Compute the absolute value or length.",
|
||||
"math.abs.2": "Replaces a number with its absolute value, or a vector with its length.",
|
||||
"math.pow.1": "Perform exponentiation or vector projection.",
|
||||
"math.pow.2": "With two numbers, combines them by raising the first to the power of the second.$(li)With a number and a vector, removes the number and raises each component of the vector to the number's power.$(li)With two vectors, combines them into the $(l:https://en.wikipedia.org/wiki/Vector_projection)vector projection/$ of the top of the stack onto the second-from-the-top.$(br2)In the first and second cases, the first argument or its components are the base, and the second argument or its components are the exponent.",
|
||||
"math.floor": "\"Floors\" a number, cutting off the fractional component and leaving an integer value.",
|
||||
"math.ceil": "\"Ceilings\" a number, raising it to the next integer value if it has a fractional component.",
|
||||
"math.construct_vec": "Combine three numbers at the top of the stack into a vector's X, Y, and Z components (top to bottom).",
|
||||
|
@ -1248,6 +1244,7 @@
|
|||
"lists.index": "Remove the number at the top of the stack, then replace the list at the top with the nth element of that list (where n is the number you removed). Replaces the list with $(l:casting/influences)$(thing)Null/$ if the number is out of bounds.",
|
||||
"lists.slice": "Remove the two numbers at the top of the stack, then take a sublist of the list at the top of the stack between those indices, lower bound inclusive, upper bound exclusive. For example, the 0, 2 sublist of [0, 1, 2, 3, 4] would be [0, 1].",
|
||||
"lists.append": "Remove the top of the stack, then add it to the end of the list at the top of the stack.",
|
||||
"lists.unappend": "Remove the iota on the end of the list at the top of the stack, and add it to the top of the stack.",
|
||||
"lists.concat": "Remove the list at the top of the stack, then add all its elements to the end of the list at the top of the stack.",
|
||||
"lists.empty_list": "Push an empty list to the top of the stack.",
|
||||
"lists.singleton": "Remove the top of the stack, then push a list containing only that element.",
|
||||
|
|
|
@ -64,8 +64,8 @@
|
|||
},
|
||||
{
|
||||
"type": "hexcasting:pattern",
|
||||
"op_id": "hexcasting:abs_len",
|
||||
"anchor": "hexcasting:abs_len",
|
||||
"op_id": "hexcasting:abs",
|
||||
"anchor": "hexcasting:abs",
|
||||
"input": "list",
|
||||
"output": "num",
|
||||
"text": "hexcasting.page.lists.list_size"
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
},
|
||||
{
|
||||
"type": "hexcasting:pattern",
|
||||
"op_id": "hexcasting:bool_to_number",
|
||||
"anchor": "hexcasting:bool_to_number",
|
||||
"op_id": "hexcasting:abs",
|
||||
"anchor": "hexcasting:abs",
|
||||
"input": "bool",
|
||||
"output": "number",
|
||||
"text": "hexcasting.page.logic.bool_to_number"
|
||||
|
@ -26,8 +26,8 @@
|
|||
"type": "hexcasting:pattern",
|
||||
"op_id": "hexcasting:not",
|
||||
"anchor": "hexcasting:not",
|
||||
"input": "any",
|
||||
"output": "number",
|
||||
"input": "bool",
|
||||
"output": "bool",
|
||||
"text": "hexcasting.page.logic.not"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -39,51 +39,51 @@
|
|||
},
|
||||
{
|
||||
"type": "hexcasting:pattern",
|
||||
"op_id": "hexcasting:mul_dot",
|
||||
"anchor": "hexcasting:mul_dot",
|
||||
"op_id": "hexcasting:mul",
|
||||
"anchor": "hexcasting:mul",
|
||||
"input": "num/vec, num/vec",
|
||||
"output": "num/vec",
|
||||
"text": "hexcasting.page.math.mul_dot.1"
|
||||
"text": "hexcasting.page.math.mul.1"
|
||||
},
|
||||
{
|
||||
"type": "patchouli:text",
|
||||
"text": "hexcasting.page.math.mul_dot.2"
|
||||
"text": "hexcasting.page.math.mul.2"
|
||||
},
|
||||
{
|
||||
"type": "hexcasting:pattern",
|
||||
"op_id": "hexcasting:div_cross",
|
||||
"anchor": "hexcasting:div_cross",
|
||||
"op_id": "hexcasting:div",
|
||||
"anchor": "hexcasting:div",
|
||||
"input": "num/vec, num/vec",
|
||||
"output": "num/vec",
|
||||
"text": "hexcasting.page.math.div_cross.1"
|
||||
"text": "hexcasting.page.math.div.1"
|
||||
},
|
||||
{
|
||||
"type": "patchouli:text",
|
||||
"text": "hexcasting.page.math.div_cross.2"
|
||||
"text": "hexcasting.page.math.div.2"
|
||||
},
|
||||
{
|
||||
"type": "hexcasting:pattern",
|
||||
"op_id": "hexcasting:abs_len",
|
||||
"anchor": "hexcasting:abs_len",
|
||||
"op_id": "hexcasting:abs",
|
||||
"anchor": "hexcasting:abs",
|
||||
"input": "num/vec",
|
||||
"output": "number",
|
||||
"text": "hexcasting.page.math.abs_len.1"
|
||||
"text": "hexcasting.page.math.abs.1"
|
||||
},
|
||||
{
|
||||
"type": "patchouli:text",
|
||||
"text": "hexcasting.page.math.abs_len.2"
|
||||
"text": "hexcasting.page.math.abs.2"
|
||||
},
|
||||
{
|
||||
"type": "hexcasting:pattern",
|
||||
"op_id": "hexcasting:pow_proj",
|
||||
"anchor": "hexcasting:pow_proj",
|
||||
"op_id": "hexcasting:pow",
|
||||
"anchor": "hexcasting:pow",
|
||||
"input": "num/vec, num/vec",
|
||||
"output": "num/vec",
|
||||
"text": "hexcasting.page.math.pow_proj.1"
|
||||
"text": "hexcasting.page.math.pow.1"
|
||||
},
|
||||
{
|
||||
"type": "patchouli:text",
|
||||
"text": "hexcasting.page.math.pow_proj.2"
|
||||
"text": "hexcasting.page.math.pow.2"
|
||||
},
|
||||
{
|
||||
"type": "hexcasting:pattern",
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
},
|
||||
{
|
||||
"type": "hexcasting:pattern",
|
||||
"op_id": "hexcasting:bit/or",
|
||||
"anchor": "hexcasting:bit/or",
|
||||
"op_id": "hexcasting:or",
|
||||
"anchor": "hexcasting:or",
|
||||
"input": "num, num/list, list",
|
||||
"output": "num/list",
|
||||
"text": "hexcasting.page.sets.or.1"
|
||||
|
@ -27,8 +27,8 @@
|
|||
},
|
||||
{
|
||||
"type": "hexcasting:pattern",
|
||||
"op_id": "hexcasting:bit/and",
|
||||
"anchor": "hexcasting:bit/and",
|
||||
"op_id": "hexcasting:and",
|
||||
"anchor": "hexcasting:and",
|
||||
"input": "num, num/list, list",
|
||||
"output": "num/list",
|
||||
"text": "hexcasting.page.sets.and.1"
|
||||
|
@ -39,8 +39,8 @@
|
|||
},
|
||||
{
|
||||
"type": "hexcasting:pattern",
|
||||
"op_id": "hexcasting:bit/xor",
|
||||
"anchor": "hexcasting:bit/xor",
|
||||
"op_id": "hexcasting:xor",
|
||||
"anchor": "hexcasting:xor",
|
||||
"input": "num, num/list, list",
|
||||
"output": "num/list",
|
||||
"text": "hexcasting.page.sets.xor.1"
|
||||
|
@ -51,16 +51,16 @@
|
|||
},
|
||||
{
|
||||
"type": "hexcasting:pattern",
|
||||
"op_id": "hexcasting:bit/not",
|
||||
"anchor": "hexcasting:bit/not",
|
||||
"op_id": "hexcasting:not",
|
||||
"anchor": "hexcasting:not",
|
||||
"input": "num",
|
||||
"output": "num",
|
||||
"text": "hexcasting.page.sets.not"
|
||||
},
|
||||
{
|
||||
"type": "hexcasting:pattern",
|
||||
"op_id": "hexcasting:bit/to_set",
|
||||
"anchor": "hexcasting:bit/to_set",
|
||||
"op_id": "hexcasting:unique",
|
||||
"anchor": "hexcasting:unique",
|
||||
"input": "list",
|
||||
"output": "list",
|
||||
"text": "hexcasting.page.sets.to_set"
|
||||
|
|
Loading…
Reference in a new issue