2D Game Dev – Part 13.3 – Finite State Machine Artificial Intelligence

This post is a portion of Part 13 in my on going series about 2D Game Development using the Allegro 5 library. These posts are in course order. You can see all of the posts in this course by clicking the “2D Game Development” button at the top of this site.

 


You’re all going to like this one. We can extend the concept of states to also include the behaviors of in game objects. Doing this is called Finite State Machine (FSM) Artificial Intelligence. Granted, we aren’t getting very deep into the concepts of AI in this video, and we are definitely stunted since we aren’t using OOP, but it is a good primer nonetheless. I hope you enjoy it as much as I enjoyed making it.

Full source can be found here.

Posted in 2D Game Dev, Allegro, C++, Code, Game Dev, Part 13, Tutorial
7 Comments » for 2D Game Dev – Part 13.3 – Finite State Machine Artificial Intelligence
  1. sparksplur says:

    I loved this tutorial it was awesome i cant wait to try to impliment that into the game im doing and maybe even during the IDLE state create a idolThreshold so that the enemy could lets say walk in a random angled y and x for a small threshold
    yay excited!
    thanks again for this

    • sparksplur says:

      k so my brain officially hurts (probably because ive gone through all the 2d and OOP devel lessons in 5 days .. but! lol.. i cant figure out how to make the enemy box walk in a random direction in a smaller threshold until the player enters the chasing threshold.. please help

  2. Zepher77 says:

    Really awesome tutorial, thanks for this as I’ve learned alot. Now I’m just studying everything over.

    @sparksplur
    don’t rush the videos or you won’t really learn anything. Its not about getting everything done now but in time. Trust me, I rushed this stuff before and gave up on programming cause I couldn’t get things done. Btw you should try to implement code in a similar way but differently if you can.

    back on topic, great examples and I’m glad to have made it through. Though the math throws me off just a bit since I havent been to college yet due to it being full. I sucked at math cause my teacher never helped the right way. But I guess I can improve, some guy at a starbucks learned calculus on his on :)

  3. Thomas says:

    Great video, cant wait to code some heat seeking missiles with this :D

    I originally voted ’3D game development’ for your next series, but after watching this I am definately voting for some more AI instead!

  4. Zack Mayoh says:

    One question about the enemy following algorithm:

    If you are above and to the right of the enemy at what I think is about a 45 degree angle, he seems to go faster than at any other angle. Do you know why this is?

  5. Cody says:

    the math just takes time, like the programming lol. the best tool you have is flow charts and pseudocode. just sayin’

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • I think I am going to use the word "chortling" instead of laughing from now on. 16 hours ago
  • Only 78 more assignments to grade! 1 day ago
  • RT @_matthewBowen: Final thoughts on Apple and the IPhone for an essay I submitted today. Not a hater, just a realist. http://t.co/tTyXQhM6 1 day ago
  • I know I joke a lot and say bad things about my students, but I really have a lot of good ones. Now get back to work you ingrates. 1 day ago
  • RT @TrocarRogue: My 14 yr old daughter, Kayla Bolin, disappeared morning of 5/7 in Lodi, CA. Call Lodi PD w/ info: 209-333-6727. Pls RT! ... 2 days ago