Hack Forums
[Java] Finite State Machine Help! - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Java] Finite State Machine Help! (/showthread.php?tid=4119436)



Finite State Machine Help! - Vaws - Mar 16, 2014

Im trying to implement a finite state machine to handle the AI of my game's AI. Ive implemented finite state machine in c++ before using function pointers but i do not know how to do it in java due to lack of these. If you could help, please pm me or message me on skype: imomniscient


* - SIM-2015410 - Mar 16, 2014

Im a bit busy at the moment, but i just found this which might be of interest to you:
http://stackoverflow.com/questions/13221168/how-to-implement-a-fsm-finite-state-machine-in-java
You could use an enum of states, and each AI can base its actions on the State it is in.


* - Ben121 - Mar 17, 2014

You can replicate function pointers with lambdas or interfaces.


* - SIM-2015410 - Mar 17, 2014

(Mar 17, 2014 03:34 AM)Ben121 Wrote:  You can replicate function pointers with lambdas or interfaces.

You can only use lambdas if you are using java 8 🙂