-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconn.go
35 lines (31 loc) · 931 Bytes
/
conn.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
package evo
import "fmt"
// A Conn describes a synapse (a connection between neurons) in the network
type Conn struct {
Source, Target Position // The positions of the source and target nodes
Weight float64 // The connection weight
Enabled bool // True if this connection should be used to create a synapse
Locked bool // Locked connections cannot be removed or split
}
// String returns a description of the connection
func (c Conn) String() string {
var s string
if c.Enabled {
s = "enabled "
} else {
s = "disabled"
}
return fmt.Sprintf("conn %v->%v %s %.6f", c.Source, c.Target, s, c.Weight)
}
// Compare two connections for relative position, considering their source and
// target node positions.
func (c Conn) Compare(other Conn) int8 {
switch c.Source.Compare(other.Source) {
case -1:
return -1
case 1:
return 1
default:
return c.Target.Compare(other.Target)
}
}