Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Johnicholas/41cd447821ac848ef7350567afc48a70 to your computer and use it in GitHub Desktop.
Save Johnicholas/41cd447821ac848ef7350567afc48a70 to your computer and use it in GitHub Desktop.
Chalcraft-Greene automaton (attempt, possible bug)
type Track
type Point
-- type LazyPoint <: Point
-- type SprungPoint <: Point
-- A track always has exactly two points, which might not be distinct.
predicate Connects(Track t, Point p1, Point p2)
-- A point always has exactly one feeder track and two siding tracks.
predicate Feeds(Track t, Point p)
-- constructor LazyPoint(Track feederTrack)
-- constructor SpringPoint(Track feederTrack)
-- predicate Siding(Track t, Point p)
{"name":"Chalcraft-Greene automaton (attempt, bug)","editorVersion":0.1,"forkedFromGist":null,"fileNames":{"domain":".domain","style":".style","substance":".substance"}}
canvas {
width = 1000
height = 1000
}
GLOBAL {
COLOR_DEBUG = #ff0000ff
}
forall Track t {
vec2 t.start = (?, ?)
vec2 t.corner = (?, ?)
vec2 t.end = (?, ?)
shape t.icon = Path {
d: quadraticCurveFromPoints("open", [t.start, t.corner, t.end])
}
shape t.debugStart = Circle {
center: t.start
r: 6
fillColor: GLOBAL.COLOR_DEBUG
}
shape t.debugCorner = Circle {
center: t.corner
r: 6
fillColor: GLOBAL.COLOR_DEBUG
}
shape t.debugEnd = Circle {
center: t.end
r: 6
fillColor: GLOBAL.COLOR_DEBUG
}
}
forall Point p {
vec2 p.center = (?, ?)
shape p.debugCircle = Circle {
center: p.center
r: 10
fillColor: GLOBAL.COLOR_DEBUG
}
}
forall Track t; Point p1; Point p2 where Connects(t, p1, p2) {
ensure equal(0., vdist(t.start, p1.center))
ensure equal(0., vdist(t.end, p2.center))
}
Track left_loop
Point left
Track straight
Point right
Track right_loop
Connects(left_loop, left, left)
Feeds(straight, left)
Feeds(straight, right)
Connects(right_loop, right, right)
AutoLabel All
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment