From f5f7a8a63cc7b4179c685cccfad026144a35e4a3 Mon Sep 17 00:00:00 2001 From: Giovanni Squillero Date: Sat, 3 Aug 2024 18:23:25 +0200 Subject: [PATCH] feat!: in Rome BREAKING CHANGE: Still not working --- .../shortest-path/british-museum.go | 2 +- 2024-25/golang-demos/shortest-path/go.mod | 3 ++ 2024-25/golang-demos/shortest-path/go.sum | 8 +++++ 2024-25/golang-demos/shortest-path/main.go | 34 ++++++++++++++++--- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/2024-25/golang-demos/shortest-path/british-museum.go b/2024-25/golang-demos/shortest-path/british-museum.go index 99fb450..4d5158f 100644 --- a/2024-25/golang-demos/shortest-path/british-museum.go +++ b/2024-25/golang-demos/shortest-path/british-museum.go @@ -12,7 +12,7 @@ import ( func britishMuseum(graph *Graph, feed chan<- interface{}, tag int32) { cs := float32(graph.canvasSize) for { - var p viz.TaggedPolyline + var p viz.TaggedVanishingPolyline p.Tag = tag p.Points = make([]viz.Point, 0) for np := 3 + rand.Intn(10); np > 0; np -= 1 { diff --git a/2024-25/golang-demos/shortest-path/go.mod b/2024-25/golang-demos/shortest-path/go.mod index 0b737ab..5113d92 100644 --- a/2024-25/golang-demos/shortest-path/go.mod +++ b/2024-25/golang-demos/shortest-path/go.mod @@ -8,7 +8,10 @@ require ( github.com/ebitengine/gomobile v0.0.0-20240518074828-e86332849895 // indirect github.com/ebitengine/hideconsole v1.0.0 // indirect github.com/ebitengine/purego v0.7.0 // indirect + github.com/go-text/typesetting v0.1.1-0.20240325125605-c7936fe59984 // indirect github.com/jezek/xgb v1.1.1 // indirect + golang.org/x/image v0.18.0 // indirect golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.20.0 // indirect + golang.org/x/text v0.16.0 // indirect ) diff --git a/2024-25/golang-demos/shortest-path/go.sum b/2024-25/golang-demos/shortest-path/go.sum index 77541b0..d026106 100644 --- a/2024-25/golang-demos/shortest-path/go.sum +++ b/2024-25/golang-demos/shortest-path/go.sum @@ -4,6 +4,12 @@ github.com/ebitengine/hideconsole v1.0.0 h1:5J4U0kXF+pv/DhiXt5/lTz0eO5ogJ1iXb8Yj github.com/ebitengine/hideconsole v1.0.0/go.mod h1:hTTBTvVYWKBuxPr7peweneWdkUwEuHuB3C1R/ielR1A= github.com/ebitengine/purego v0.7.0 h1:HPZpl61edMGCEW6XK2nsR6+7AnJ3unUxpTZBkkIXnMc= github.com/ebitengine/purego v0.7.0/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ= +github.com/go-text/typesetting v0.1.1-0.20240325125605-c7936fe59984 h1:NwCC36eQsDf1xVZG9jD7ngXNNjsvk8KXky15ogA1Vo0= +github.com/go-text/typesetting v0.1.1-0.20240325125605-c7936fe59984/go.mod h1:2+owI/sxa73XA581LAzVuEBZ3WEEV2pXeDswCH/3i1I= +github.com/go-text/typesetting-utils v0.0.0-20240317173224-1986cbe96c66 h1:GUrm65PQPlhFSKjLPGOZNPNxLCybjzjYBzjfoBGaDUY= +github.com/go-text/typesetting-utils v0.0.0-20240317173224-1986cbe96c66/go.mod h1:DDxDdQEnB70R8owOx3LVpEFvpMK9eeH1o2r0yZhFI9o= +github.com/hajimehoshi/bitmapfont/v3 v3.0.0 h1:r2+6gYK38nfztS/et50gHAswb9hXgxXECYgE8Nczmi4= +github.com/hajimehoshi/bitmapfont/v3 v3.0.0/go.mod h1:+CxxG+uMmgU4mI2poq944i3uZ6UYFfAkj9V6WqmuvZA= github.com/hajimehoshi/ebiten/v2 v2.7.8 h1:QrlvF2byCzMuDsbxFReJkOCbM3O2z1H/NKQaGcA8PKk= github.com/hajimehoshi/ebiten/v2 v2.7.8/go.mod h1:Ulbq5xDmdx47P24EJ+Mb31Zps7vQq+guieG9mghQUaA= github.com/jezek/xgb v1.1.1 h1:bE/r8ZZtSv7l9gk6nU0mYx51aXrvnyb44892TwSaqS4= @@ -14,3 +20,5 @@ golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= diff --git a/2024-25/golang-demos/shortest-path/main.go b/2024-25/golang-demos/shortest-path/main.go index cf5e2f2..b07fdf4 100644 --- a/2024-25/golang-demos/shortest-path/main.go +++ b/2024-25/golang-demos/shortest-path/main.go @@ -6,12 +6,28 @@ package main import ( "demo-sp/viz" + "flag" + "log" + "log/slog" ) -const CanvasSize int = 1000 -const WindowSize int = 800 +const ( + CanvasSize int = 1000 + WindowSize int = 800 +) func main() { + log.SetPrefix("CI24 ") // 🐁 + log.SetFlags(log.Ldate | log.Ltime | log.Lmicroseconds | log.Lmsgprefix | log.LUTC) + + // command line arguments + verbose := flag.Bool("v", false, "Verbose operations") + flag.Parse() + if *verbose { + slog.SetLogLoggerLevel(slog.LevelDebug) + } + slog.Debug("This is Computational Intelligence 🐹 2024/25!") + // Create problem numVertexes := 50 edgeDensity := 0.01 @@ -23,13 +39,13 @@ func main() { go func() { for _, c := range graph.nodes { - feed <- viz.Circle{Color: viz.ColorBabyPink, Center: c, Radius: 5} + feed <- viz.ColoredCircle{Color: viz.ColorBabyPink, Center: c, Radius: 3} } for n1 := 0; n1 < numVertexes; n1 += 1 { for n2 := n1 + 1; n2 < numVertexes; n2 += 1 { if graph.edges[n1][n2] > 0 { - feed <- viz.Polyline{Color: viz.ColorBabyPink, - Points: []viz.Point{graph.nodes[n1], graph.nodes[n2]}} + feed <- viz.ColoredPolyline{Color: viz.ColorBabyPink, + Polyline: viz.Polyline{Points: []viz.Point{graph.nodes[n1], graph.nodes[n2]}}} } } } @@ -39,6 +55,14 @@ func main() { go britishMuseum(graph, feed, 1) go britishMuseum(graph, feed, 2) go britishMuseum(graph, feed, 3) + + go func() { + feed <- viz.TaggedText{Tag: 0, Text: "British Museum Algorithm"} + feed <- viz.TaggedText{Tag: 1, Text: "British Museum Algorithm"} + feed <- viz.TaggedText{Tag: 2, Text: "British Museum Algorithm"} + feed <- viz.TaggedText{Tag: 3, Text: "British Museum Algorithm"} + }() + viz.Run(feed, "Zap!", CanvasSize, WindowSize) //britishMuseum(graph) }