summaryrefslogtreecommitdiff
path: root/dot.lua
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2024-11-07 18:30:16 +0100
committerAki <please@ignore.pl>2024-11-07 18:35:55 +0100
commitd4dd6baae7ec7d4c02d978762cf4dd99b83ec04a (patch)
tree440dd4a098260a556a7f0a1f5edab46d36af43f5 /dot.lua
parent2eee005702d1be7e0391399f203cdbd9d7d5a42a (diff)
downloadnoita-eyes-d4dd6baae7ec7d4c02d978762cf4dd99b83ec04a.zip
noita-eyes-d4dd6baae7ec7d4c02d978762cf4dd99b83ec04a.tar.gz
noita-eyes-d4dd6baae7ec7d4c02d978762cf4dd99b83ec04a.tar.bz2
Dump automaton to a graphviz digraph
Diffstat (limited to 'dot.lua')
-rwxr-xr-xdot.lua31
1 files changed, 31 insertions, 0 deletions
diff --git a/dot.lua b/dot.lua
new file mode 100755
index 0000000..8ef5685
--- /dev/null
+++ b/dot.lua
@@ -0,0 +1,31 @@
+#!/usr/bin/env lua
+local automaton = require "automaton"
+local init = {}
+for i=1, 25 do
+ table.insert(init, i)
+end
+init = automaton(init)
+
+
+local function dump_edges (state, prefix, color)
+ prefix = prefix or ""
+ color = color or "gray"
+ io.write(prefix, "edge [color=", color, "];\n")
+ for i, v in ipairs(state) do
+ io.write(prefix, string.format("%d -> %d;\n", v, i))
+ end
+end
+
+
+print[[
+digraph {
+ node [style=filled];
+ node [fillcolor="#ded"] 1 2 3 [fillcolor=green] 4 5 6 7 8 9;
+ node [fillcolor="#dde"] 10 11 12 13 14 15 16;
+ node [fillcolor="#fed"] 17 18 19 [fillcolor=red] 20 21 22 23 24 25;]]
+dump_edges(init:left(), "\t", "red")
+dump_edges(init:right(), "\t", "blue")
+dump_edges(init:pivot(), "\t", "aqua")
+dump_edges(init:up(), "\t", "purple")
+dump_edges(init:down(), "\t", "darkgreen")
+print"}"