![]() |
| | #1 |
| Registered User Join Date: Jun 2003
Posts: 90
| AI programming help wanted
__________________ He who asks is a fool for five minutes, but he who does not ask remains a fool forever. The fool wonders, the wise man asks. - Benjamin Disraeli There are no foolish questions and no man becomes a fool until he has stopped asking questions. Charles Steinmetz |
| DanFraser is offline | |
| | #2 |
| Crazy Fool Join Date: Jan 2003 Location: Canada
Posts: 2,588
| You want to search for Minimax and Alpha-beta tree.
__________________ jeff.bagu.org - Terrain rendering and other random stuff |
| Perspective is offline | |
| | #3 |
| Registered User Join Date: Jun 2003
Posts: 90
| Thanks, looking that up now. As I read through, is this type of AI suitable for an up to 11 AI player complex grid map turn based game?
__________________ He who asks is a fool for five minutes, but he who does not ask remains a fool forever. The fool wonders, the wise man asks. - Benjamin Disraeli There are no foolish questions and no man becomes a fool until he has stopped asking questions. Charles Steinmetz |
| DanFraser is offline | |
| | #4 |
| Crazy Fool Join Date: Jan 2003 Location: Canada
Posts: 2,588
| >up to 11 AI player complex grid map no. It's for adversarial 1v1 turn based games. Its what's used in traditional game AI like chess, checkers, etc... Sounds like you may want a decision tree for that type of thing. These types of games often have human designed AI, though you could probably train a tree by playing the game against itself.
__________________ jeff.bagu.org - Terrain rendering and other random stuff |
| Perspective is offline | |
| | #5 |
| Registered User Join Date: Jun 2003
Posts: 90
| Ah, this is starting to lead me in a good direction. It's always good to have someone not speak like they're writing a book ![]() If you have any more suggestions or stuff, lemme know. Would telling you a little more about the game and it's constricts allow you to point me further?
__________________ He who asks is a fool for five minutes, but he who does not ask remains a fool forever. The fool wonders, the wise man asks. - Benjamin Disraeli There are no foolish questions and no man becomes a fool until he has stopped asking questions. Charles Steinmetz |
| DanFraser is offline | |
| | #6 |
| Rampaging 35 Stone Welsh Join Date: Apr 2007
Posts: 2,927
| For a turn based game, your ai should probably be pretty simple. Scripting it to just build an economy and make units and then attack will probably beat most players. You can hide any defficiencies by giving it an advanatge in materials or unit cost/quality. 85% of players cant tell the dfifference between smarter AI and AI with higher hitpoints/more resources.
__________________ He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet |
| abachler is offline | |
| | #7 |
| Registered User Join Date: Jun 2003
Posts: 90
| I think it needs to be a bit more complicated than that though. The properties of each empire and it's governed systems is quite huge, and the actual game itself in real life demands that you make at least one alliance or die.
__________________ He who asks is a fool for five minutes, but he who does not ask remains a fool forever. The fool wonders, the wise man asks. - Benjamin Disraeli There are no foolish questions and no man becomes a fool until he has stopped asking questions. Charles Steinmetz |
| DanFraser is offline | |
| | #8 |
| Rampaging 35 Stone Welsh Join Date: Apr 2007
Posts: 2,927
| So you add a section of code that makes the AI form an alliance. Code: if(this->Allied == FALSE) this->OfferRandomAlliance();
__________________ He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet |
| abachler is offline | |
| | #9 |
| Crazy Fool Join Date: Jan 2003 Location: Canada
Posts: 2,588
| >if(this->Allied == FALSE) this->OfferRandomAlliance(); It would work but it's pretty simple. I would break things down into basic actions, like attacking a unit in neutral territory, invading enemy territory, expanding your territory, etc... As well as the state of the game (I have an alliance, x territory, x units). All of these can then be fed to a scoring function for a particular goal. If you have a goal to make an alliance, than attacking a unit in neutral territory carries negative weight for that goal. Invading an enemy carries even worse weight. However, they carry positive weight towards other goals such as winning the game. Not having an alliance also contributes negatively to winning the game. etc.. The AI then evaluates the effect of candidate actions on all of it's goals and chooses accordingly. Different AI strategies will value (or weight) goals differently. Tuning these weights (or learning them) is what makes a good AI.
__________________ jeff.bagu.org - Terrain rendering and other random stuff |
| Perspective is offline | |
| | #10 |
| Wheres the lesbians? Join Date: Oct 2006 Location: UK
Posts: 1,219
| You may want to learn to use Dijkstras algorithm for path finding. A* is a faster, simpler, and more common pathfinding technique, but it doesent necessarily find the shortest path. Since turn based strategy games don't have to do pathfinding as frequently as real-time games dijkstras algo should be much better for what you need. Last edited by mike_g; 12-13-2007 at 08:26 PM. |
| mike_g is offline | |
| | #11 |
| Crazy Fool Join Date: Jan 2003 Location: Canada
Posts: 2,588
| >A* is a faster, simpler, and more common pathfinding technique, but it doesent necessarily find the shortest path What? It most certainly does find the shortest path.
__________________ jeff.bagu.org - Terrain rendering and other random stuff |
| Perspective is offline | |
| | #12 |
| Wheres the lesbians? Join Date: Oct 2006 Location: UK
Posts: 1,219
| No. Not always ![]() It can find the most direct path from a to b with no obstructions, but it works on guessing the distance from the current location to its target. This causes problems when you have variable stuff like differing movement costs for terrain types. I have been there and done that with a turn based strategy game. From experience I found Dijkstras algo is the one to go for. |
| mike_g is offline | |
| | #13 |
| Crazy Fool Join Date: Jan 2003 Location: Canada
Posts: 2,588
| >No. Not always Than your implementation is wrong or your heuristic is over-estimating.
__________________ jeff.bagu.org - Terrain rendering and other random stuff |
| Perspective is offline | |
| | #14 |
| Wheres the lesbians? Join Date: Oct 2006 Location: UK
Posts: 1,219
| There is nothing wrong with my implementation. A* heuristic improvements I have seen on net simply point to finding a more direct route. How would you implement varying terrain move costs in your A* heuristics? Use the average move cost per tile on the map? The A* algorithm finishes once a path has been found; regardless of if its is the shortest path. As heuristics here basically means guessing you cant be guaranteed to have the shortest path. Dijkstras algorithm is often referred to as 'the shortest path algorithm'. A* is not. If theres anyone else here familiar with both algorithms they should agree with me. |
| mike_g is offline | |
| | #15 | |
| Crazy Fool Join Date: Jan 2003 Location: Canada
Posts: 2,588
| Just do a little googling, you can model all of your terrain stuff as part of the cost function. As long as your heuristic doesn't overestimate the cost at any point, the A* search will always find the shortest path. http://en.wikipedia.org/wiki/A*_search_algorithm Quote:
Your A* implementation is broken
__________________ jeff.bagu.org - Terrain rendering and other random stuff | |
| Perspective is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Simple space combat AI | Bubba | Game Programming | 5 | 01-06-2009 12:54 AM |
| chess ai contest | Raven Arkadon | Contests Board | 7 | 07-09-2005 06:38 AM |
| AI Contest Proposal | MadCow257 | Contests Board | 4 | 03-13-2005 03:27 PM |
| Game Design Topic #1 - AI Behavior | TechWins | Game Programming | 13 | 10-11-2002 10:35 AM |
| Technique of all board-like games? | Nutshell | Game Programming | 28 | 04-24-2002 08:19 AM |