Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A classic finite state automaton framework for JVM Applications (Android and jMonkeyEngine Applications).

License

NotificationsYou must be signed in to change notification settings

Electrostat-Lab/Automata4j

Repository files navigation

Automata4jCodacy Badge

A finite state automaton framework for Java, Android, and jMonkeyEngine Applications.

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:

finalStringversion ="1.0.0-beta"repositories {mavenCentral()}dependencies {implementation"io.github.software-hardware-codesign:automata4j:${version}"}
publicfinalclassSpaceCraftEngineextendsThreadimplementsTransitionalListener {privatefinalTransitionalManagertransitionalManager =newTransitionalManager();privatefinalLatLnginitialPosition =VehicleManager.getInstance().getSpaceCraft().getLocation();privatefinalSpaceCraftEngine.TravelDistancetravelDistance =newSpaceCraftEngine.TravelDistance(10f);privatefinalSpaceCraftEngine.MoveCommandhorizontalMoveState =newSpaceCraftEngine.MoveCommand();publicSpaceCraftEngine() {super(SpaceCraftEngine.class.getName());     }/** Run your example from here or a Game state or a Unit Test */publicstaticvoidmain(Stringargs[]) {finalSpaceCraftEngineengine =newSpaceCraftEngine();engine.startTravelling();     }publicvoidstartTravelling() {/* Assigns the initial state and starts the transitional manager */transitionalManager.assignNextState(horizontalMoveState);this.start();     }@Overridepublicvoidrun() {/* Starts the finite-state-system by transiting to the next travel state */travel(travelDistance);     }@Overridepublic <I,O>voidonTransition(AutoState<I,O>presentState) {finalAutoState<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);     }protectedvoidtravel(SpaceCraftEngine.TravelDistancetravelDistance) {transitionalManager.transit(travelDistance,this);Gui.getInstance().message(Message.Type.Alert,"Travelling Now for "                                   +travelDistance.getPulse() +" Miles");     }protectedstaticclassMoveCommandimplementsAutoState<PulseCommand,LatLng> {privatePulseCommandcommand;@OverridepublicvoidsetInput(PulseCommandcommand) {this.command =command;          }@Overridepublicvoidinvoke(PulseCommandcommand) {this.command =command;// Your system state goes hereVehicleManager.getInstance().getSpaceCraft().force(command.getPulse(),0);Gui.getInstance().message(Message.Type.Info,"Added additional "                                        +command.getPulse() +" Miles");          }@OverridepublicPulseCommandgetInput() {returncommand;          }@OverridepublicLatLnggetStateTracer() {returnVehicleManager.getInstance().getSpaceCraft().getLocation();          }@OverridepublicvoidonFinish() {// Your finish code goes hereVehicleManager.getInstance().getSpaceCraft().stopEngine();Gui.getInstance().message(Message.Type.Warning,"Engine Stops");          }@OverridepublicvoidonStart() {// Your start code goes hereVehicleManager.getInstance().getSpaceCraft().startEngine();Gui.getInstance().message(Message.Type.Info,"Engine Starts");          }     }protectedstaticclassTravelDistanceimplementsPulseCommand {privatefloatpulse;publicTravelDistance(floatpulse) {this.pulse =pulse;          }@OverridepublicfloatgetPulse() {returnpulse;          }     }protectedstaticclassLocationimplementsLatLng {privatefloatx;privatefloaty;publicLocation(floatx,floaty) {this.x =x;this.y =y;          }@OverridepublicvoidsetLocation(floatx,floaty) {this.x =x;this.y =y;          }@OverridepublicfloatgetX() {returnx;          }@OverridepublicfloatgetY() {returny;          }     }}

Appendix

Features:

  • Finite-State-Machine pattern.
  • SerialAdder Example.
  • API Documentation.
  • Document describing the finite-state theory.
  • Publishing to Maven for public use.
  • Deterministic Finite-State-Automata.
  • Wiki for general use.

Theory Archive:

For more about Finite-States, find the full TextBook:

About

A classic finite state automaton framework for JVM Applications (Android and jMonkeyEngine Applications).

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp