- how to make computer chose from random values?
- how to make artificial intelligence?
how to make artificial intelligent enemies?
- Random variables are created like this:
Do = Random(x) to variable MyVariable
Where x is the range you want. e.g.
Do = Random(10) to variable MyVariable
You can then use conditions to choose things from this values.
MyVariable = 0 || Create object tank
MyVariable = 1 || Create object marine
If you ask something more specific, you might get an answer more suited to what you want to do.
- Artificial intelligence is an entire field of scientific study. You need to ask a much more specific question such as “How to make pacman ghosts?” or “How to make AI tanks?” to get any kind of useful answer.
ok what i want to know is how to make an enemy to have mind of it’s own. not too intelligence but can decide to attack and chase the hero\player\character you are playing with, get alert when he is near and can chose from different attacks animation, like prefer the one that damages more. and if have one attack animation only then chose to attack time to time not consistence all the time.
You need to be much more specific. What is the game genre that you are making the AI for? What is the gameplay like? What you described is a very generic enemy and you won’t get very useful answers about what code to write. A screenshot or video of your game would help a lot in answering your question.
Hi, just updated the title
As Mats said, AI can be complex, with a lot of variations. We can’t be very specific with the given information, but there can be general rules that you could try to achieve your own AI.
A good AI system can be performed through the “finite-state machine”. Here, the states are “Quite”, “Alert”, “Chase” and “Attack”, maybe with some extra states as “Between Attacks”.
The finite-state machine should be common to every game style (top-down, platform, RTS, etc.), the difference between one game style and another would be the way you make the logic to decide what to do in each state and when to switch the state.
In a top-down game style, your AI would start “Quiet”:
While “Quiet” check the distance between the player and AI, if distance < 100, change state to “Chase”.
While on “Chase”, if distance > 150, change state to “Alert”, if distance < 20, change state to “Attack”, and so on.
Hope it helps, if you give us more information, we can help more
right not i am making the animation, it would be done sooner. but getting very curious every second. my game genre is action\superhero like superman!!! and i don’t think i need anything too complex just simple. I kinda have a few ideas about the events i can create for my purpose. so i know it will b simple. but need a little help. like this big villain (not every enemy) needs to block the hero attack once in a while or something. so it will be something like
condition: attack variable is >0
action: (it would be something like this) do = 1 to the variable of villianblock of ogre. once in a while
all these enemies need to be alert when the character is around. follow him and attack.
it is a platformer game
my game is not a platformer and i am also trying to get random values but if you have a look at my project it will answer alot of questions on how you can use variables to make evemys decide what to do my game will soon have enemys making their own mind which way the want to turn every 3 seconds its not fully complete and working yet but you will get the idea on how things work
Tank Commander.rar (1.09 MB)
Would you mind if I use this game as an example to make an AI tutorial with for Youtube?
feel free once i have a few things properly working i will be making some tutorials myself use this Tank Commander as some bugs are fixed, please send me a link to the tutorial once done.
Tank Commander.rar (2.06 MB)