Jump to content

  • Log In with Google      Sign In   
  • Create Account


How would you do AI for this?


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
12 replies to this topic

#1 slicer4ever   Crossbones+   -  Reputation: 3398

Like
0Likes
Like

Posted 16 January 2012 - 11:45 AM

hello all, i'm having a problem with figuring out how to appoach ai for the game i'm making.

basically, the battle system is a real time version of final fantasy tatics turn based system, only battled with creatures instead of people, and where stamina/Mana governs how creatures can attack/move.

here's a video of an earlier build of me fighting myself.



anyway, i just don't know where to begin with in terms of ai, it's all going to be scripted in lua so i can do things with unique npc's, but the most i can come up with is checking each action a creature the npc controls can do against another creature. and factoring a number to see how it affects(this number can be partially controlled by the action's own scripting.) and eventually choosing the highest action factored. also, as you can see, you can avoid attacks by moving away before they hit, i'd like to approach this as well.

but i also need to figure out how to factor in movement to other spaces and such.

in short, looking at the basic mechanics in the video, i'd like to hear how people would implement ai in this game.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

Sponsor:

#2 Benholio   Members   -  Reputation: 129

Like
4Likes
Like

Posted 17 January 2012 - 09:58 AM

The method you are describing uses a utility function to decide the next move. It is a totally valid approach in your situation. You can find some information on implementing such a system by searching around by the name, or checking out this book by the resident utility-master Dave Mark: http://www.amazon.com/Behavioral-Mathematics-Game-Dave-Mark/dp/1584506849

I would probably write a simple finite state machine or behavior tree that then uses utility functions like you described to drive the transitions from one state to another. Check out some of the sites in the stickied resource thread if you want to learn more about those methods!

#3 IADaveMark   Moderators   -  Reputation: 2401

Like
0Likes
Like

Posted 19 January 2012 - 03:53 PM

The method you are describing uses a utility function to decide the next move. It is a totally valid approach in your situation. You can find some information on implementing such a system by searching around by the name, or checking out this book by the resident utility-master Dave Mark: http://www.amazon.co...k/dp/1584506849

I would probably write a simple finite state machine or behavior tree that then uses utility functions like you described to drive the transitions from one state to another. Check out some of the sites in the stickied resource thread if you want to learn more about those methods!


What he said.
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC

Professional consultant on game AI, mathematical modeling, simulation modeling
Co-advisor of the GDC AI Summit
Co-founder of the AI Game Programmers Guild
Author of the book, Behavioral Mathematics for Game AI

Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

#4 xByteCode   Members   -  Reputation: 104

Like
2Likes
Like

Posted 23 January 2012 - 10:35 AM

The method you are describing uses a utility function to decide the next move. It is a totally valid approach in your situation. You can find some information on implementing such a system by searching around by the name, or checking out this book by the resident utility-master Dave Mark: http://www.amazon.co...k/dp/1584506849

I would probably write a simple finite state machine or behavior tree that then uses utility functions like you described to drive the transitions from one state to another. Check out some of the sites in the stickied resource thread if you want to learn more about those methods!


That is an excellent book, without a doubt and is a highly recommended read for anyone looking into game AI. But Behavioral Mathematics for Game AI is more about the theory of behavioral mechanics. It sound as though this game would be a perfect canidate for a combination of Finite State Machines and Fuzzy Logic. FSM is a fairly simple AI mechanic, but Fuzzy Logic is a bit more in depth and deals with probabilities. I recommend "Programming Game AI by Example, by Mat Buckland". He provides an excellent implementation of Fuzzy Logic in his book, plus much, much more :)

http://www.amazon.com/Programming-Game-Example-Mat-Buckland/dp/1556220782/ref=sr_1_1?s=books&ie=UTF8&qid=1327336093&sr=1-1

#5 IADaveMark   Moderators   -  Reputation: 2401

Like
0Likes
Like

Posted 23 January 2012 - 01:01 PM

Fuzzy logic is utility theory in a different light. And considering that my book is almost entirely about utility theory, you can see the overlap.

That said, Mat's book is great for learning how to do all the different AI techniques such as FSM. However, note that an FSM doesn't decide anything for you. It is an architecture, not a reasoner. The OP didn't want to know about an architecture for representing/storing what he is doing now (e.g. a FSM) but rather suggestions on a reasoner about what to do next.
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC

Professional consultant on game AI, mathematical modeling, simulation modeling
Co-advisor of the GDC AI Summit
Co-founder of the AI Game Programmers Guild
Author of the book, Behavioral Mathematics for Game AI

Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

#6 xByteCode   Members   -  Reputation: 104

Like
1Likes
Like

Posted 23 January 2012 - 01:47 PM

In my opinion, that is what fuzzy logic would help the AI controlled character determine. Based on what the player is doing "now", fuzzy logic can return a weighted value as to what the AI should do next. If the player is, say shooting a lighting ball at the AI, fuzzy logic can determine that the best thing to do next is to try and dodge the players lighting ball. With FSM, the AI can then switch to something like an Evade state in order to try and dodge the incoming attack.

Based on the video posted by the OP, this is how I would construct the AI, which is the reason I suggested this approach. In all honesty, I meant no disrespect, just merely trying to provide a direction in which the OP could take in designing the AI for his game.

#7 IADaveMark   Moderators   -  Reputation: 2401

Like
2Likes
Like

Posted 23 January 2012 - 07:34 PM

In my opinion, that is what fuzzy logic would help the AI controlled character determine. Based on what the player is doing "now", fuzzy logic can return a weighted value as to what the AI should do next. If the player is, say shooting a lighting ball at the AI, fuzzy logic can determine that the best thing to do next is to try and dodge the players lighting ball. With FSM, the AI can then switch to something like an Evade state in order to try and dodge the incoming attack.

Based on the video posted by the OP, this is how I would construct the AI, which is the reason I suggested this approach. In all honesty, I meant no disrespect, just merely trying to provide a direction in which the OP could take in designing the AI for his game.

No problem, you're on the right track... you are just enamored with the term "fuzzy logic", that's all. Utility theory is the practice of weighing things based on their pros and cons and deciding which gives the best "return on investment" so to speak. It's a much more flexible superset of fuzzy logic.

Also, the fact that probably 90% of all RTS and TBS AI uses utility theory in some form or another is a pretty solid recommendation. Posted Image
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC

Professional consultant on game AI, mathematical modeling, simulation modeling
Co-advisor of the GDC AI Summit
Co-founder of the AI Game Programmers Guild
Author of the book, Behavioral Mathematics for Game AI

Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

#8 slicer4ever   Crossbones+   -  Reputation: 3398

Like
0Likes
Like

Posted 25 January 2012 - 06:44 AM

thanks all for the input, i'm sorry it's been a little bit since i've responded, i haven't been able to do work on the ai at the moment, as i realized that the ai systems would benefit greatly by incorporating multi threading in my application, to allow my render, ai, and animation routines to be ran side by side, instead of one choking the other.

anyway, that's just about finished now, so, i can again focus on ai.

so, utility theory is the word i'm looking for, thank you for linking me to some book's on the subject, i think i'll purchase both, and gain a better understanding of how to approach ai in my current game, and future game's i work on.

thanks everyone, and if their's anymore input on the subject, i'd be much appreciated to hear more.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

#9 wodinoneeye   Members   -  Reputation: 721

Like
1Likes
Like

Posted 26 January 2012 - 02:44 AM

risk/reward analysis for the evaluations.

complexity may be significant when several moves/actions are required to carry out goals (and factors like facings and terrain blockage effect results)

'planners' might be useful as well as influence maps if multiple object interactions/coordinations are part of the game problem
--------------------------------------------Ratings are Opinion, not Fact

#10 IADaveMark   Moderators   -  Reputation: 2401

Like
0Likes
Like

Posted 26 January 2012 - 08:06 AM

risk/reward analysis for the evaluations.

complexity may be significant when several moves/actions are required to carry out goals (and factors like facings and terrain blockage effect results)

'planners' might be useful as well as influence maps if multiple object interactions/coordinations are part of the game problem

That about covers it. I planner would be an OK solution but might be a bit harder to pull off in Lua. Even then, you need to use the utility theory stuff to create the edge weights of your plan graph. Influence maps, as you mention, are very valuable here but really only if you have multi-unit things going on. Even then, influence maps are pretty much 2D grid-based utility in that they are combining the risk and reward factors into discrete values in space.

Still, all of those terms are very valuable to look up in this situation.
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC

Professional consultant on game AI, mathematical modeling, simulation modeling
Co-advisor of the GDC AI Summit
Co-founder of the AI Game Programmers Guild
Author of the book, Behavioral Mathematics for Game AI

Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

#11 wodinoneeye   Members   -  Reputation: 721

Like
0Likes
Like

Posted 26 January 2012 - 03:24 PM

The description I found in ( http://en.wikipedia.org/wiki/Final_fantasy_tactics ) mention multiturn involvement, what sounds like the need to sometimes concentrate fire to kill opposing units and area effect attacks. Definitely coordinating mutiple units movement and firing for best effect AND to deny the same to your enemy -- alot of combinatorics and including the unknowns of what your opponent does (exploding the possibilities further).

Methods of partial reevaluation would likely have a big payoff.

Lua I would assume allows you to write C/C++ functional code which for a planner and pathfinding would likely be needed to speed up the AI for this level of complexity. SInce its not a realtime game the time the user spends on input could be used to reevaluate the game situation.
--------------------------------------------Ratings are Opinion, not Fact

#12 IADaveMark   Moderators   -  Reputation: 2401

Like
0Likes
Like

Posted 26 January 2012 - 09:01 PM

Good point.
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC

Professional consultant on game AI, mathematical modeling, simulation modeling
Co-advisor of the GDC AI Summit
Co-founder of the AI Game Programmers Guild
Author of the book, Behavioral Mathematics for Game AI

Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

#13 slicer4ever   Crossbones+   -  Reputation: 3398

Like
0Likes
Like

Posted 09 March 2012 - 01:34 AM

hey guys, i just wanted to give an update on how it's coming along:



essentially it's a state machine for each player, and it subdivides long ai processing by spacing out alot of the checks over several frames. it's pretty decent for my needs, and puts up a nice fight. it also required a lot of involment from the action's scripts themselves to maintain what they are about to hit, and what tile's they could potentially hit(to avoid walking onto another tile that might be targeted.)

it also showed alot of bugs that i couldn't find myself due to lack of speed for input's(such as the sliding death at the end.), it's kindof interesting to see that it brings out alot of bugs in how the game handles things when the ai is unrestricted at how fast it can process and do things.

one suggestion by wodinoneeye is the coordination. doing this in real time means alot of spacing the algorithm across multiple steps. and keeping track of alot more data to weight in the need for multiple units striking the same unit. currently, the ai works on 1 unit at a time, and evaluates all the opponent's, it then takes each opponent, and checks to see what the least relative cost action it can perform(also looks up if combining movement/attack would cost less than an attack that could potentially hit the target from it's current position.)

it's not perfect, but fits my needs for now.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.




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