Compare commits
1 Commits
v0.0.2-dev
...
renovate/c
Author | SHA1 | Date | |
---|---|---|---|
a468fc27a0 |
10
.drone.yml
10
.drone.yml
@ -1,10 +0,0 @@
|
|||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
type: kubernetes
|
|
||||||
name: proto pipeline
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Run goids
|
|
||||||
image: golang:alpine3.16
|
|
||||||
commands:
|
|
||||||
- go run main.go
|
|
@ -1,12 +1,15 @@
|
|||||||
- step: 10
|
- step: 10
|
||||||
amount: 100
|
amount: 100
|
||||||
neighbours: 1
|
neighbours: 10
|
||||||
- step: 100
|
- step: 100
|
||||||
amount: 100
|
amount: 100
|
||||||
neighbours: 50
|
neighbours: 50
|
||||||
- step: 200
|
- step: 200
|
||||||
amount: 500
|
amount: 150
|
||||||
neighbours: 20
|
neighbours: 20
|
||||||
|
- step: 300
|
||||||
|
amount: 40
|
||||||
|
neighbours: 10
|
||||||
- step: 400
|
- step: 400
|
||||||
amount: 10
|
amount: 10
|
||||||
neighbours: 5
|
neighbours: 5
|
||||||
|
58
main.go
58
main.go
@ -12,7 +12,6 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/llgcode/draw2d/draw2dimg"
|
"github.com/llgcode/draw2d/draw2dimg"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
@ -24,7 +23,7 @@ var goidSize = 3
|
|||||||
var goidColor = color.RGBA{200, 200, 100, 255} // gray, 50% transparency
|
var goidColor = color.RGBA{200, 200, 100, 255} // gray, 50% transparency
|
||||||
var populationSize = 20
|
var populationSize = 20
|
||||||
var loops = 500
|
var loops = 500
|
||||||
var numNeighbours = 5
|
var numNeighbours = 10
|
||||||
var separationFactor = float64(goidSize * 5)
|
var separationFactor = float64(goidSize * 5)
|
||||||
var coherenceFactor = 8
|
var coherenceFactor = 8
|
||||||
|
|
||||||
@ -34,16 +33,6 @@ type steps struct {
|
|||||||
NumNeighbours int `yaml:"neighbours"`
|
NumNeighbours int `yaml:"neighbours"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Coor struct {
|
|
||||||
X int `yaml:"x"`
|
|
||||||
Y int `yaml:"y"`
|
|
||||||
}
|
|
||||||
type OutPut struct {
|
|
||||||
Goid int `yaml:"goid"`
|
|
||||||
Loop int `yaml:"loop"`
|
|
||||||
Data Coor `yaml:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func fixGoids(gs []*Goid, actual int, wished int) ([]*Goid, int) {
|
func fixGoids(gs []*Goid, actual int, wished int) ([]*Goid, int) {
|
||||||
if actual < wished {
|
if actual < wished {
|
||||||
g := createRandomGoid()
|
g := createRandomGoid()
|
||||||
@ -57,7 +46,7 @@ func fixGoids(gs []*Goid, actual int, wished int) ([]*Goid, int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
fo, err := os.Create("/tmp/goids.yaml")
|
fo, err := os.Create("/tmp/goids.txt")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -89,48 +78,11 @@ func main() {
|
|||||||
if i > td[current_stage].Step {
|
if i > td[current_stage].Step {
|
||||||
current_stage += 1
|
current_stage += 1
|
||||||
}
|
}
|
||||||
move(goids, fo, i)
|
move(goids, fo)
|
||||||
frame := draw(goids)
|
frame := draw(goids)
|
||||||
printImage(frame.SubImage(frame.Rect))
|
printImage(frame.SubImage(frame.Rect))
|
||||||
}
|
}
|
||||||
showCursor()
|
showCursor()
|
||||||
|
|
||||||
out, err := ioutil.ReadFile("/tmp/goids.yaml")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
output := []OutPut{}
|
|
||||||
err = yaml.Unmarshal(out, &output)
|
|
||||||
var total int = 0
|
|
||||||
for _, goid := range output {
|
|
||||||
if total < goid.Goid {
|
|
||||||
total = goid.Goid
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fmt.Println(total)
|
|
||||||
|
|
||||||
for i := 0; i <= total; i++{
|
|
||||||
var x []string
|
|
||||||
var y []string
|
|
||||||
fmt.Println("GOID: ", i)
|
|
||||||
for z := 0; z <= loops; z++ {
|
|
||||||
check := false
|
|
||||||
for _, g := range output {
|
|
||||||
if g.Goid == i && g.Loop == z{
|
|
||||||
check = true
|
|
||||||
x = append(x, strconv.Itoa(g.Data.X))
|
|
||||||
y = append(y, strconv.Itoa(g.Data.Y))
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !check {
|
|
||||||
x = append(x, "-")
|
|
||||||
y = append(y, "-")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fmt.Printf("%v\n", x)
|
|
||||||
fmt.Printf("%v\n", y)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Goid represents a drawn goid
|
// Goid represents a drawn goid
|
||||||
@ -176,13 +128,13 @@ func (g *Goid) distance(n Goid) float64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// move the goids with the 3 classic boid rules
|
// move the goids with the 3 classic boid rules
|
||||||
func move(goids []*Goid, file *os.File, loop int) {
|
func move(goids []*Goid, file *os.File) {
|
||||||
for i, goid := range goids {
|
for i, goid := range goids {
|
||||||
neighbours := goid.nearestNeighbours(goids)
|
neighbours := goid.nearestNeighbours(goids)
|
||||||
separate(goid, neighbours)
|
separate(goid, neighbours)
|
||||||
align(goid, neighbours)
|
align(goid, neighbours)
|
||||||
cohere(goid, neighbours)
|
cohere(goid, neighbours)
|
||||||
position := fmt.Sprintf("- goid: %d\n loop: %d\n data:\n x: %d\n y: %d\n", i, loop, goid.X, goid.Y)
|
position := fmt.Sprintf("- coor: %d\n data:\n x: %d\n y: %d\n", i, goid.X, goid.Y)
|
||||||
file.Write([]byte(position))
|
file.Write([]byte(position))
|
||||||
stayInWindow(goid)
|
stayInWindow(goid)
|
||||||
}
|
}
|
||||||
|
3
renovate.json
Normal file
3
renovate.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
|
||||||
|
}
|
Reference in New Issue
Block a user