Compare commits
1 Commits
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
|
|
33
config.yaml
33
config.yaml
@ -1,24 +1,19 @@
|
|||||||
screen_size:
|
- step: 10
|
||||||
width: 1400
|
amount: 100
|
||||||
height: 1000
|
|
||||||
last_step: 500
|
|
||||||
init_amount: 20
|
|
||||||
steps:
|
|
||||||
- step: 100
|
|
||||||
amount: 20
|
|
||||||
neighbours: 5
|
|
||||||
- step: 200
|
|
||||||
amount: 20
|
|
||||||
neighbours: 10
|
neighbours: 10
|
||||||
|
- step: 100
|
||||||
|
amount: 100
|
||||||
|
neighbours: 50
|
||||||
|
- step: 200
|
||||||
|
amount: 150
|
||||||
|
neighbours: 20
|
||||||
- step: 300
|
- step: 300
|
||||||
amount: 5
|
amount: 40
|
||||||
neighbours: 1
|
neighbours: 10
|
||||||
- step: 400
|
- step: 400
|
||||||
amount: 5
|
amount: 10
|
||||||
neighbours: 1
|
neighbours: 5
|
||||||
- step: 500
|
- step: 500
|
||||||
amount: 6
|
amount: 1
|
||||||
neighbours: 1
|
|
||||||
- step: 600
|
|
||||||
amount: 7
|
|
||||||
neighbours: 1
|
neighbours: 1
|
||||||
|
|
||||||
|
@ -1,172 +0,0 @@
|
|||||||
(
|
|
||||||
setf *om-current-persistent*
|
|
||||||
(
|
|
||||||
om-load-patch1 "Patch 2"
|
|
||||||
(
|
|
||||||
quote
|
|
||||||
(
|
|
||||||
(
|
|
||||||
let
|
|
||||||
(
|
|
||||||
(
|
|
||||||
box
|
|
||||||
(
|
|
||||||
om-load-editor-box1 "BPC"
|
|
||||||
(
|
|
||||||
quote bpc
|
|
||||||
)
|
|
||||||
(
|
|
||||||
quote
|
|
||||||
(
|
|
||||||
(
|
|
||||||
om-load-inputfun
|
|
||||||
(
|
|
||||||
quote input-funbox
|
|
||||||
)
|
|
||||||
"object" "self" nil
|
|
||||||
)
|
|
||||||
(
|
|
||||||
om-load-inputfun
|
|
||||||
(
|
|
||||||
quote input-funbox
|
|
||||||
)
|
|
||||||
"X coordinates (list)" "x-points"
|
|
||||||
(
|
|
||||||
list 0 100
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
om-load-inputfun
|
|
||||||
(
|
|
||||||
quote input-funbox
|
|
||||||
)
|
|
||||||
"Y coordinates (list)" "y-points"
|
|
||||||
(
|
|
||||||
list 0 100
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
om-load-inputfun
|
|
||||||
(
|
|
||||||
quote input-funbox
|
|
||||||
)
|
|
||||||
"precision
|
|
||||||
(
|
|
||||||
integer
|
|
||||||
) [0 - 10]" "decimals" 0
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
om-make-point 151 96
|
|
||||||
)
|
|
||||||
(
|
|
||||||
om-make-point 40 60
|
|
||||||
)
|
|
||||||
(
|
|
||||||
let
|
|
||||||
(
|
|
||||||
(
|
|
||||||
newobj
|
|
||||||
(
|
|
||||||
when
|
|
||||||
(
|
|
||||||
find-class
|
|
||||||
(
|
|
||||||
quote bpc
|
|
||||||
)
|
|
||||||
nil
|
|
||||||
)
|
|
||||||
(
|
|
||||||
let
|
|
||||||
(
|
|
||||||
(
|
|
||||||
newbpf
|
|
||||||
(
|
|
||||||
simple-bpf-from-list
|
|
||||||
(
|
|
||||||
quote
|
|
||||||
(
|
|
||||||
-1 99 70
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
quote
|
|
||||||
(
|
|
||||||
0 100 65
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
quote bpc
|
|
||||||
)
|
|
||||||
0
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
setf
|
|
||||||
(
|
|
||||||
bpfcolor newbpf
|
|
||||||
)
|
|
||||||
(
|
|
||||||
om-make-color 0 0 0
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
set-name newbpf "BPC"
|
|
||||||
)
|
|
||||||
newbpf
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
when newobj
|
|
||||||
)
|
|
||||||
newobj
|
|
||||||
)
|
|
||||||
"x" nil
|
|
||||||
(
|
|
||||||
pairlis
|
|
||||||
(
|
|
||||||
quote
|
|
||||||
(
|
|
||||||
picture winpos winsize
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
list nil
|
|
||||||
(
|
|
||||||
om-make-point 0 0
|
|
||||||
)
|
|
||||||
(
|
|
||||||
om-make-point 1900 1006
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
nil nil nil nil
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
when
|
|
||||||
(
|
|
||||||
fboundp
|
|
||||||
(
|
|
||||||
quote set-active
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
set-active box nil
|
|
||||||
)
|
|
||||||
)
|
|
||||||
box
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
quote nil
|
|
||||||
)
|
|
||||||
nil 6.19
|
|
||||||
)
|
|
||||||
)
|
|
@ -1,4 +0,0 @@
|
|||||||
; OM File Header - Saved 2022/12/29 14:43:16
|
|
||||||
; (6.19 :patc (om-make-point 10 10) (om-make-point 50 50) (om-make-point 500 400) "" 183 0 "2022/12/29 14:43:16" "2022/12/29 14:43:16")
|
|
||||||
; End File Header
|
|
||||||
(in-package :om)(load-lib-for (quote nil))(setf *om-current-persistent* (om-load-patch1 "Patch" (quote nil) (quote nil) nil 6.19))
|
|
@ -1,183 +0,0 @@
|
|||||||
(
|
|
||||||
in-package :om
|
|
||||||
)
|
|
||||||
|
|
||||||
(
|
|
||||||
load-lib-for
|
|
||||||
(
|
|
||||||
quote nil
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
(
|
|
||||||
setf *om-current-persistent*
|
|
||||||
(
|
|
||||||
om-load-patch1 "Patch 2"
|
|
||||||
(
|
|
||||||
quote
|
|
||||||
(
|
|
||||||
(
|
|
||||||
let
|
|
||||||
(
|
|
||||||
(
|
|
||||||
box
|
|
||||||
(
|
|
||||||
om-load-editor-box1 "BPC"
|
|
||||||
(
|
|
||||||
quote bpc
|
|
||||||
)
|
|
||||||
(
|
|
||||||
quote
|
|
||||||
(
|
|
||||||
(
|
|
||||||
om-load-inputfun
|
|
||||||
(
|
|
||||||
quote input-funbox
|
|
||||||
)
|
|
||||||
"object" "self" nil
|
|
||||||
)
|
|
||||||
(
|
|
||||||
om-load-inputfun
|
|
||||||
(
|
|
||||||
quote input-funbox
|
|
||||||
)
|
|
||||||
"X coordinates (list)" "x-points"
|
|
||||||
(
|
|
||||||
list 0 100
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
om-load-inputfun
|
|
||||||
(
|
|
||||||
quote input-funbox
|
|
||||||
)
|
|
||||||
"Y coordinates (list)" "y-points"
|
|
||||||
(
|
|
||||||
list 0 100
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
om-load-inputfun
|
|
||||||
(
|
|
||||||
quote input-funbox
|
|
||||||
)
|
|
||||||
"precision
|
|
||||||
(
|
|
||||||
integer
|
|
||||||
) [0 - 10]" "decimals" 0
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
om-make-point 151 96
|
|
||||||
)
|
|
||||||
(
|
|
||||||
om-make-point 40 60
|
|
||||||
)
|
|
||||||
(
|
|
||||||
let
|
|
||||||
(
|
|
||||||
(
|
|
||||||
newobj
|
|
||||||
(
|
|
||||||
when
|
|
||||||
(
|
|
||||||
find-class
|
|
||||||
(
|
|
||||||
quote bpc
|
|
||||||
)
|
|
||||||
nil
|
|
||||||
)
|
|
||||||
(
|
|
||||||
let
|
|
||||||
(
|
|
||||||
(
|
|
||||||
newbpf
|
|
||||||
(
|
|
||||||
simple-bpf-from-list
|
|
||||||
(
|
|
||||||
quote
|
|
||||||
(
|
|
||||||
-1 99 70
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
quote
|
|
||||||
(
|
|
||||||
0 100 65
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
quote bpc
|
|
||||||
)
|
|
||||||
0
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
setf
|
|
||||||
(
|
|
||||||
bpfcolor newbpf
|
|
||||||
)
|
|
||||||
(
|
|
||||||
om-make-color 0 0 0
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
set-name newbpf "BPC"
|
|
||||||
)
|
|
||||||
newbpf
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
when newobj
|
|
||||||
)
|
|
||||||
newobj
|
|
||||||
)
|
|
||||||
"x" nil
|
|
||||||
(
|
|
||||||
pairlis
|
|
||||||
(
|
|
||||||
quote
|
|
||||||
(
|
|
||||||
picture winpos winsize
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
list nil
|
|
||||||
(
|
|
||||||
om-make-point 0 0
|
|
||||||
)
|
|
||||||
(
|
|
||||||
om-make-point 1900 1006
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
nil nil nil nil
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
when
|
|
||||||
(
|
|
||||||
fboundp
|
|
||||||
(
|
|
||||||
quote set-active
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
set-active box nil
|
|
||||||
)
|
|
||||||
)
|
|
||||||
box
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
quote nil
|
|
||||||
)
|
|
||||||
nil 6.19
|
|
||||||
)
|
|
||||||
)
|
|
179
main.go
179
main.go
@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
"image/png"
|
"image/png"
|
||||||
@ -13,67 +12,30 @@ 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"
|
||||||
)
|
)
|
||||||
|
|
||||||
// parameters
|
// parameters
|
||||||
|
var windowWidth, windowHeight = 1000, 700
|
||||||
var goidSize = 3
|
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 = 0
|
var populationSize = 20
|
||||||
var loops = 3000
|
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
|
||||||
|
|
||||||
const OM_TEMPLATE = `; OM File Header - Saved 2023/01/22 08:12:44
|
|
||||||
; (7.01 :patc (om-make-point 10 10) (om-make-point 915 795) (om-make-point 845 307) "" 183 0 "2023/01/22 08:11:39" "2023/01/22 08:12:44")
|
|
||||||
; End File Header
|
|
||||||
(in-package :om)(load-lib-for (quote nil))(setf *om-current-persistent* (om-load-patch1 "Patch" (quote ({{range $val := .BPC}}(let ((box (om-load-editor-box1 "BPC" (quote bpc) (quote ((om-load-inputfun (quote input-funbox) "object" "self" nil) (om-load-inputfun (quote input-funbox) "X coordinates (list)" "x-points" (list{{ range $x := .X }} {{ $x }}{{ end }})) (om-load-inputfun (quote input-funbox) "Y coordinates (list)" "y-points" (list{{ range $y:= .Y }} {{ $y }}{{ end }})) (om-load-inputfun (quote input-funbox) "precision (integer) [0 - 10]" "decimals" 0))) (om-make-point {{ .MakePoint.X }} {{ .MakePoint.Y }}) (om-make-point 50 50) (let ((newobj (when (find-class (quote bpc) nil) (let ((newbpf (simple-bpf-from-list (quote ({{ range $x := .X }} {{ $x }}{{ end }})) (quote ({{ range $y := .Y }} {{ $y }}{{ end }})) (quote bpc) 0))) (setf (bpfcolor newbpf) (om-make-color 0 0 0)) (set-name newbpf "BPC") newbpf)))) (when newobj) newobj) "&" nil (pairlis (quote (picture winpos winsize)) (list nil (om-make-point 20 20)(om-make-point 20 20))) nil nil nil nil))) (when (fboundp (quote set-active)) (set-active box nil)) box){{ end }}))(quote nil) nil 7.01))
|
|
||||||
`
|
|
||||||
|
|
||||||
type configuration struct {
|
|
||||||
Steps []steps `yaml:"steps"`
|
|
||||||
ScreenSize ScreenSize `yaml:"screen_size"`
|
|
||||||
LastStep int `yaml:"last_step"`
|
|
||||||
InitAmount int `yaml:"init_amount"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ScreenSize struct {
|
|
||||||
Width int `yaml:"width"`
|
|
||||||
Height int `yaml:"height"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type steps struct {
|
type steps struct {
|
||||||
Step int `yaml:"step"`
|
Step int `yaml:"step"`
|
||||||
Amount int `yaml:"amount"`
|
Amount int `yaml:"amount"`
|
||||||
NumNeighbours int `yaml:"neighbours"`
|
NumNeighbours int `yaml:"neighbours"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Coor struct {
|
func fixGoids(gs []*Goid, actual int, wished int) ([]*Goid, int) {
|
||||||
X int `yaml:"x"`
|
|
||||||
Y int `yaml:"y"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type BPC struct {
|
|
||||||
BPC []Coords
|
|
||||||
}
|
|
||||||
type Coords struct {
|
|
||||||
X []int
|
|
||||||
Y []int
|
|
||||||
MakePoint Coor
|
|
||||||
}
|
|
||||||
type OutPut struct {
|
|
||||||
Goid int `yaml:"goid"`
|
|
||||||
Loop int `yaml:"loop"`
|
|
||||||
Data Coor `yaml:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func fixGoids(gs []*Goid, actual int, wished int, field ScreenSize) ([]*Goid, int) {
|
|
||||||
if actual < wished {
|
if actual < wished {
|
||||||
g := createRandomGoid(field)
|
g := createRandomGoid()
|
||||||
gs = append(gs, &g)
|
gs = append(gs, &g)
|
||||||
return gs, actual + 1
|
return gs, actual + 1
|
||||||
} else if wished < actual {
|
} else if wished < actual {
|
||||||
@ -84,7 +46,7 @@ func fixGoids(gs []*Goid, actual int, wished int, field ScreenSize) ([]*Goid, in
|
|||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
}
|
}
|
||||||
@ -92,11 +54,8 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
config := configuration{}
|
td := []steps{}
|
||||||
err = yaml.Unmarshal(conf, &config)
|
err = yaml.Unmarshal(conf, &td)
|
||||||
steps := config.Steps
|
|
||||||
loops = config.LastStep
|
|
||||||
populationSize = config.InitAmount
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := fo.Close(); err != nil {
|
if err := fo.Close(); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -105,97 +64,25 @@ func main() {
|
|||||||
clearScreen()
|
clearScreen()
|
||||||
hideCursor()
|
hideCursor()
|
||||||
var goids []*Goid
|
var goids []*Goid
|
||||||
|
|
||||||
for i := 0; i < populationSize; i++ {
|
for i := 0; i < populationSize; i++ {
|
||||||
g := createRandomGoid(config.ScreenSize)
|
g := createRandomGoid()
|
||||||
goids = append(goids, &g)
|
goids = append(goids, &g)
|
||||||
}
|
}
|
||||||
|
|
||||||
current_stage := 0
|
current_stage := 0
|
||||||
|
|
||||||
for i := 0; i < loops; i++ {
|
for i := 0; i < loops; i++ {
|
||||||
goids, populationSize = fixGoids(goids, populationSize, steps[current_stage].Amount, config.ScreenSize)
|
goids, populationSize = fixGoids(goids, populationSize, td[current_stage].Amount)
|
||||||
fmt.Printf("%d - %d", i, populationSize)
|
numNeighbours = td[current_stage].NumNeighbours
|
||||||
if steps[current_stage].NumNeighbours >= populationSize {
|
if i > td[current_stage].Step {
|
||||||
numNeighbours = populationSize
|
|
||||||
} else {
|
|
||||||
numNeighbours = steps[current_stage].NumNeighbours
|
|
||||||
}
|
|
||||||
if i == steps[current_stage+1].Step {
|
|
||||||
current_stage += 1
|
current_stage += 1
|
||||||
}
|
}
|
||||||
move(goids, fo, i, config.ScreenSize)
|
move(goids, fo)
|
||||||
frame := draw(goids, config.ScreenSize)
|
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
outfile, err := os.Create("./goids.txt")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
bpc := BPC{}
|
|
||||||
mX := 0
|
|
||||||
mY := 0
|
|
||||||
for i := 0; i <= total; i++ {
|
|
||||||
mX += 70
|
|
||||||
if i%10 == 0 {
|
|
||||||
mX = 70
|
|
||||||
mY += 70
|
|
||||||
}
|
|
||||||
coords := Coords{}
|
|
||||||
makePoint := Coor{X: mX, Y: mY}
|
|
||||||
coords.MakePoint = makePoint
|
|
||||||
var x []string
|
|
||||||
var y []string
|
|
||||||
outfile.Write([]byte(fmt.Sprintf("GOID: %d\n", i)))
|
|
||||||
for z := 0; z <= loops; z++ {
|
|
||||||
cX := 0
|
|
||||||
cY := 0
|
|
||||||
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))
|
|
||||||
coords.X = append(coords.X, g.Data.X)
|
|
||||||
coords.Y = append(coords.Y, g.Data.Y)
|
|
||||||
cX = g.Data.X
|
|
||||||
cY = g.Data.Y
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !check {
|
|
||||||
x = append(x, "-")
|
|
||||||
y = append(y, "-")
|
|
||||||
coords.X = append(coords.X, cX)
|
|
||||||
coords.Y = append(coords.Y, cY)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bpc.BPC = append(bpc.BPC, coords)
|
|
||||||
outfile.Write([]byte(fmt.Sprintf("%v\n", x)))
|
|
||||||
outfile.Write([]byte(fmt.Sprintf("%v\n", y)))
|
|
||||||
}
|
|
||||||
t, err := template.New("todos").Parse(OM_TEMPLATE)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
file, _ := os.Create("Patch.omp")
|
|
||||||
defer file.Close()
|
|
||||||
err = t.Execute(file, bpc)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Goid represents a drawn goid
|
// Goid represents a drawn goid
|
||||||
@ -208,10 +95,10 @@ type Goid struct {
|
|||||||
Color color.Color
|
Color color.Color
|
||||||
}
|
}
|
||||||
|
|
||||||
func createRandomGoid(field ScreenSize) (g Goid) {
|
func createRandomGoid() (g Goid) {
|
||||||
g = Goid{
|
g = Goid{
|
||||||
X: rand.Intn(field.Width),
|
X: rand.Intn(windowWidth),
|
||||||
Y: rand.Intn(field.Height),
|
Y: rand.Intn(windowHeight),
|
||||||
Vx: rand.Intn(goidSize),
|
Vx: rand.Intn(goidSize),
|
||||||
Vy: rand.Intn(goidSize),
|
Vy: rand.Intn(goidSize),
|
||||||
R: goidSize,
|
R: goidSize,
|
||||||
@ -241,29 +128,29 @@ 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, field ScreenSize) {
|
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, field)
|
stayInWindow(goid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if goid goes out of the window frame it comes back on the other side
|
// if goid goes out of the window frame it comes back on the other side
|
||||||
func stayInWindow(goid *Goid, field ScreenSize) {
|
func stayInWindow(goid *Goid) {
|
||||||
if goid.X < 0 {
|
if goid.X < 0 {
|
||||||
goid.X = field.Width - goid.X
|
goid.X = windowWidth - goid.X
|
||||||
} else if goid.X > field.Width {
|
} else if goid.X > windowWidth {
|
||||||
goid.X = field.Width - goid.X
|
goid.X = windowWidth - goid.X
|
||||||
}
|
}
|
||||||
if goid.Y < 0 {
|
if goid.Y < 0 {
|
||||||
goid.Y = field.Height - goid.Y
|
goid.Y = windowHeight - goid.Y
|
||||||
} else if goid.Y > field.Height {
|
} else if goid.Y > windowHeight {
|
||||||
goid.Y = field.Height - goid.Y
|
goid.Y = windowHeight - goid.Y
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,8 +198,8 @@ func cohere(g *Goid, neighbours []Goid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// draw the goids
|
// draw the goids
|
||||||
func draw(goids []*Goid, field ScreenSize) *image.RGBA {
|
func draw(goids []*Goid) *image.RGBA {
|
||||||
dest := image.NewRGBA(image.Rect(0, 0, field.Width, field.Height))
|
dest := image.NewRGBA(image.Rect(0, 0, windowWidth, windowHeight))
|
||||||
gc := draw2dimg.NewGraphicContext(dest)
|
gc := draw2dimg.NewGraphicContext(dest)
|
||||||
for _, goid := range goids {
|
for _, goid := range goids {
|
||||||
gc.SetFillColor(goid.Color)
|
gc.SetFillColor(goid.Color)
|
||||||
|
@ -1 +0,0 @@
|
|||||||
pacjage
|
|
@ -1,11 +0,0 @@
|
|||||||
package omp
|
|
||||||
|
|
||||||
type BPC struct {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s BPC) Init() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// InitPatch()
|
|
@ -1,22 +0,0 @@
|
|||||||
package omp
|
|
||||||
|
|
||||||
type Header struct {
|
|
||||||
Data []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//TODO: It must be create dynamically for different kinds of entities (patch, maquette, etc)
|
|
||||||
func (h *Header) Init() {
|
|
||||||
h.Data = []byte(`; OM File Header - Saved 2022/12/29 14:43:16
|
|
||||||
; (6.19 :patc (om-make-point 10 10) (om-make-point 50 50) (om-make-point 500 400) "" 183 0 "2022/12/29 14:43:16" "2022/12/29 14:43:16")
|
|
||||||
; End File Header
|
|
||||||
`)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *Header) GetData() []byte {
|
|
||||||
return h.Data
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *Header) DataToString() string {
|
|
||||||
return string(h.Data)
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package omp_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"goids/pkg/types/omp"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
const headerExample = `; OM File Header - Saved 2022/12/29 14:43:16
|
|
||||||
; (6.19 :patc (om-make-point 10 10) (om-make-point 50 50) (om-make-point 500 400) "" 183 0 "2022/12/29 14:43:16" "2022/12/29 14:43:16")
|
|
||||||
; End File Header
|
|
||||||
`
|
|
||||||
|
|
||||||
func TestAbs(t *testing.T) {
|
|
||||||
header := &omp.Header{}
|
|
||||||
header.Init()
|
|
||||||
str := header.DataToString()
|
|
||||||
if str != headerExample {
|
|
||||||
t.Errorf("Header is wrong\nwant:\n%s \n\ngot \n%s", headerExample, str)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
package omp
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
type OMP struct {
|
|
||||||
Header Header
|
|
||||||
Data Data
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s OMP) Build() []byte {
|
|
||||||
buff := bytes.NewBufferString("")
|
|
||||||
buff.Write(s.Header.GetData())
|
|
||||||
buff.Write(s.Data.GetIntro())
|
|
||||||
buff.Write(s.Data.GetLibFor())
|
|
||||||
buff.Write(s.Data.GetOMCurrentPersistent())
|
|
||||||
return buff.Bytes()
|
|
||||||
}
|
|
||||||
|
|
||||||
type Data struct {
|
|
||||||
Intro []byte
|
|
||||||
LibFor []byte
|
|
||||||
CurrentPersistent []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Data) GetIntro() []byte {
|
|
||||||
return s.Intro
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Data) SetIntro() {
|
|
||||||
s.Intro = []byte("(in-package :om)")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Data) GetLibFor() []byte {
|
|
||||||
return s.LibFor
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Data) SetLibFor() {
|
|
||||||
s.LibFor = []byte("(load-lib-for (quote nil))")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Data) SetOMCurrentPersistent(kind string, name string) {
|
|
||||||
s.CurrentPersistent = []byte(fmt.Sprintf("(setf *om-current-persistent* (%s \"%s\" () (quote nil) nil 6.19))", kind, name))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Data) GetOMCurrentPersistent() []byte {
|
|
||||||
return s.CurrentPersistent
|
|
||||||
}
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
|||||||
package omp_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"goids/pkg/types/omp"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
const ompExample = `; OM File Header - Saved 2022/12/29 14:43:16
|
|
||||||
; (6.19 :patc (om-make-point 10 10) (om-make-point 50 50) (om-make-point 500 400) "" 183 0 "2022/12/29 14:43:16" "2022/12/29 14:43:16")
|
|
||||||
; End File Header
|
|
||||||
(in-package :om)(load-lib-for (quote nil))(setf *om-current-persistent* (om-load-patch1 "Test Patch" (quote nil) (quote nil) nil 6.19))`
|
|
||||||
|
|
||||||
func TestOmpBuilder(t *testing.T) {
|
|
||||||
header := &omp.OMP{}
|
|
||||||
header.Data.SetIntro()
|
|
||||||
header.Data.SetLibFor()
|
|
||||||
header.Data.SetOMCurrentPersistent("om-load-patch1", "Test Patch")
|
|
||||||
header.Header.Init()
|
|
||||||
str := string(header.Build())
|
|
||||||
if str != ompExample {
|
|
||||||
t.Errorf("Header is wrong\nwant:\n%s \n\ngot \n%s", ompExample, str)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
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