assignment2021scala/main4/knight3.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Tue, 08 Nov 2022 18:35:41 +0000
changeset 434 8c5804b2f9d2
parent 415 fced9a61c881
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
415
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     1
// Finding a single tour on a "mega" board
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     2
//=========================================
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     3
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     4
object M4c {
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     5
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     6
// !!! Copy any function you need from file knight1.scala !!!
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     7
// !!! or knight2.scala                                   !!! 
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     8
//
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     9
// If you need any auxiliary function, feel free to 
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    10
// implement it, but do not make any changes to the
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    11
// templates below.
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    12
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    13
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    14
type Pos = (Int, Int)    // a position on a chessboard 
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    15
type Path = List[Pos]    // a path...a list of positions
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    16
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    17
//(9) Implement a function that searches for a 
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    18
//    you have to be careful to write a tail-recursive version as this 
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    19
//    function will be called with dimensions of up to 70 * 70
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    20
//    and starting field (0, 0). It has to produce a solution within
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    21
//    30 seconds.
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    22
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    23
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    24
def tour_on_mega_board(dim: Int, path: Path) : Option[Path] = ???
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    25
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    26
}