Welcome, Guest. Please login or register.

Pages: [1]
Print
Author Topic: NPC AI (combat)  (Read 4141 times)
zenbitz
Moderator
Community member

Posts: 1164



View Profile
« on: June 26, 2009, 01:25:00 AM »

This is not quite a proposal, but it came up in another thread, I remembered I had some notes jotted down:
Yay pseudocode!

= Heuristic Combat AI Thoughts =

* AI needs to recognize and balance needs of the "team" vs. needs of the individual.

* "Enemy" AI should probably start with full info of PC / 3rd NPC side, it's much easier to dumb down a too smart AI than to smart it up.  So Enemy NPCs all have perfect perception and evaluation of PC team.  PC gets a human brain.

* Multi-sided battles can be decomposed into 2-sided battles.  Exactly how, I don't know, but generally Enemies should avoid getting 3rd-party neutrals involved unless they are insignificant.

Rough hierarchy:

check_flee()
check_surrender()
// side will always choose flee over surrender if feasible.  Will almost always choose surrender over certain death.
// if both these checks fail, then 2 sides are fighting.
// It would be cool, but hard to have an NPC side decide that it wants to flee - but can't and must fight it's way out.  This could cause AI to make different tactical choice than just kill.  Perhaps both of the above could be subsumed in a define_objectives() call where the result is: survive, escape, kill.
while(still_fighting()):
    calculate_numerical_advantage() // Do I have numerical superiority
    calculate_qualitative_advantage() // At what ranges is my side superior.  Note that a "mixed" result is possible where some team members may need to get in close, while others should stay back
    generate_moves(N) // Pick some smallish (5) numbers of moves from this position.  Generally, this would be the top N moves given objective, and the results of the two calculate_x_advantage.  This is where "lay of the land" comes in.
    for(depth):
        evaluate_probable_counter_moves(N moves) // for each of N, switch sides and evaluate counters.  This can be recursive to x=depth times, but will quickly explode.
    make_best_move() // from above counters and counter-counters.
   
   
   
     
Logged

We are not denying them an ending...
We are denying them a DISNEY ending - Icelus
tZee
Community member

Posts: 190


View Profile Email
« Reply #1 on: June 26, 2009, 09:14:08 AM »

I like the strategy idea.

Hmm.. about the morale: I think it should be decided for every individual actor whether his morale breaks and he runs in fear - or not.
The strategy should be decided by a leader, there is not enough time in a combat to decide on a strategy in a democratic system. (Troops of 3+ always have 1 leader/decider, AFAIK)
Therefore: A leader boosts the groups morale, a leader decides on strategies for the whole group.
If there is no leader there group is unorganized. Individuals are more likely to flee and each individual does what he thinks is best.

I'd like the reputation thing to influence the combat as well. If you are known for killing your enemies when they flee from you in defeat they will probably rather surrender than flee. If you're known to kill enemies that surrendered then they'll still try to flee.

I don't like the generic "everyone in the world knows your exact reputation and you can see it in numeric values in your stats screen", though. I prefer to simulate a spreading reputation by word of mouth.
Maybe we can assign every item a "recognizability" value which determines how out-of-the-ordinary it is. The sum of all values of the items you are wearing defines how likely people are to recognize you on first sight. That way you can try to camouflage yourself, se they just don't recognize you.
Logged

shevegen
Community member

Posts: 705



View Profile
« Reply #2 on: June 26, 2009, 01:33:03 PM »

Quote
I'd like the reputation thing to influence the combat as well. If you are known for killing your enemies when they flee from you in defeat they will probably rather surrender than flee. If you're known to kill enemies that surrendered then they'll still try to flee.

Sounds good, I only want to add one thing. Reputation builds up slowly, by hearsay, gossip etc... Sometimes it is also impossible to find out who is who, just think of combat at night time... would anyone realize his enemy is Jack the Ripper in near total darkness? If he sees who this guy is, and heard stories of his actions, then I agree though that this should influence the NPC where he decides what to do (fleeing or fighting)

I believe fleeing in most situations - if possible - is the easier thing to do for a NPC. Surrendering should be rare, but I agree that reputation should play a factor in this.
Logged

Cleaning away the bureaucracy in PARPG to make our life easier.
zenbitz
Moderator
Community member

Posts: 1164



View Profile
« Reply #3 on: June 26, 2009, 04:29:23 PM »

Morale is implicit - if people think they are going to lose or get killed they will run away...  I guess we should have a "fanaticism" trait or stat which could partially or completely override surrender/survival reflex.

My ideas for leader ship right now are having "leadership" and "tactics" be skills which inluence the above (generalized) "morale" checks, as well as their accuracy.    One simple way to incorporate leadership of a group is to just use the "best" leadership and tactics skills of the remaining (conscious) opponents.

Note that morale and leadership I would like to apply to NPC _party_ members too...they should not be mindless fanatic slaves of the PC.

As for reputation... still another thread guys!  I think we should start by coding in a "speed of rumor" (although it's been postulated that this is faster than the speed of light...) for which the PC/Party's rep propagates through the game.  Other thoughts were to consider all the NPCs in the game as a Network (graph) with "connection strengths"  and the rumor mill/reputation factory/word fame would spread naturally through the graph (rather than a simpler approach of a point rumor source that spreads in an ever expanding sphere.  Or rather, "circle" in a 2D game)
Logged

We are not denying them an ending...
We are denying them a DISNEY ending - Icelus
Pages: [1]
Print
Jump to: