Recommended FSM (Finite State Machine) Library for Java [closed]
2015-04-03 18:03
447 查看
50down votefavorite 23 | Is there a best-of-breed in-memory FSM library for Java? I think ideal library would be relatively simple with support for events, actions, and transitions. It wouldn't require external configuration or precompilation. It wouldn't have to be concurrent capable or multi-threaded. Nice if it was hierarchical, but also not required. I think the State Machine included in Qt (C++) is at the ideal level of complexity and functionality. In fact, there are a number of interesting FSM libraries for C/C++, but I've been unable to find anything similar for Java. I've come across the following Java libraries so far: Unimod FSM Framework - Looks very good, but maybe overly complex. Tungsten FSM Library - No longer active as a standalone library. No documentation that I could find. Apache SCXML - Maybe? I've read that it has issues, but haven't used it yet myself. A number of articles online discuss ideas for implementing a custom FSM in Java, and maybe that's the way to go for simple in-memory FSM needs. At first I considered using a BPM engine like Activiti, but I think that those types of libraries are overkill and are more oriented towards process workflow. I'm looking to use an FSM for managing the high level behaviors of a small robot. However, I would expect a decent FSM library of this type would also be applicable to GUI state management, game flow, and simple AI. Any library recommendations, notes on experience with libraries above, or pointers to recent and modern FSM implementation strategies in Java would be appreciated. java finite-state-machine fsm
| ||
This question appears to be off-topic. The users who voted to close gave this specific reason: | |||
add a comment |
8 Answers
activeoldestvotesup vote35down voteaccepted | In answer to my question, there seems to be no defacto FSM libraries for Java. The complete list of options I've come across as of April 2013: From original question: Unimod FSM Framework Tungsten FSM Library Apache SCXML Updates: SMC: The State Map Compiler (per @Jordão's answer) Stateless4J (per @Basis Musa's answer) Ragel State Machine Compiler EasyFlow (per @Andrey's answer) Squirrel-Foundation (per @Fluera's answer) Also: JavaScript Finite State Machine A clean design that could be easily used from Java with embedded script engine.
| ||||||||||||||||||||
a comment |
up vote6down vote | This library is a very simple but fully functional state machine implementation:http://sourceforge.net/projects/javafsm/ It can be used for two quite distinct sets of purposes: Define business workflow with the purpose of validating state transitions Use it as a theoretical FSM for language recognition by defining an alphabet and using the accept() method for strings on this alphabet. Here is an example of how to build a state machine with JavaFSM: FSMBuilder<String> builder = FSM.newFSM(); FiniteStateMachine<String> machine = builder.setInitialState("A") .addFinalState("B") .addTransition("A", "A", '0') .addTransition("A", "B", '1') .addTransition("B", "A", '1') .addTransition("B", "B", '0') .build();
| ||
add a comment |
up vote6down vote | akka's FSM is also an option..
| ||
add a comment |
up vote5down vote | In the book Agile Software Development, Uncle Bob discusses Finite State Machines and the Statepattern (if I remember correctly). He's created an FSM compiler called SMC. Take a look.
| ||||||||
a comment |
up vote5down vote | Try this wonderful library from code.google.com : Stateless4J
| ||||
a comment |
up vote5down vote | You can check for "squirell-foundation" too.
| ||||
a comment |
up vote2down vote | I was looking for a FSM for Android a few months ago but couldn't find anything suitable, so had to create my own - EasyFlow. I reviewed the existing at that moment solutions and developed a light-weight library that is easier to use. With EasyFlow even complex logic can be implemented with clean and well-structured code. If anyone's still looking for a state machine for java, check it out. You can contribute to the project as well.
| ||||
a comment |
up vote0down vote | The CS department at Aarhus University has www.brics.dk/automaton which looks interesting. It seems most geared towards automata derived from regular expressions, but you can create them manually. It has three different algorithms for determinizing an NFA, and a lot of formal operations on automata (combining them, comparing them, describing what input sequences they'll match, etc.) I don't see support for actions, which seems an odd omission to me. Maybe I'm missing it. Maybe it's tricky to have them end up in the right places after the various formal operations. Still, it doesn't seem as if it should be impossible to have some notion of actions; maybe that could be added and submitted upstream.
| ||
add a comment |
Not the answer you're looking for? Browse other questions tagged java finite-state-machine fsm orask
your own question.
http://stackoverflow.com/questions/10875317/recommended-fsm-finite-state-machine-library-for-java50down votefavorite 23 | Is there a best-of-breed in-memory FSM library for Java? I think ideal library would be relatively simple with support for events, actions, and transitions. It wouldn't require external configuration or precompilation. It wouldn't have to be concurrent capable or multi-threaded. Nice if it was hierarchical, but also not required. I think the State Machine included in Qt (C++) is at the ideal level of complexity and functionality. In fact, there are a number of interesting FSM libraries for C/C++, but I've been unable to find anything similar for Java. I've come across the following Java libraries so far: Unimod FSM Framework - Looks very good, but maybe overly complex. Tungsten FSM Library - No longer active as a standalone library. No documentation that I could find. Apache SCXML - Maybe? I've read that it has issues, but haven't used it yet myself. A number of articles online discuss ideas for implementing a custom FSM in Java, and maybe that's the way to go for simple in-memory FSM needs. At first I considered using a BPM engine like Activiti, but I think that those types of libraries are overkill and are more oriented towards process workflow. I'm looking to use an FSM for managing the high level behaviors of a small robot. However, I would expect a decent FSM library of this type would also be applicable to GUI state management, game flow, and simple AI. Any library recommendations, notes on experience with libraries above, or pointers to recent and modern FSM implementation strategies in Java would be appreciated. java finite-state-machine fsm
| ||
This question appears to be off-topic. The users who voted to close gave this specific reason: | |||
add a comment |
8 Answers
activeoldestvotesup vote35down voteaccepted | In answer to my question, there seems to be no defacto FSM libraries for Java. The complete list of options I've come across as of April 2013: From original question: Unimod FSM Framework Tungsten FSM Library Apache SCXML Updates: SMC: The State Map Compiler (per @Jordão's answer) Stateless4J (per @Basis Musa's answer) Ragel State Machine Compiler EasyFlow (per @Andrey's answer) Squirrel-Foundation (per @Fluera's answer) Also: JavaScript Finite State Machine A clean design that could be easily used from Java with embedded script engine.
| ||||||||||||||||||||
a comment |
up vote6down vote | This library is a very simple but fully functional state machine implementation:http://sourceforge.net/projects/javafsm/ It can be used for two quite distinct sets of purposes: Define business workflow with the purpose of validating state transitions Use it as a theoretical FSM for language recognition by defining an alphabet and using the accept() method for strings on this alphabet. Here is an example of how to build a state machine with JavaFSM: FSMBuilder<String> builder = FSM.newFSM(); FiniteStateMachine<String> machine = builder.setInitialState("A") .addFinalState("B") .addTransition("A", "A", '0') .addTransition("A", "B", '1') .addTransition("B", "A", '1') .addTransition("B", "B", '0') .build();
| ||
add a comment |
up vote6down vote | akka's FSM is also an option..
| ||
add a comment |
up vote5down vote | In the book Agile Software Development, Uncle Bob discusses Finite State Machines and the Statepattern (if I remember correctly). He's created an FSM compiler called SMC. Take a look.
| ||||||||
a comment |
up vote5down vote | Try this wonderful library from code.google.com : Stateless4J
| ||||
a comment |
up vote5down vote | You can check for "squirell-foundation" too.
| ||||
a comment |
up vote2down vote | I was looking for a FSM for Android a few months ago but couldn't find anything suitable, so had to create my own - EasyFlow. I reviewed the existing at that moment solutions and developed a light-weight library that is easier to use. With EasyFlow even complex logic can be implemented with clean and well-structured code. If anyone's still looking for a state machine for java, check it out. You can contribute to the project as well.
| ||||
a comment |
up vote0down vote | The CS department at Aarhus University has www.brics.dk/automaton which looks interesting. It seems most geared towards automata derived from regular expressions, but you can create them manually. It has three different algorithms for determinizing an NFA, and a lot of formal operations on automata (combining them, comparing them, describing what input sequences they'll match, etc.) I don't see support for actions, which seems an odd omission to me. Maybe I'm missing it. Maybe it's tricky to have them end up in the right places after the various formal operations. Still, it doesn't seem as if it should be impossible to have some notion of actions; maybe that could be added and submitted upstream.
| ||
add a comment |
Not the answer you're looking for? Browse other questions tagged java finite-state-machine fsm orask
your own question.
相关文章推荐
- Finite State Machine library V1.0 Release
- Finite State Machine library Introduction
- Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
- HierarchicalStateMachine.java
- Are Osworkflow and Activiti based on Finite State Machine(FSM)?
- State Threads Library for Internet Applications
- 今天从http://eclipse.org/下载了一个Eclipse IDE For Java EE Developers,解压后启动,发现弹出提示框“ Failed to create the Java Virtual Machine”
- cannot find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
- JSF错误:cannot find the tag library descriptor for "http://java.sun.com/jsf/core"
- 有限状态机(Finite State Machine)在游戏中的应用和实现
- java cannot find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
- NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java class
- 装入本机库 db2jcct2, java.lang.UnsatisfiedLinkError: no db2jcct2 in java.library.path 时产生故障: ERRORCODE=-4472, SQLSTATE=null
- Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
- 64位windows Server上JavaService服务The LoadLibrary function failed for the following reason 找不到指定的模块的解决
- Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
- FSM(finite state machine)
- A Java library for reading/writing Excel
- java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Object has been closed.
- 【Jstl】java cannot find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"