View previous topic - View next topic |
Author |
Message |
Captain Vimes Grumble Teddy
Joined: 12 May 2006 Posts: 225 Location: The City Streets
|
Posted: Mon May 22, 2006 3:09 pm Post subject: Strategic A.I. Programming |
[quote] |
|
In addition to working on Mysilin (which is going very slowly), I am working on another game outside of RPGDX. However, this game requires strategic AI programming, in which I am totally lost. Does anyone know how to do this, and could you give me some pointers?
In case it matters, it's a game that takes place in a small city, with two teams of several people each, basically trying to kill each other by any means possible. They can use the buildings and stuff in the streets as cover. I doubt it really matters, but in case it does... _________________ "Sometimes it is better to light a flamethrower than to curse the darkness."
- Terry Pratchett
|
|
Back to top |
|
|
RuneLancer Mage
Joined: 17 Jun 2005 Posts: 441
|
Posted: Mon May 22, 2006 6:05 pm Post subject: |
[quote] |
|
It depends a bit on what you mean by AI. I'm going to assume you're not throwing about a trendy buzzword and mean the actual CPU vs player mechanisms of your game.
Is this turn-based, or real-time à la Starcraft? There's a massive difference here.
Turn-based games will often look at every resource available, every unit in place, and every move it can make, and pick the one which performs best (using a scoring system of sorts; ie, a move that takes out 3 enemies is worth 300 pts, one that takes out 2 AND keeps the unit out of range of the remaining units is worth 315 pts, etc. just examples...)
Real-time games will set itself goals instead of micro-managing each unit. For instance, you're attacking with 20 light infantry units, it'll decide to assign 5 light infantry and 15 heavy infantry units to push back the assault. Some AIs often have hard-coded (yet flexible) strategies, such as "build the important buildings first, then send out units to scout while everyone else builds up the base and the army; send a large amount of troops if the enemy is found.) _________________ Endless Saga
An OpenGL RPG in the making. Now with new hosting!
|
|
Back to top |
|
|
Nephilim Mage
Joined: 20 Jun 2002 Posts: 414
|
Posted: Mon May 22, 2006 7:12 pm Post subject: |
[quote] |
|
As RuneLancer mentioned, computer AI almost always boils down to assigning possible moves a fitness function, and then choosing the move that has the highest value of that fitness function (or randomizing among some range of values in the fitness function for some fuzziness of strategy or dumbing-down the AI). Long-term strategies can be implemented as a series of staged fitness functions.
That's usually the easy part. The hard parts are:
* Figuring out good strategies and their fitness function stages.
* Coordinating strategies of multiple units.
* Resolving conflicts between multiple units' goals.
* Depending on the game, culling possible options down to a reasonable number, so you're not having to test millions of possibilities each turn.
* Look-ahead
If your game is tile-based, that will help a lot, since you have discrete locations on the game map AND you can store "influence map" information fairly cleanly about each location. _________________ Visit the Sacraments web site to play the game and read articles about its development.
|
|
Back to top |
|
|
Captain Vimes Grumble Teddy
Joined: 12 May 2006 Posts: 225 Location: The City Streets
|
Posted: Tue May 23, 2006 9:58 pm Post subject: |
[quote] |
|
Thanks guys. Any examples? That would really help. _________________ "Sometimes it is better to light a flamethrower than to curse the darkness."
- Terry Pratchett
|
|
Back to top |
|
|
RuneLancer Mage
Joined: 17 Jun 2005 Posts: 441
|
Posted: Wed May 24, 2006 9:51 pm Post subject: |
[quote] |
|
Not really. No two strategy games follow the same rules, so at best a brief overview like Nephilim and I have posted is all you could hope to rely on until you come up with something a little more specific...
You might want to start by looking into A* pathfinding, though. Having units navigating intelligently around objects to reach a specific goal is a big first step. The next big step would be determining which conditions would cause these goals to come into being, and what the goals would be.
The best example I can think of that wouldn't be game-specific is a chase scenario. The computer could attempt to pick the shortest path towards the player at all times (though since it would be unfeasible to do A* path-finding with 100+ units in real-time each frame, you'd have to limit it to discrete "waypoints" and implant a timeout if the target is too far away.)
Alternatively, a unit could look for the closest waypoint to the player and only recalculate its path when its targetted waypoint changes, or head straight for the player once it's close enough.
Then you'd have to consider look-ahead cases in order to make the AI smarter and attempt to intercept the target instead of rushing towards it.
Of course this is nothing compared to a strategy game where different units have different purposes. _________________ Endless Saga
An OpenGL RPG in the making. Now with new hosting!
|
|
Back to top |
|
|
Captain Vimes Grumble Teddy
Joined: 12 May 2006 Posts: 225 Location: The City Streets
|
Posted: Sat May 27, 2006 12:45 am Post subject: |
[quote] |
|
Well, I've never did any pathfinding either and I have no idea what A* means. Definitions, please! _________________ "Sometimes it is better to light a flamethrower than to curse the darkness."
- Terry Pratchett
|
|
Back to top |
|
|
LeoDraco Demon Hunter
Joined: 24 Jun 2003 Posts: 584 Location: Riverside, South Cali
|
Posted: Sat May 27, 2006 2:00 am Post subject: |
[quote] |
|
(Not to sound like an asshole, or anything, but less than five minutes worth of searching for either "pathfinding" or "a* algorithm" in either google or wikipedia would net you answers to your questions without you having to ask us about it.)
Pathfinding (in case you known nothing about it); A* Search.
The important thing to note about A*: it is a graph/tree searching algorithm (and thus requires your game states to be representable by a graph or tree) which selectively determines an optimal (not necessarily globally optimal) state to move into, based upon assigning each potential next state a fitness value, which, in turn, is determined by a combination of a breadth first search and the heuristic estimate of the next state. _________________ "...LeoDraco is a pompus git..." -- Mandrake
|
|
Back to top |
|
|
Captain Vimes Grumble Teddy
Joined: 12 May 2006 Posts: 225 Location: The City Streets
|
Posted: Sat May 27, 2006 9:22 pm Post subject: |
[quote] |
|
I have already Googled and Wikied both these topics. It said "The page cannot be displayed" for Wiki's A* and on Google. I knew the definition of pathfinding already, but had no idea how to do it, and the problem with most sites is that they will tell you the theory but give you nothing else... besides this is my dad's connection and I'm only allowed to stay on for about 10 minutes at a time and as such can't check every Google search result... _________________ "Sometimes it is better to light a flamethrower than to curse the darkness."
- Terry Pratchett
|
|
Back to top |
|
|
RuneLancer Mage
Joined: 17 Jun 2005 Posts: 441
|
Posted: Sat May 27, 2006 9:29 pm Post subject: |
[quote] |
|
Maestro134 wrote: | I knew the definition of pathfinding already, but had no idea how to do it, and the problem with most sites is that they will tell you the theory but give you nothing else... |
Sometimes you're required to do a little bit of work in the field of game developement, and won't be given out source code freely.
Googling for "A* Pathfinding" gave me a very detailled introduction to A* which is more than enough for anyone to write their own implementation. Turns out it was the first result, too. _________________ Endless Saga
An OpenGL RPG in the making. Now with new hosting!
|
|
Back to top |
|
|
Captain Vimes Grumble Teddy
Joined: 12 May 2006 Posts: 225 Location: The City Streets
|
Posted: Tue May 30, 2006 3:38 pm Post subject: |
[quote] |
|
Whee! Finally! Thanks man! Funny, though, that didn't show up on my Google search... Hmm. _________________ "Sometimes it is better to light a flamethrower than to curse the darkness."
- Terry Pratchett
|
|
Back to top |
|
|
Nodtveidt Demon Hunter
Joined: 11 Nov 2002 Posts: 786 Location: Camuy, PR
|
Posted: Sat Jun 03, 2006 2:57 am Post subject: |
[quote] |
|
Google has been getting a lot more localized as of late, so what the #1 search is for some may not be for others. It's getting confusing. :( _________________ If you play a Microsoft CD backwards you can hear demonic voices. The scary part is that if you play it forwards it installs Windows. - wallace
|
|
Back to top |
|
|
Captain Vimes Grumble Teddy
Joined: 12 May 2006 Posts: 225 Location: The City Streets
|
Posted: Wed Jun 07, 2006 3:35 pm Post subject: |
[quote] |
|
Well, I got that onto my computer (saved the page), and it doesn't look too hard. However, before I can try it, I have to get around my image-display troubles. I'm getting closer, I know it!
... I hope so, anyway... _________________ "Sometimes it is better to light a flamethrower than to curse the darkness."
- Terry Pratchett
|
|
Back to top |
|
|
BadMrBox Bringer of Apocalypse
Joined: 26 Jun 2002 Posts: 1022 Location: Dark Forest's of Sweden
|
Posted: Sun Jun 18, 2006 11:05 pm Post subject: |
[quote] |
|
Seems like I'm not the only one interested in A* lately. I'm trying to code it for FreeBasic and it kinda makes my head feel like a smashed watermelon. _________________
|
|
Back to top |
|
|
Bjorn Demon Hunter
Joined: 29 May 2002 Posts: 1425 Location: Germany
|
|
Back to top |
|
|
BadMrBox Bringer of Apocalypse
Joined: 26 Jun 2002 Posts: 1022 Location: Dark Forest's of Sweden
|
Posted: Thu Jul 27, 2006 3:59 pm Post subject: |
[quote] |
|
Quote: | 503 Service Unavailable
The service is not available. Please try again later. |
I hate it when that happens :( _________________
|
|
Back to top |
|
|