0
\$\begingroup\$

I am designing a City-Runner game in Unity 3D Engine.I am a beginner in game development (not in programming). The idea is really simple, the Runner will be followed by AI enemies, and if caught by one of them it will be dead or his energy will decrease.

Anyway I cannot find any Algorithm for implementing a "smart" AI, in the sense that not only he will follow the player and do Path-finding to the player, but also get smarter from the first level to the second level.

Probably AI must store some information/state in regards to the terrain and the runner position.

My question here is :

  1. Is it a good idea to make the AI smarter (because all the runner does is running in a straight line, only the person who is playing the game can change his direction- left, right; so maybe its not like the learning will be very beneficial)

  2. If this is a good idea, do you have any knowledge on what algorithms may be used (implementing neural-nets or something alike)

  3. If it's not the best idea, what AI mechanism can I use expect of path-finding, wandering, seeking, flocking ??

Any kind of advice would be greatly appreciated !!

Thank you.

\$\endgroup\$
  • \$\begingroup\$ Can you give us a description or a picture of what your game looks & plays like? If it's similar to Temple Run or Subway Surfers mobile games then you probably don't need an AI at all. \$\endgroup\$ – Charanor Apr 22 '17 at 8:07
  • 1
    \$\begingroup\$ You need to think the other way around. Make the AI as smart as possible, then make it dumb by introducing mistakes to it. As the player progresses, the AI can become sell dumb as opposed to smarter. \$\endgroup\$ – John Hamilton Apr 22 '17 at 8:20
  • \$\begingroup\$ @Charanor yes it is similiar to the games you mentioned, but here I have the opponents that will threat the main character, for instance, on the second level the opponent figures out faster where the player is, than on the first level. Even though this can be hard-coded I would like for the opponents to have some learning within. \$\endgroup\$ – Kejsi Struga Apr 22 '17 at 9:06
2
\$\begingroup\$

As @JohnHamilton noted, the simplest way to implement this AI is to always have the "perfect" move. For example, if you were creating an FPS, the AI can find the exact vector to the player, and can precisely adjust for the time it takes for its attack to reach the player, and can calculate the required trajectory to compensate for intervening terrain....

For other types of games, the nature of these parameters may be different but the approach is the same. The AI has a lot more information about the world readily available than the player does. It "knows" exactly what move to make every time.

A "dumb" AI just chooses not to make that move sometimes.

\$\endgroup\$
0
\$\begingroup\$

Could you please make a screenshot, their movement and algorithm depend on the environment and gameplay style?

I bet it's good to pick a grid of points around player that are free, then calculate best destination for every enemy to catch player. But making this every frame could be overkill, so better put it in coroutine to calculate every second or so, make chosen grid big enough, but relatively to calculation time, pick the best points to go to for enemy, take into account players movement direction.

You can have Manager that records some amount of recent player moves and calculates next destination of the enemy, for example: left, left, right, left, right. Now every enemy gets it desired position depending on how the player moves, so algorithm predicts where the player would probably turn.

Make some bias value and put it into the algorithm, decrease it when level increases. If you want to use a neural network, you can do that, but I would suggest calculating values like bias while loading level, not on runtime, this way you could have more data stored.

You can use current player moves data (they are small like a queue of 10 elements) to put into your algorithm and also put the last move into the algorithm or pick it from the queue if there is a method for it, I guess there is only Peek().

But mostly algorithm will depend on different static values for this level. Like if the player risky, playing safe, trying to defend and all that stuff. You can even modify these values a bit on runtime. As I said I can't really propose any algorithm as I don't know anything about gameplay.

You have to take into account obstacles if you have them.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.