296
|
1 |
// Core Part about finding a single tour for a board using the
|
|
2 |
// Warnsdorf Rule
|
|
3 |
//==============================================================
|
|
4 |
|
|
5 |
object CW8b {
|
|
6 |
|
214
|
7 |
|
|
8 |
// !!! Copy any function you need from file knight1.scala !!!
|
|
9 |
//
|
|
10 |
// If you need any auxiliary function, feel free to
|
|
11 |
// implement it, but do not make any changes to the
|
|
12 |
// templates below.
|
|
13 |
|
|
14 |
type Pos = (Int, Int) // a position on a chessboard
|
|
15 |
type Path = List[Pos] // a path...a list of positions
|
|
16 |
|
|
17 |
|
|
18 |
//(6) Complete the function that calculates a list of onward
|
|
19 |
// moves like in (2) but orders them according to Warnsdorf’s
|
|
20 |
// rule. That means moves with the fewest legal onward moves
|
|
21 |
// should come first.
|
|
22 |
|
|
23 |
|
|
24 |
//def ordered_moves(dim: Int, path: Path, x: Pos) : List[Pos] = ..
|
|
25 |
|
|
26 |
|
|
27 |
//(7) Complete the function that searches for a single *closed*
|
|
28 |
// tour using the ordered_moves function from (6). This
|
|
29 |
// function will be tested on a 6 x 6 board.
|
|
30 |
|
|
31 |
|
|
32 |
//def first_closed_tour_heuristic(dim: Int, path: Path) : Option[Path] = ...
|
|
33 |
|
|
34 |
|
|
35 |
//(8) Same as (7) but searches for *non-closed* tours. This
|
|
36 |
// version of the function will be called with dimensions of
|
|
37 |
// up to 30 * 30.
|
|
38 |
|
|
39 |
//def first_tour_heuristic(dim: Int, path: Path) : Option[Path] = ...
|
|
40 |
|
296
|
41 |
|
|
42 |
|
|
43 |
}
|