You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.4 KiB
Go

2 years ago
package main
import (
"flag"
// "fmt"
"log"
"github.com/goccy/go-graphviz"
_ "github.com/mattn/go-sqlite3"
2 years ago
)
func main() {
var (
mapDB string
)
flag.StringVar(&mapDB, "map", "Aardwolf.db", "name of aardwolf map file")
flag.Parse()
am, err := NewMapper(mapDB)
if err != nil {
log.Fatalf("error creating AardMapper: %s\n", err)
}
// log.Printf("databse opened: %#+v\n", am)
2 years ago
gv := graphviz.New()
if err != nil {
log.Fatalf("error opening graph: %s\n", err)
}
g, err := gv.Graph()
if err != nil {
log.Fatalf("error retrieving cgraph: %s\n", err)
}
/*
x, err := am.Room("673")
if err != nil {
log.Fatalf("error querying room: %s", err)
}
log.Printf("%#+v\n", x)
return
*/
rooms, err := am.Rooms()
log.Printf("rooms found: %d\n", len(rooms))
for _, room := range rooms[:50] {
log.Printf("main() %s\n", room)
// log.Printf("Area: %#+v\n", v)
// log.Printf("RoomExit found: %s\n", v)
err := am.Walk(room.Uid.String, g)
if err != nil {
log.Fatalf("error adding room to graph: %s\n", err)
}
}
log.Printf("exit count: %d\n", g.NumberEdges())
log.Printf("room count: %d\n", g.NumberNodes())
if err := gv.RenderFilename(g, graphviz.SVG, "/var/www/renders.ndumas.com/aardmaps/final.svg"); err != nil {
log.Fatal(err)
}
// now that I have areas and rooms, I can start building a map
// first iteration should be a recursive walk
// step over every room. add a vertex, then descend into each
// adjoining room
2 years ago
}