main_testing4/knight2.scala
changeset 403 ffce7b61b446
parent 347 4de31fdc0d67
equal deleted inserted replaced
402:de59aa20a1dc 403:ffce7b61b446
     1 // Part 3 about finding a single tour using the Warnsdorf Rule
     1 // Part 2 about finding a single tour using the Warnsdorf Rule
     2 //=============================================================
     2 //=============================================================
     3 
     3 
     4 object CW9b {
     4 object M4b { // for preparing the jar
     5 
     5 
     6 type Pos = (Int, Int)
     6 type Pos = (Int, Int)
     7 type Path = List[Pos]
     7 type Path = List[Pos]
     8 
     8 
     9 
     9 
    65  time_needed(tfirst_closed_tour_heuristics(dim: Int, path: Path))
    65  time_needed(tfirst_closed_tour_heuristics(dim: Int, path: Path))
    66 
    66 
    67 def first_closed_tour_heuristic(dim: Int, path: Path) =
    67 def first_closed_tour_heuristic(dim: Int, path: Path) =
    68  time_needed(tfirst_closed_tour_heuristics(dim: Int, path: Path))
    68  time_needed(tfirst_closed_tour_heuristics(dim: Int, path: Path))
    69 
    69 
    70 
       
    71 // heuristic cannot be used to search for closed tours on 7 x 7 an beyond
    70 // heuristic cannot be used to search for closed tours on 7 x 7 an beyond
    72 //for (dim <- 1 to 6) {
    71 //for (dim <- 1 to 6) {
    73 //  val t = time_needed(0, first_closed_tour_heuristics(dim, List((dim / 2, dim / 2))))
    72 //  val t = time_needed(0, first_closed_tour_heuristics(dim, List((dim / 2, dim / 2))))
    74 //  println(s"${dim} x ${dim} closed: " + (if (t == None) "" else { print_board(dim, t.get) ; "" }))
    73 //  println(s"${dim} x ${dim} closed: " + (if (t == None) "" else { print_board(dim, t.get) ; "" }))
    75 //}
    74 //}