author | Christian Urban <christian.urban@kcl.ac.uk> |
Sat, 04 Nov 2023 18:53:37 +0000 | |
changeset 476 | 7550c816187a |
parent 428 | main_templates4/knight2.scala@cdfa6a293453 |
permissions | -rw-r--r-- |
296 | 1 |
// Core Part about finding a single tour for a board using the |
2 |
// Warnsdorf Rule |
|
3 |
//============================================================== |
|
4 |
||
397 | 5 |
object M4b { |
296 | 6 |
|
214 | 7 |
// !!! Copy any function you need from file knight1.scala !!! |
8 |
// |
|
400 | 9 |
// If you need any auxiliary functions, feel free to |
10 |
// implement them, but do not make any changes to the |
|
214 | 11 |
// templates below. |
12 |
||
13 |
type Pos = (Int, Int) // a position on a chessboard |
|
14 |
type Path = List[Pos] // a path...a list of positions |
|
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 | 18 |
|
428
cdfa6a293453
updated solutions and templates
Christian Urban <christian.urban@kcl.ac.uk>
parents:
400
diff
changeset
|
19 |
//(6) |
347 | 20 |
def ordered_moves(dim: Int, path: Path, x: Pos) : List[Pos] = ??? |
214 | 21 |
|
22 |
||
428
cdfa6a293453
updated solutions and templates
Christian Urban <christian.urban@kcl.ac.uk>
parents:
400
diff
changeset
|
23 |
//(7) |
347 | 24 |
def first_closed_tour_heuristics(dim: Int, path: Path) : Option[Path] = ??? |
214 | 25 |
|
26 |
||
27 |
//(8) Same as (7) but searches for *non-closed* tours. This |
|
28 |
// version of the function will be called with dimensions of |
|
29 |
// up to 30 * 30. |
|
30 |
||
347 | 31 |
def first_tour_heuristics(dim: Int, path: Path) : Option[Path] = ??? |
214 | 32 |
|
296 | 33 |
|
34 |
||
35 |
} |