Skip to content

Commit

Permalink
Incomplete attempt to implement strobing rules
Browse files Browse the repository at this point in the history
  • Loading branch information
jedlimlx committed May 12, 2024
1 parent b0e2034 commit d68f37c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/commonMain/kotlin/search/cfind/CFind.kt
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ class CFind(
}
}

// Computing the background for strobing rules
val background = IntArray(this.period * maxOf(this.k, 1)) { -1 }.apply {
// Compute the offsets
var count = 0
var index = 0
while (count < period * k) {
val rem = count % period
for (i in 0 ..<k) this[rem] = rule.background[index]
count += backOff[count.mod(period)]
index++
}
}

// Compute various statistics about the neighbourhood
// TODO Get neighbourhood coordinate direction conventions right
val height: Int = neighbourhood.maxOf { it.maxOf { it.y } - it.minOf { it.y } } + 1
Expand Down Expand Up @@ -690,6 +703,7 @@ class CFind(
println((bold("Successor Table Size: ") + "${successorTable.size}"), verbosity = 1)
println((bold("Backoff Table: ") + "${backOff.toList()}"), verbosity = 1)
println((bold("Reverse Backoff Table: ") + "${fwdOff.toList()}"), verbosity = 1)
println((bold("Background: ") + "${background.toList()}"), verbosity = 1)
println((bold("Maximum Lookahead Depth: ") + "$maxLookaheadDepth"), verbosity = 1)
println((bold("Successor Lookahead: ") + "$successorLookaheadDepth / $successorLookahead"), verbosity = 1)
println((bold("Approximate Lookahead: ") + "$approximateLookahead"), verbosity = 1)
Expand Down
2 changes: 1 addition & 1 deletion src/jvmMain/kotlin/Main.jvm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ actual fun main() {

// B2-ei3cjkr4cektyz5-cnr6-ik78/S01e2-ae3cnqry4cqrtwyz5-ain6ekn7e
val search = CFind(
HROT("R2,C2,S3,B3,NN"), 4, 1, 6, ShipSymmetry.ODD,
HROT("R2,C2,S3,B0,NN"), 4, 1, 6, ShipSymmetry.ODD,
verbosity = 1, searchStrategy = SearchStrategy.PRIORITY_QUEUE, //lookaheadDepth = 0,
direction = Coordinate(1, 1)
)
Expand Down

0 comments on commit d68f37c

Please sign in to comment.