Skip to main content
gamedev.net
🔒 Locked

Implementing base AI

Started by Nahrix 0 replies 1.4k views
Original Post
Nahrix
Nahrix
I'm working on my first project to aid me in development of programming skills. It's going to be a 2D simulation. What I need to know is how do implement very basic AI algorithms, such as movement, eating, hunting, etc, in such a manner that 'upgrading' the AI to advanced heuristics, genetic algorithms, neural networks, etc, will be seamless. As of now, I'm not even sure how to implement any form of pathfinding, such as using nodes, and as such, I need to start of small. The important thing, though, is keeping the doors open for adding functionality without large code rewrites. Thank you very much in advance for any input provided.
silmaril
silmaril
What I would do is first settle on which actions your agent should be able to make. Then how to represent those actions.

Once you've gotten that part down, I would make a base class/interface for sensory readings. After all this is what your agent will base your decisions on. More advanced decision making can take various internal states into account as well, but I would start with a purely reactive agent - responding only to what it senses right now.

Next you can make a general action function that takes in the sensory readings from the agent, and a list of possible actions and let that return the action to take next.

Since you talk about learning algorithms here, you would also need some way to give your agent information about how good the chosen action was. This could either be directly after your environment responds (supervised learning) or sometime later, as when your agent loses or wins the game (reinforcement learning). Depending on how your simulation is, you need to provide this feedback as well.

Using this approach, it should be possible to extend the structure to account for more advanced decision making (with internal states of various kind) later while still being able to implement simple algorithms to begin with. However, I am quite sure that's there something I didn't think of and that you will have to rewrite some interfaces :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.