This repository has been archived by the owner on Sep 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathida.go
82 lines (78 loc) · 1.8 KB
/
ida.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package main
import (
// "fmt"
// "sync/atomic"
)
type Ida struct {
// running uint32
// found chan *Board
}
func (a *Ida) search(node *Board, depth, bound uint16, c chan uint16, routine bool) {
// end := func() {
// if routine {
// atomic.AddUint32(&a.running, ^uint32(0))
// }
// }
//
// f := depth + node.priority()
// if f > bound {
// end()
// c <- f
// return
// }
//
// if isGoal(node) {
// a.found <- node
// return
// }
//
// var min uint16
// childC := make(chan uint16, 4)
//
// neighbours := node.neighbours()
//
// for _, n := range neighbours {
// n.parent = node
// if atomic.LoadUint32(&a.running) < uint32(threads) {
// atomic.AddUint32(&a.running, 1)
// go a.search(n, depth+node.priority(), bound, childC, true)
// } else {
// a.search(n, depth+node.priority(), bound, childC, false)
// }
// }
//
// end()
//
// for i := 0; i < len(neighbours); i++ {
// result := <-childC
// if min == 0 || result < min {
// min = result
// }
// }
//
// c <- min
}
func (a *Ida) solve(initial *Board) (steps uint16) {
// initGoal()
//
// fmt.Println("Starting path search.")
// bound := initial.priority()
//
// c := make(chan uint16, 1)
// a.found = make(chan *Board)
//
// for {
// atomic.AddUint32(&a.running, 1)
// go a.search(initial, 0, bound, c, true)
//
// select {
// case t := <-c:
// bound = t
// case result := <-a.found:
// fmt.Println("found!!!!")
// output(result)
// return
// }
// }
return
}