It could be part of the model because it's part of the business logic of the game.
It could be part of the controller because it could be seen as simulating player input, which would be considered part of the controller, right? Or would it?
What about a normal enemy, like a goomba in Mario?
UPDATE: Wow, that's really not the answer I was expecting. As far as I could tell, A.I. is an internal part of the autonomous game system, hence model. I'm still not convinced.
A controller is responsible for controlling the way that a user interacts with an MVC application. A controller contains the flow control logic for an ASP.NET MVC application. A controller determines what response to send back to a user when a user makes a browser request.
MVC (Model-View-Controller) is a pattern in software design commonly used to implement user interfaces, data, and controlling logic. It emphasizes a separation between the software's business logic and display. This "separation of concerns" provides for a better division of labor and improved maintenance.
MVC works very well as an architecture for a large number of applications. Some applications may find that MVC works well for the external interfaces, especially User Interfaces as part of a more complex architecture.
If you find yourself trying to "force fit" a problem into a pattern, it probably isn't the right pattern. Use MVC for the UI - use other patterns (Message Bus, or Observer/Listener, etc...) or other OO techniques for the AI (@Bill the Lizard's suggestion of Strategy still applies).
Use your entire toolbox - not just the hammer. ;-)
The enemy AI has a model - its intelligent innards that specify how to play the game - and it uses the controllers available to both human players and NPCs to manipulate its state in the game environment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With