marking3/knight1_test5.scala
changeset 331 e3878cdd38bc
parent 244 a359976a6f3e
equal deleted inserted replaced
330:c3d3461a5e77 331:e3878cdd38bc
       
     1 import CW8a._
     1 
     2 
     2 //type Pos = (Int, Int)    // a position on a chessboard 
     3 //type Pos = (Int, Int)    // a position on a chessboard 
     3 //type Path = List[Pos]    // a path...a list of positions
     4 //type Path = List[Pos]    // a path...a list of positions
     4 
     5 
     5 def add_pair_urban(x: Pos)(y: Pos): Pos = 
     6 def add_pair_urban(x: Pos)(y: Pos): Pos = 
    21   case x::y::p => 
    22   case x::y::p => 
    22     if (legal_moves_urban(dim, p, y).contains(x)) correct_urban(dim)(y::p) else false
    23     if (legal_moves_urban(dim, p, y).contains(x)) correct_urban(dim)(y::p) else false
    23 }
    24 }
    24 
    25 
    25 
    26 
    26 val ts1_urban = first_tour(8, List((0, 0))).get
    27 val ts1_urban = first_tour(6, List((0, 0))).get
    27 assert(correct_urban(8)(ts1_urban) == true)
    28 assert(correct_urban(6)(ts1_urban) == true)
    28 
    29 
    29 val ts2_urban = first_tour(4, List((0, 0)))
    30 val ts2_urban = first_tour(4, List((0, 0)))
    30 assert(ts2_urban == None)  
    31 assert(ts2_urban == None)