parent
14e9b99189
commit
c07952bec1
@ -0,0 +1,29 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="it.unimi.dsi.dsiutils" type="repository">
|
||||||
|
<properties maven-id="it.unimi.dsi:dsiutils:2.7.3" />
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/it/unimi/dsi/dsiutils/2.7.3/dsiutils-2.7.3.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/2.0.3/slf4j-api-2.0.3.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/ch/qos/logback/logback-core/1.3.4/logback-core-1.3.4.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/ch/qos/logback/logback-classic/1.3.4/logback-classic-1.3.4.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/sun/mail/javax.mail/1.6.2/javax.mail-1.6.2.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/javax/activation/activation/1.1/activation-1.1.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/it/unimi/dsi/fastutil/8.5.12/fastutil-8.5.12.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/it/unimi/di/jsap/20210129/jsap-20210129.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-configuration2/2.8.0/commons-configuration2-2.8.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-lang3/3.12.0/commons-lang3-3.12.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-text/1.9/commons-text-1.9.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/commons-logging/commons-logging/1.2/commons-logging-1.2.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-math3/3.6.1/commons-math3-3.6.1.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/google/guava/guava/31.1-jre/guava-31.1-jre.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/google/errorprone/error_prone_annotations/2.11.0/error_prone_annotations-2.11.0.jar!/" />
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</component>
|
@ -1,40 +1,51 @@
|
|||||||
package technology.zim.data
|
package technology.zim.data
|
||||||
|
|
||||||
enum class Directions(val value: Pair<Int, Int>) {
|
enum class Directions(val dir: Int) {
|
||||||
NORTH(Pair(0, -1)) {
|
NONE(0),
|
||||||
override fun opposite(): Directions {
|
UP(1),
|
||||||
return SOUTH
|
DOWN(2),
|
||||||
|
LEFT(4),
|
||||||
|
RIGHT(8),
|
||||||
|
VISITED(16)
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun getModifier(dir: Directions): Long {
|
||||||
|
return when(dir) {
|
||||||
|
UP -> NORTH
|
||||||
|
DOWN -> SOUTH
|
||||||
|
LEFT -> WEST
|
||||||
|
RIGHT -> EAST
|
||||||
|
else -> 0L
|
||||||
}
|
}
|
||||||
},
|
|
||||||
SOUTH(Pair(0, 1)) {
|
|
||||||
override fun opposite(): Directions {
|
|
||||||
return NORTH
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
EAST(Pair(1, 0)) {
|
fun convertModifier(mod: Long): Directions {
|
||||||
override fun opposite(): Directions {
|
return when(mod) {
|
||||||
return WEST
|
NORTH -> UP
|
||||||
|
SOUTH -> DOWN
|
||||||
|
WEST -> LEFT
|
||||||
|
EAST -> RIGHT
|
||||||
|
else -> NONE
|
||||||
}
|
}
|
||||||
},
|
|
||||||
WEST(Pair(-1, 0)) {
|
|
||||||
override fun opposite(): Directions {
|
|
||||||
return EAST
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
//Return the opposite direction
|
const val SOUTH: Long = 0x1L
|
||||||
abstract fun opposite(): Directions
|
const val NORTH: Long = -0x1L
|
||||||
|
const val WEST: Long = -0x100000000L
|
||||||
fun x():Int {
|
const val EAST: Long = 0x100000000L
|
||||||
return value.first
|
val ALL = arrayOf(UP, DOWN, LEFT, RIGHT)
|
||||||
|
const val NONEMOD = 0L
|
||||||
}
|
}
|
||||||
|
|
||||||
fun y():Int {
|
fun inv(): Int {
|
||||||
return value.second
|
return dir.inv()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
fun opposite(dir: Long): Long {
|
||||||
val ALL = setOf(NORTH, EAST, WEST, SOUTH)
|
val x = (dir shr 32).toInt() * -1
|
||||||
|
val y = dir.toInt() * -1
|
||||||
|
return x.toLong() shl 32 + y
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in new issue