mirror of
https://github.com/mx42/codingame_code_of_kutulu.git
synced 2026-01-13 21:29:50 +01:00
Updates
This commit is contained in:
@@ -9,3 +9,6 @@ Codingame Challenge using the excellent Codingame-Scala-Kit : https://github.com
|
||||
* Symlinks `build.sbt`, `src/main/scala/com` and `project` should be referring the appropriate paths in `codingame-scala-kit-forked`
|
||||
* Running `./enhanceCoK` should continuously build a file `target/CoK.scala` that you can sync with Codingame using a web-browser plugin.
|
||||
|
||||
# TODO
|
||||
|
||||
* Monkey Patch / extend / update `com.truelaurel.math.geometry.Pos` with local changes (see backup)
|
||||
|
||||
1128
backup_CoK.scala
Normal file
1128
backup_CoK.scala
Normal file
File diff suppressed because it is too large
Load Diff
20
src/main/scala/cok/math/geometry/Pos.scala
Normal file
20
src/main/scala/cok/math/geometry/Pos.scala
Normal file
@@ -0,0 +1,20 @@
|
||||
package cok.math.geometry
|
||||
import com.truelaurel.math.geometry.{Direction, N, S, W, E}
|
||||
|
||||
// TODO Add those changes to truelaurel code.
|
||||
|
||||
case class Pos(x: Int, y:Int) {
|
||||
def neighborsIn(direction: Direction): Iterator[Pos] = direction match {
|
||||
case N ⇒ (y - 1).to(0).iterator.map(y2 ⇒ Pos(x, y2))
|
||||
case S ⇒ (y + 1).to(500).iterator.map(y2 ⇒ Pos(x, y2))
|
||||
case W ⇒ (x - 1).to(0).iterator.map(x2 ⇒ Pos(x2, y))
|
||||
case E ⇒ (x + 1).to(500).iterator.map(x2 ⇒ Pos(x2, y))
|
||||
}
|
||||
|
||||
def distanceManhattan(pos: Pos): Int =
|
||||
Math.abs(x - pos.x) + Math.abs(y - pos.y)
|
||||
}
|
||||
|
||||
object Direction {
|
||||
val cardinals = Seq(N, W, S, E)
|
||||
}
|
||||
Reference in New Issue
Block a user