marking/knight1_test.scala
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Wed, 21 Dec 2016 03:06:18 +0000
changeset 94 ae4708c851ee
parent 85 fd3f8581ce85
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
85
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
import scala.concurrent._
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
import scala.concurrent.duration._
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
import ExecutionContext.Implicits.global
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
import scala.language.postfixOps 
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
lazy val f = Future {
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
  assert(legal_moves(8, Nil, (2,2)) == 
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
             List((3,4), (4,3), (4,1), (3,0), (1,0), (0,1), (0,3), (1,4)))
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
  assert(legal_moves(8, Nil, (7,7)) == List((6,5), (5,6)))
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
  assert(legal_moves(8, List((4,1), (1,0)), (2,2)) == 
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
             List((3,4), (4,3), (3,0), (0,1), (0,3), (1,4)))
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
  assert(legal_moves(8, List((6,6)), (7,7)) == List((6,5), (5,6)))
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
  assert(legal_moves(1, Nil, (0,0)) == List())
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
  assert(legal_moves(2, Nil, (0,0)) == List())
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
  assert(legal_moves(3, Nil, (0,0)) == List((1,2), (2,1)))
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
}
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
fd3f8581ce85 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
Await.result(f, 120 second)