-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblackboard.go
More file actions
123 lines (103 loc) · 2.17 KB
/
blackboard.go
File metadata and controls
123 lines (103 loc) · 2.17 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package behavior
func newBlackboard(nodeCount int) *Blackboard {
bb := &Blackboard{
nodeMemo: make([]Memory, nodeCount),
}
// for i := range bb.nodeMemo {
// bb.nodeMemo[i] = make(map[string]interface{})
// }
return bb
}
type Blackboard struct {
Instance interface{}
TreeMemo Memory
nodeMemo []Memory
}
func (bb *Blackboard) GetNodeMemo(index int) Memory {
return bb.nodeMemo[index]
}
type Memory interface {
GetStatus() NodeStatus
SaveStatus(st NodeStatus)
}
type BaseMemo struct {
status NodeStatus
}
// GetStatus get status of related node
func (memo *BaseMemo) GetStatus() NodeStatus {
return memo.status
}
// SaveStatus save status of related node
func (memo *BaseMemo) SaveStatus(st NodeStatus) {
memo.status = st
}
// type Memory map[string]interface{}
// func (memo *Memory) Set(key string, value interface{}) {
// (*memo)[key] = value
// }
// func (memo *Memory) Get(key string) interface{} {
// return (*memo)[key]
// }
// func (memo *Memory) GetInt(key string) int {
// v := (*memo)[key]
// if v == nil {
// return 0
// }
// return v.(int)
// }
// func (memo *Memory) GetInt16(key string) int16 {
// v := (*memo)[key]
// if v == nil {
// return 0
// }
// return v.(int16)
// }
// func (memo *Memory) GetInt32(key string) int32 {
// v := (*memo)[key]
// if v == nil {
// return 0
// }
// return v.(int32)
// }
// func (memo *Memory) GetInt64(key string) int64 {
// v := (*memo)[key]
// if v == nil {
// return 0
// }
// return v.(int64)
// }
// func (memo *Memory) GetUint16(key string) uint16 {
// v := (*memo)[key]
// if v == nil {
// return 0
// }
// return v.(uint16)
// }
// func (memo *Memory) GetUint32(key string) uint32 {
// v := (*memo)[key]
// if v == nil {
// return 0
// }
// return v.(uint32)
// }
// func (memo *Memory) GetUint64(key string) uint64 {
// v := (*memo)[key]
// if v == nil {
// return 0
// }
// return v.(uint64)
// }
// func (memo *Memory) GetBool(key string) bool {
// v := (*memo)[key]
// if v == nil {
// return false
// }
// return v.(bool)
// }
// func (memo *Memory) GetString(key string) string {
// v := (*memo)[key]
// if v == nil {
// return ""
// }
// return v.(string)
// }