1 package forage
2 3 // SourceRecord remembers a URL that the organism fetched.
4 // Bond ratio indicates how useful the content was.
5 type SourceRecord struct {
6 URL string `json:"url"`
7 BondRatio float64 `json:"bond_ratio"` // fraction of elements that bonded
8 Gen int `json:"gen"` // generation when fetched
9 Hash string `json:"hash"` // SHA-256 of content
10 }
11 12 // FilterUsefulSources returns sources with bond ratio above threshold.
13 // These are URLs that produced content the lattice could absorb.
14 func FilterUsefulSources(records []SourceRecord, minRatio float64) []SourceRecord {
15 var useful []SourceRecord
16 for _, r := range records {
17 if r.BondRatio >= minRatio {
18 useful = append(useful, r)
19 }
20 }
21 return useful
22 }
23