Automata4j
A classic finite state automaton framework for JVM Applications (Android and jMonkeyEngine Applications).
Install / Use
/learn @Electrostat-Lab/Automata4jREADME
<img src="https://github.com/Software-Hardware-Codesign/Automata4j/blob/master/vending-machine-svgrepo-com.svg" width=55 height=55/> Automata4j

A finite state automaton framework for Java, Android, and jMonkeyEngine Applications.
<img src="https://github.com/Software-Hardware-Codesign/Automata4j/blob/master/archives/architecture.png"/>Building:
┌─[pavl-machine@pavl-machine]─[/home/pavl-machine/projects]
└──╼ $git clone https://github.com/Software-Hardware-Codesign/Automata4j.git && cd ./Automata4j
┌─[pavl-machine@pavl-machine]─[/home/pavl-machine/projects/Automata4j]
└──╼ $./gradlew automata4j:build && \
./gradlew automata4j:generateJavadocJar && \
./gradlew automata4j:generateSourcesJar
Implementation Example:
final String version = "1.0.0-beta"
repositories {
mavenCentral()
}
dependencies {
implementation "io.github.software-hardware-codesign:automata4j:${version}"
}
public final class SpaceCraftEngine extends Thread implements TransitionalListener {
private final TransitionalManager transitionalManager = new TransitionalManager();
private final LatLng initialPosition = VehicleManager.getInstance().getSpaceCraft().getLocation();
private final SpaceCraftEngine.TravelDistance travelDistance = new SpaceCraftEngine.TravelDistance(10f);
private final SpaceCraftEngine.MoveCommand horizontalMoveState = new SpaceCraftEngine.MoveCommand();
public SpaceCraftEngine() {
super(SpaceCraftEngine.class.getName());
}
/** Run your example from here or a Game state or a Unit Test */
public static void main(String args[]) {
final SpaceCraftEngine engine = new SpaceCraftEngine();
engine.startTravelling();
}
public void startTravelling() {
/* Assigns the initial state and starts the transitional manager */
transitionalManager.assignNextState(horizontalMoveState);
this.start();
}
@Override
public void run() {
/* Starts the finite-state-system by transiting to the next travel state */
travel(travelDistance);
}
@Override
public <I, O> void onTransition(AutoState<I, O> presentState) {
final AutoState<PulseCommand, LatLng> autoState = (AutoState<PulseCommand, LatLng>) presentState;
if (presentState.getStateTracer().getX() > (initialPosition.getX() + 200f)) {
/* Exits the system once traveling has been completed and docks the spacecraft */
VehicleManager.getInstance().getSpaceCraft().dock(DockingSpeed.DEFAULT_SPEED);
Gui.getInstance().message(Message.Type.Alert,
"Completed Travelling 200+ Miles, Docking the SpaceCraft");
return;
}
/* Continues assigning new states as long as the destination has not been met */
transitionalManager.assignNextState(horizontalMoveState);
travel(travelDistance);
}
protected void travel(SpaceCraftEngine.TravelDistance travelDistance) {
transitionalManager.transit(travelDistance, this);
Gui.getInstance().message(Message.Type.Alert, "Travelling Now for "
+ travelDistance.getPulse() + " Miles");
}
protected static class MoveCommand implements AutoState<PulseCommand, LatLng> {
private PulseCommand command;
@Override
public void setInput(PulseCommand command) {
this.command = command;
}
@Override
public void invoke(PulseCommand command) {
this.command = command;
// Your system state goes here
VehicleManager.getInstance().getSpaceCraft().force(command.getPulse(), 0);
Gui.getInstance().message(Message.Type.Info, "Added additional "
+ command.getPulse() + " Miles");
}
@Override
public PulseCommand getInput() {
return command;
}
@Override
public LatLng getStateTracer() {
return VehicleManager.getInstance().getSpaceCraft().getLocation();
}
@Override
public void onFinish() {
// Your finish code goes here
VehicleManager.getInstance().getSpaceCraft().stopEngine();
Gui.getInstance().message(Message.Type.Warning, "Engine Stops");
}
@Override
public void onStart() {
// Your start code goes here
VehicleManager.getInstance().getSpaceCraft().startEngine();
Gui.getInstance().message(Message.Type.Info, "Engine Starts");
}
}
protected static class TravelDistance implements PulseCommand {
private float pulse;
public TravelDistance(float pulse) {
this.pulse = pulse;
}
@Override
public float getPulse() {
return pulse;
}
}
protected static class Location implements LatLng {
private float x;
private float y;
public Location(float x, float y) {
this.x = x;
this.y = y;
}
@Override
public void setLocation(float x, float y) {
this.x = x;
this.y = y;
}
@Override
public float getX() {
return x;
}
@Override
public float getY() {
return y;
}
}
}
Appendix
Features:
- [x] Finite-State-Machine pattern.
- [x] SerialAdder Example.
- [x] API Documentation.
- [x] Document describing the finite-state theory.
- [x] Publishing to Maven for public use.
- [x] Deterministic Finite-State-Automata.
- [x] Wiki for general use.
Theory Archive:
- Finite-State-Automaton Theory Archive, from Switching and Finite Automata Theory 3rd Edition
- Finite-State-Recognizers for DFSA V.S. NDFSA
For more about Finite-States, find the full TextBook:
Related Skills
diffs
344.1kUse the diffs tool to produce real, shareable diffs (viewer URL, file artifact, or both) instead of manual edit summaries.
clearshot
Structured screenshot analysis for UI implementation and critique. Analyzes every UI screenshot with a 5×5 spatial grid, full element inventory, and design system extraction — facts and taste together, every time. Escalates to full implementation blueprint when building. Trigger on any digital interface image file (png, jpg, gif, webp — websites, apps, dashboards, mockups, wireframes) or commands like 'analyse this screenshot,' 'rebuild this,' 'match this design,' 'clone this.' Skip for non-UI images (photos, memes, charts) unless the user explicitly wants to build a UI from them. Does NOT trigger on HTML source code, CSS, SVGs, or any code pasted as text.
openpencil
2.0kThe world's first open-source AI-native vector design tool and the first to feature concurrent Agent Teams. Design-as-Code. Turn prompts into UI directly on the live canvas. A modern alternative to Pencil.
HappyColorBlend
HappyColorBlendVibe Project Guidelines Project Overview HappyColorBlendVibe is a Figma plugin for color palette generation with advanced tint/shade blending capabilities. It allows designers to
