main_templates4/knight2.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Tue, 01 Nov 2022 15:03:48 +0000
changeset 428 cdfa6a293453
parent 400 e48ea8300b2d
permissions -rw-r--r--
updated solutions and templates
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
296
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 214
diff changeset
     1
// Core Part about finding a single tour for a board using the
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 214
diff changeset
     2
// Warnsdorf Rule
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 214
diff changeset
     3
//==============================================================
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 214
diff changeset
     4
397
085fefce672e updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 347
diff changeset
     5
object M4b {
296
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 214
diff changeset
     6
214
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
// !!! Copy any function you need from file knight1.scala !!!
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
//
400
e48ea8300b2d updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 397
diff changeset
     9
// If you need any auxiliary functions, feel free to 
e48ea8300b2d updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 397
diff changeset
    10
// implement them, but do not make any changes to the
214
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
// templates below.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
type Pos = (Int, Int)    // a position on a chessboard 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
type Path = List[Pos]    // a path...a list of positions
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
428
cdfa6a293453 updated solutions and templates
Christian Urban <christian.urban@kcl.ac.uk>
parents: 400
diff changeset
    16
// ADD YOUR CODE BELOW
cdfa6a293453 updated solutions and templates
Christian Urban <christian.urban@kcl.ac.uk>
parents: 400
diff changeset
    17
//======================
214
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
428
cdfa6a293453 updated solutions and templates
Christian Urban <christian.urban@kcl.ac.uk>
parents: 400
diff changeset
    19
//(6) 
347
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 305
diff changeset
    20
def ordered_moves(dim: Int, path: Path, x: Pos) : List[Pos] = ???
214
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
428
cdfa6a293453 updated solutions and templates
Christian Urban <christian.urban@kcl.ac.uk>
parents: 400
diff changeset
    23
//(7) 
347
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 305
diff changeset
    24
def first_closed_tour_heuristics(dim: Int, path: Path) : Option[Path] = ???
214
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
//(8) Same as (7) but searches for *non-closed* tours. This 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
//    version of the function will be called with dimensions of 
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
//    up to 30 * 30.
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
347
4de31fdc0d67 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 305
diff changeset
    31
def first_tour_heuristics(dim: Int, path: Path) : Option[Path] = ???
214
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
296
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 214
diff changeset
    33
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 214
diff changeset
    34
12dc251fc47e updated
Christian Urban <urbanc@in.tum.de>
parents: 214
diff changeset
    35
}