Jump to content

  • Log In with Google      Sign In   
  • Create Account


Just a bit of info for newbie


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 Nathan2222_old   Members   -  Reputation: -400

Like
0Likes
Like

Posted 17 December 2013 - 02:52 PM

I'm still learning c++ but i just wanna get preliminary info on game AI.
Is AI really hard, like harder than coding c++. From what i've seen, AI is the code, i'm not sure.
Let's say i were to create gta style game, how hard will it be to code AI for the NPC's, enemies, cops (maybe animals, zombies). Will it be too hard or just involve a lot of coding.
Another question is on learning AI. For example, in that gta game you fail a mission (there may be no last checkpoint). You go about doing other missions and then you meet the guy that escaped in the mission you lost in another mission. Is it possible to make that guy (enemy) remember how you fought him i.e. he'll remember what weapons you used, the mistakes you made and the mistakes he made, when/who you called for backup (if you did) and he'll try not to make them again and exploit your mistakes.
Is it also possible to make learning AI for NPC's and police. For example, in that gta game, an NPC sees you killing/beating someone and he calls 911 and then the cops arrive and start chasing you, you manage to escape to your safe house. 2 days later that NPC sees you and recognises you then alerts the cops but u don't know he/she (the NPC) has alerted the cops. The cops learn that blowing their sirens chases you off so they come in an undercover vehicle (maybe a taxi) and catch you by surprise. In that case, both the NPC and cops learned from their mistakes.
(I'm not making a gta game now, not until i am experienced. Just used it as an example because it focuses on the game genre i like most).
I asked in another forum but didn't get enough opinions (only 1)

Thanks for the help.

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32
smile.png
--
GREAT QUOTES:
I can do ALL things through Christ - Jesus Christ
--
Logic will get you from A-Z, imagination gets you everywhere - Albert Einstein
--
The problems of the world cannot be solved by skeptics or cynics whose horizons are limited by the obvious realities. - John F. Kennedy


Sponsor:

#2 frob   Moderators   -  Reputation: 20514

Like
4Likes
Like

Posted 17 December 2013 - 03:15 PM


Is AI really hard, like harder than coding c++. From what i've seen, AI is the code, i'm not sure.

There are many steps to programming.  When you write code, what you are doing is taking an algorithm and explaining it to the computer.

 

You need to know how to solve the problem before you write a line of code. Even if solving the problem is breaking it down into smaller problems, you still must know your solution first. You must be able to explain the algorithm to another person or to a computer. If you cannot do that, how do you expect to explain it to the computer?

 

There are many advanced topics in artificial intelligence. Fortunately most games do not rely on them. Instead they rely on state machine trees and decision trees. State machines and decision trees have many useful features, including how programmers and designers can fine-tune them easily. 

 


Is it possible to make that guy (enemy) remember how you fought him

...

In that case, both the NPC and cops learned from their mistakes.

Yes. Adding a memory is a matter of recording the key details. It requires a little bit of space and a bit of code, but it can absolutely be done.

 

You might want to refine "learning" from their mistakes. You can look at the key details to see what to change on the next encounter, but whatever you can describe as an algorithm you can encode for the computer.

 

Many games do this already. The Sims immediately comes to mind where everyone in the town has memories that can include everyone else in the town. If you follow sims around you can see that they have their own little interactions, going to shops and school and having assorted positive and negative relationships with other sims.

 

 

This is why it is so important for programmers to take study of algorithms seriously. If you do not have a solid understanding of how things work you cannot solve complex problems.


Check out my personal indie blog at bryanwagstaff.com.

#3 Lactose!   GDNet+   -  Reputation: 3307

Like
2Likes
Like

Posted 17 December 2013 - 03:28 PM

AI essentially involves making the computer do some action to achieve some outcome.

This means you must know both what you want to achieve, and which actions should be done to get there. This might involve the AI having to choose between various possible actions, depending on varying states. E.g. check to see how much money the AI character has to decide whether to buy a rocket launcher or a baseball bat.

 

AI logic can be written in C++, or any other language that the game uses, even scripting languages (if supported). The main implementation issues are usually not (as far as I've noticed) language specific, but being able to actually describe all the states, conditions and actions possible.

 

AI can be extremely simple (like a super-simple card game, always draw a new card if your current hand is worth less than a certain amount), or insanely complex. This depends entirely on the game, and what the designer wants to achieve with the AI.

As an example, for a lot of games it's probably easier to make an unbeatable AI than AI that is fun to play against.

 

Regarding your questions of if this or that possible -- generally, if you can properly define exactly what you want to happen, the answer is yes - it is possible. In some cases it might be unrealistic to achieve, but that's a different topic.

 

AI that learns and alters its behavior dynamically is generally a lot more complex than AI which does not, and thus also more difficult to create.

---

EDIT: Plus the stuff frob said.


Edited by CoreLactose, 17 December 2013 - 03:28 PM.


#4 Nathan2222_old   Members   -  Reputation: -400

Like
0Likes
Like

Posted 17 December 2013 - 03:34 PM

You might want to refine "learning" from their mistakes.

Thanks. If by 'refine' you mean explain, i mean like the cops chase you and maybe you escape to your safe house or hide (like in nfsmw). Another time you get in a cop chase, they remember what you did, whether you were scared when they shot at you etc. then they rethink their strategies, maybe you escape. Say an NPC sees your wanted photo on a billboard and sees you on the road, the NPC calls the cops. The cops realise that a chase won't stop you and shooting won't scare you so maybe they come in an undercover vehicle like a taxi and you won't know they are cops. Most likely they will catch you by surprise. The cops 'learned' from the two previous events and got better strategies to catch you. I hope that's clear enough.
Say there were a lot more scenarios if you keep beating the cops. How hard/complex would coding it in c++ be in an open world game (i'll be using c++)

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32
smile.png
--
GREAT QUOTES:
I can do ALL things through Christ - Jesus Christ
--
Logic will get you from A-Z, imagination gets you everywhere - Albert Einstein
--
The problems of the world cannot be solved by skeptics or cynics whose horizons are limited by the obvious realities. - John F. Kennedy


#5 Nathan2222_old   Members   -  Reputation: -400

Like
0Likes
Like

Posted 17 December 2013 - 03:55 PM

Another example would be watchdogs. If you've watched the demo videos, you'll see that almost everytime the cops start chasing him, he hacks the road blocks and the cop cars crash into it or he causes a blackout (in all the videos i've seen). Learning in this case would be for the cops to drive at just the right speed so that when he hacks the road blocks, they are able to decelerate and not get killed or carry a torchlight so that whenever he causes another blackout, they are not stranded.
Do you get what i'm saying?

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32
smile.png
--
GREAT QUOTES:
I can do ALL things through Christ - Jesus Christ
--
Logic will get you from A-Z, imagination gets you everywhere - Albert Einstein
--
The problems of the world cannot be solved by skeptics or cynics whose horizons are limited by the obvious realities. - John F. Kennedy


#6 frob   Moderators   -  Reputation: 20514

Like
2Likes
Like

Posted 17 December 2013 - 05:29 PM

Yes, those things are possible. 

 

One option is for you to build a long list of possible things to change, and then adjust the behavior based on scripted rules. You (with your designer hat on) need to write those rules.  Then you (with your programmer hat on) need to write a system that runs the rules.  Then you (with a combination of designer hat and QA hat) need to tune these to be fun.

 

Another option is to make a long list of possible options and then use genetic algorithms to refine what happens over time; this is moderately complex and will require some significant work. These are difficult to fine-tune, but it can be done if the designer is very, very, very patient. Unfortunately it is difficult to make designer-friendly genetic algorithms.

 

Another option is to use some combination of reinforcement learning algorithms, which is even more complex than the two above. You could make an MDP but training it can be a pain and it is nearly impossible to fine-tune for fun game behavior. There are other algorithms out there that can produce ideal or near-ideal behavior but really are impossible for designers to manipulate.

 

 

Just beware that a perfect or ideal AI tends to make for bad games. Instead you want a system that allows for the player to struggle but ultimately win, and that can be adjusted for any skill level. Machine learning algorithms are usually a bad fit because often they can easily outmaneuver a human player.


Check out my personal indie blog at bryanwagstaff.com.

#7 Nathan2222_old   Members   -  Reputation: -400

Like
0Likes
Like

Posted 18 December 2013 - 12:59 AM

@frob: I'm guessing i'll need a lot of hats to make a game :).
From your first option, that's gonna be a really long list for most of my games. Hmm, maybe i should build ...
Will freeform NPC's + scripted NPC's work with this.

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32
smile.png
--
GREAT QUOTES:
I can do ALL things through Christ - Jesus Christ
--
Logic will get you from A-Z, imagination gets you everywhere - Albert Einstein
--
The problems of the world cannot be solved by skeptics or cynics whose horizons are limited by the obvious realities. - John F. Kennedy


#8 Rld_   Members   -  Reputation: 1385

Like
0Likes
Like

Posted 18 December 2013 - 03:02 AM

@frob: I'm guessing i'll need a lot of hats to make a game smile.png.
From your first option, that's gonna be a really long list for most of my games. Hmm, maybe i should build ...
Will freeform NPC's + scripted NPC's work with this.

 

If you're going to do this all by yourself, you'll be needing all the hats in all its different flavours and colors ;)

 

With freeform + scripted NPCs I am going to guess you mean NPCs that just wander around the level, but can also react to specific things. This is perfectly doable, the way I see it, it's just part of the scripted behaviour. Almost everything is possible I would say, but the more complex you want the AI to be, the more computing power it will take, the harder it will be to program, harder to tune etc.



#9 Nathan2222_old   Members   -  Reputation: -400

Like
0Likes
Like

Posted 18 December 2013 - 04:30 AM

@frob: I'm guessing i'll need a lot of hats to make a game :).
From your first option, that's gonna be a really long list for most of my games. Hmm, maybe i should build ...
Will freeform NPC's + scripted NPC's work with this.

 
If you're going to do this all by yourself, you'll be needing all the hats in all its different flavours and colors ;)
 
With freeform + scripted NPCs I am going to guess you mean NPCs that just wander around the level, but can also react to specific things. This is perfectly doable, the way I see it, it's just part of the scripted behaviour. Almost everything is possible I would say, but the more complex you want the AI to be, the more computing power it will take, the harder it will be to program, harder to tune etc.

Right now, i'm getting my programming hat (purchase still in progress . . .), my modelling hat is not fully painted so it's a 'hatty' future for me.

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32
smile.png
--
GREAT QUOTES:
I can do ALL things through Christ - Jesus Christ
--
Logic will get you from A-Z, imagination gets you everywhere - Albert Einstein
--
The problems of the world cannot be solved by skeptics or cynics whose horizons are limited by the obvious realities. - John F. Kennedy





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS