Skip to content

Commit

Permalink
feat!: Train to Rome
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Not working
  • Loading branch information
squillero committed Aug 2, 2024
1 parent 4ad2618 commit b5c4325
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 117 deletions.
23 changes: 23 additions & 0 deletions 2024-25/golang-demos/shortest-path/british-museum.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright © 2024 Giovanni Squillero <[email protected]>
// https://github.com/squillero/computational-intelligence
// Free under certain conditions — see the license for details.

package main

import (
"demo-sp/viz"
"math/rand"
)

func britishMuseum(graph *Graph, feed chan<- interface{}, tag int32) {
cs := float32(graph.canvasSize)
for {
var p viz.TaggedPolyline
p.Tag = tag
p.Points = make([]viz.Point, 0)
for np := 3 + rand.Intn(10); np > 0; np -= 1 {
p.Points = append(p.Points, viz.Point{X: cs * rand.Float32(), Y: cs * rand.Float32()})
}
feed <- p
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module demo
module demo-sp

go 1.21

Expand Down
File renamed without changes.
44 changes: 44 additions & 0 deletions 2024-25/golang-demos/shortest-path/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright © 2024 Giovanni Squillero <[email protected]>
// https://github.com/squillero/computational-intelligence
// Free under certain conditions — see the license for details.

package main

import (
"demo-sp/viz"
)

const CanvasSize int = 1000
const WindowSize int = 800

func main() {
// Create problem
numVertexes := 50
edgeDensity := 0.01

// all passed by reference...
feed := make(chan interface{}, numVertexes)
graph := &Graph{canvasSize: CanvasSize}
graph.initialize(numVertexes, edgeDensity)

go func() {
for _, c := range graph.nodes {
feed <- viz.Circle{Color: viz.ColorBabyPink, Center: c, Radius: 5}
}
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]}}
}
}
}
}()

go britishMuseum(graph, feed, 0)
go britishMuseum(graph, feed, 1)
go britishMuseum(graph, feed, 2)
go britishMuseum(graph, feed, 3)
viz.Run(feed, "Zap!", CanvasSize, WindowSize)
//britishMuseum(graph)
}
45 changes: 0 additions & 45 deletions 2024-25/golang-demos/tsp/main.go

This file was deleted.

5 changes: 0 additions & 5 deletions 2024-25/golang-demos/tsp/tsp.go

This file was deleted.

66 changes: 0 additions & 66 deletions 2024-25/golang-demos/tsp/visual.go

This file was deleted.

0 comments on commit b5c4325

Please sign in to comment.