A question about having very complex AI in a game

I have nearly no programming or blueprint experience, so please feel free to oversimplify your response. Also, the case may be that I am asking the wrong question, because I’m confused about something to do with AI.

Before I get to my questions, I want to say that I realize that actually making this game/simulation would be a massive undertaking. These questions are hypothetical, I am simply trying to understand some questions I have about programming/blueprinting and AI.

A description of the Game/Simulation:
The game is more of a simulation of a bunch of creatures on an island, and you play as a creature, and try to survive. On this island are maybe 1,000 creatures, which all are run by an AI system. They interact with each other and the environment whether or not you are nearby. They would have various types of attributes and abilities, some of which would affect their AI. They would (in no particular order) search for food, die, fight each other, have offspring, sleep, build nests, etc. - all of these actions and interactions would be controlled by the AI system, and kept track of.

Creating the AI would be a complex task because it would be kind of procedural. I mean there would be a large number of segments of code that would only ever be used if it applied to that creature. Like if the creature had claws, it could claw things and dig. If it had wings it could fly. I wouldn’t write a separate type of code for every possible combination of abilities and attributes, instead, when there was a new creature, it would load various interchangeable snippets of code that

As I said, you could play a creature, where you try to survive among the AI creatures. You could also set up the environment from the start how you wanted, and alter the type of beginning creatures, so how the simulation plays out would be different each time.

My questions: (If your answer is “It depends on how well it is optimized”, please note that doesn’t really give me any usable info. If possible, instead assume it is fairly well optimized. Or perhaps describe how quickly things could go wrong if it isn’t optimized enough. Or describe just how involved it would be to optimize it. Anything other than just “It depends”)

  • If you had to take a guess, which of these two things would be the biggest hurdle to making this game, and how much more of a hurdle is it than the other? : 1. Having 1,000 AI run simultaneously, or 2. Writing a procedural/segmented type of AI that would actually work with any type of creature?

  • What part of a computer would be taxed by having to simulate a large amount of AI running through decisions and interacting with each other and the environment?

  • If the AI is fairly well optimized, is there any reason that having 1,000 AI running at once would cause problems or make this idea impossible? Keep in mind you would not have to see all the AI at once, as you would be playing as a creature in first or third person view.

^— If the answer is no, can you make a guess as to how many AI you could have? (I realize that the answer will largely depend on just how complex each AI is, so if you want to answer this maybe you could give a example.)

^---- If the answer is yes, can you explain why? Also, this would confuse me some, or seem unintuitive to me, because it seems like the ability for computers to handle other parts of games have gotten wildly more complex over the years, it seems like this shouldn’t be a gargantuan task. So if it is, how might I be looking at this wrong?

Ok, those are my questions. As I mentioned in the beginning, some of these questions may put on display my lack of understanding of programming, and may just be the wrong question all together. If that’s the case, feel free to point out what I should be asking or thinking about, and why what I asked may be the wrong question.

Thank you in advance!

Hey OldAccount29 :cool:

  • For the First Q:
    I would pick two, and I can pick 1 in one case, having the AI spawn only around a predefined distance to player to get better performance.
    you need to think this way when you design your game, the player will in no way interact with 1000 AI at the same time! otherwise you are building your game for a super genius aliens! silly but its true even those who like open-world games where you have freedom to do whatever you want will get bored if there is no missions or task you have to do to make it challenging. If you ever played games like Mafia, MafiaII or GTA series, the buildings around you are not all accessible and still these games are so successful and have a touching story “for mafia and mafiaII” that made their success and they built the levels based on that story. and even if the buildings are, players will not visit them all and insect them all, it would be a waste of effort for developers. instead they made key building and some additional buildings like a clothes store or gym etc…
    even though buildings are not AI, but you get the picture, why spawn 1000 or even 100 AI when player can see only 10 or max 20 AI in his forward direction and fewer around him?
    Also for the second pick it is easier because you can make base creature and have little variety for every species. and then identify like hunger/attack animations and can fly or not for each…

2nd Q:
By ignoring graphics I would say mainly CPU and then “not sure but” I think RAM.

3rd Q: I think my first answer gave you a hit about what I am going to say here, It is not a matter of number even if it is well optimized, but why would you waste your client/player resources on things they don’t even see? i.e. care about? like I mentioned there is no need to design each building interior in a street when your player won’t even have the time to get into each of them and only will drive through that street to get to the mission?
And for your Idea it is not as much of complexity issue as it is for the for the creativity, the ease of unreal engine blueprints and behavior trees “the main AI part in UE4” is easier than you think to get along, most behaviors for AI’s will be the same, the diffrence will be in attributes, how much damage per hit or running speed or…

AI uses tick event, and in case you don’t know what tick event is it is event that runs every X frames, ideally every frame but for AI you can define it like every 0.2 second or so. These events what takes your CPU and you would use them on stuff that keeps updating throughout the game, and using it too much on AI is just too expensive for the user.

I hope you get my points and if there are any other questions or points you want to discuss feel free to do so!

Galaxyman92, thank you very much for your response!

You confirmed a lot of what I guessed to be the case with stuff.

You asked why bother having so many AI, and I get that. I realize that just playing as a creature that having a massive simulation is not going to make much of a difference to a player usually, so its a massive waste of resources that could be spent adding something that has a much more noticeable impact on player enjoyment. The reason why I even ask is that I am actually more interested in building a simulation of evolution. That is as or more important then having a playable animal character to me. So let me rephrase my question a little, given the new info you have shared with me…

This simulation game is along the lines of what I want. (quite a few differences as well though.)

^-- My simulation, if I made it how I would like to, would have AI that is much more complex than the example I linked to. But the fun of it would largely come from playing out simulations, and manipulating the outcome. For this, if I faked the simulation, then it wouldnt work the same. Now, if possible, I would like to be able to play as a creature and be actively involved in the simulation, but its not a must.

Focusing just on the simulation aspect, I don’t even care if people find it fun for the moment, and I am prioritizing (for the sake of this question) the full simulation of these creatures. They don’t have to visually be rendered, just the AI of each creature must be ran. Is there any information you can give me on this or places to look?** Here is kind of a stream of thought of some questions I have… maybe it’ll give you an idea of some information that might help me. Just throw out any thoughts you have related to this that you think might help me!:
**

  • If I just had the simulation of the AI, with graphics that look like space invaders and no playable characters, how many calculations could a normal computer before it ran into problems? I am sure that if I could guesstimate how many calculations/orders each AI creature would be performing each minute or something it would be very useful to this.
  • How many (Operations? Commands? Orders?) for the AI can be computed per second on an average computer before it runs into problems?
  • Is there any games that have pushed these limits?
  • It seems like most games (assuming they are reasonably well optimized) tend to slow down due to graphics and like physics maybe (because, as you said, its usually pointless to run a vast simulation that can be believably faked with more control anyways).
  • What about something like a chess program calculating moves, is that similar enough that I could make an educated guess about how many AI I could have running simultaneously?

**-The biggest question I have with all of this might actually be much simpler: ** Is this even a concern at all? Am I going to run into a mass of other problems long before AI calculations for the AI become taxing on a modern computer? Could I have 5 or 10 thousand AI? If thats the case, Then i am asking the wrong question. If I knew I could have 10,000 AI creatures (without rendering graphics or anything) running in a simulation (I am guessing I cant) then I would no longer even think about it. I would be concerned about making animations, and a complex AI system, and a bunch of other things.

Ok thank you again for your response… And anyone else, feel free to chime in! You don’t have to directly answer one of my questions to be very helpful to me!

You said here you don’t care about graphics, and mention like space invaders. But, you want huge numbers of AI.

Really, you are probably best making a plain application, in C++, LISP, or what ever is the favorite language of the programmer you hire to build your simulation for you. Spend your time making a complete design for all the interactions etc. and then hire a programmer to make it for you.

Otherwise. Start reading AI books and/or take some online AI Programming classes. But, if you don’t care about graphics, you don’t need UE4.

About the graphics:
I’m sorry, that was accidentally a bit misleading, on my part.

  1. When I said I don’t care about graphics I meant ignore graphics for the question I was asking: How many AI calculations can a normal computer run before it slows down or crashes? If I actually make this I would want some graphics to view the number crunching behind the scenes.
  2. These questions are at the moment about a hypothetical game that I may never make. I AM very interested in eventually making this game, but the questions have the intent of helping me understand how AI work and what constraints AI have, and what is or isn’t feasible, so regardless of if I make the game, the answers to my questions are of interest to me.
  3. I know I haven’t explained everything super well, and its convoluted but that is mostly because I am willing to change my plans based on feasibility, but I just don’t know what is and is not feasible.
  4. There are kind of two separate aspects of my idea that COULD be two entirely separate and unrelated games (1. A pure simulation of creatures evolving. 2. A game like Spore where you control a creature ina natural environment, but without any kind of deep AI in the background, just basic AI for nearby animals. ) What I want to do is take from both the ideas at least somewhat. And if I had no restraints and a team of people I would blend them both to make one massive complex game. Since I can’t do that, I’m trying to figure out which features to scrap due to various constraints (money, time, knowledge…) while also keeping it enjoyable to play, and a cohesive experience. (I think Ill ask some of these questions again in a few months after I have learned more, and Im able to understand more)

That is definitely a very interesting possibility. I don’t currently know any programming to speak of, although I am learning the very basics of C++ at the moment. You are saying just set up all of the pieces and how they would work together, then have someone translate that into actual code, right? I know so little that even though you were clear I don’t totally understand what you, but I get your basic meaning.

Thank you again for your reply! I kinda got burnt out while I was typing this, I meant to shorten and clarify it, but I’m too tired now. I think its fairly readable though.

There is absolutely no way to say how many “AI Calculations” a normal computer can handle. AI can be as simple as an if statement and doing 1 thing based on 1 input to very complex to anywhere in between. That’s on you, the developer. AI is always custom, there’s no general plug in solution at present.

This is a great resource that may help you:

Hello Again!
I would agree with mikepurvis last post, and add to that:

From what I get and the video you linked, the AI won’t be a concern, actually that game AI isn’t that complex and you can add to that. If I were you I would not worry about that, For a start I wouldn’t think about this rather than learning actually how AI works and try to do simple AIs then go on from that… you will notice your limits as you progress and overcome them based on that.
and the site added got a full free series of leasons about AI regardless of engine, just how to design and work AI.
http://courses.nucl.ai/courses/pmgai/

Thanks for that. I’ll check it out! I need to learn more about AI as well.

The modular parts that would compose an “animal” are relatively easy to code in. The wings part would provide the flying code, the prehensile tail part would provide the ability to manipulate objects and easier climbing skills, etc. The parts themselves would contain the code that allowed the Owner to do certain things. This approach does take the AI out of the equation and brings it into modular components or objects. It is a lot like making a health component that would provide health and damages to the Owner.