Teach a Computer to Play Heroes, Part 1: Building

The old Heroes games developed by New World Computing. Please specify which game you are referring to in your post.
User avatar
Kristo
Round Table Knight
Round Table Knight
Posts: 1548
Joined: 23 Nov 2005
Location: Chicago, IL

Teach a Computer to Play Heroes, Part 1: Building

Unread postby Kristo » 20 Feb 2008, 15:42

The AI in Heroes games gets so much criticism that it warrants discussion of how to make it better. In order to do that, we must explore everything a computer player is required to do. We can discuss various strategies at an abstract level and the programmers among us can write some test programs to evaluate what we've come up with.

The first thing I want to look at is how the computer builds up its towns, specifically the first week. A good week 1 build order can give you leg up on the competition; a bad one can all but ensure defeat. From reading the various strategies employed by expert players, I think the common theme is, "build the highest level creature generator you can before the week is over." The naive approach is just brute-force: evaluate all possible builds for the seven days and pick the one that yields the highest level dwelling.

CPU cycles are cheap enough these days that such a plan may be good enough. We'd probably want the building to occur last during the computer's turn so it can take into account any resources or mines gained during the turn. To summarize, the "build" step of a turn should look like this:

1. Assume constant income for the rest of the week at current rates.
2. Try all possible build orders through the rest of the week. (We'll need a convenient way to indicate dependencies). Remember that "Nothing" is a valid choice for any given day.
3. Choose the build order that yields the highest level dwelling. TODO: we need a good way to break ties.
4. Build the first structure in the chosen plan.

Thoughts?
Peace. Love. Penguin.

User avatar
Jolly Joker
Round Table Hero
Round Table Hero
Posts: 3316
Joined: 06 Jan 2006

Unread postby Jolly Joker » 20 Feb 2008, 16:52

No, that's starting too late. We must differentiate between difficulty level (starting materials) and map size. Depending on the combination of starting materials (difficulty) and map size we must formulate a strategic aim for the AI. Basically this will be exactly eopposed to the aim of the human player. For example, on a small map that is played on easy difficulty (meaning easy for the player, mind you), the aim would be to concentrate on defense, expand extremely slowly and simply try to make it difficult to conquer the AI (not the map). And so on.
ZZZzzzz....

User avatar
Kristo
Round Table Knight
Round Table Knight
Posts: 1548
Joined: 23 Nov 2005
Location: Chicago, IL

Unread postby Kristo » 20 Feb 2008, 18:55

We'll get there. If more people besides you and I want to discuss this, I'm envisioning a set of tools, more or less, that can be used to accomplish a strategic goal. Examples include:

1. How to build up a town.
2. When to buy creatures and how many.
3. What's important on the adventure map and more importantly, what isn't.
4. How to position your heroes relative to the opponents.
etc.

"Build the highest level creature dwelling you can" is one goal in the process of building up a town. I'm more interested in the how than the why. If we can nail down the way computer player should choose buildings, we can apply other goals. Examples include "Generate more income," and, "Strengthen town defenses."

I want to start at the bottom because starting at the top is too hard. Let's make the bricks, then we can build the castle.
Peace. Love. Penguin.

User avatar
Darmani
Blood Fury
Blood Fury
Posts: 479
Joined: 06 Jan 2006
Location: Cambridge, MA

Unread postby Darmani » 20 Feb 2008, 22:15

Curses, I've been wasting enough time already. And now someone comes along and makes a very interesting thread... :P

First, we need to get a few things out of the way. To what extent will this AI be allowed to cheat? If this works right, it shouldn't need extra resources, but what about exact creature numbers, or a fully revealed adventure map?
Assume constant income for the rest of the week at current rates.
I think this is an absolutely unreasonable assumption. The AI will be picking up mines and treasure chests at vastly different rates throughout the week.

Unfortunately, but Heroes is anything but modular. Building, the adventure map, and battle are all closely intertwined -- the build AI must interact with the adventure map AI to determine how many resources it can get and what it needs to allocate them to. As easy as it would be to build an AI for various subsystems, you can't build a competent AI that doesn't encompass the whole game. (Luckily, battle is fairly isolated, but it'll still need to decide how many troops/what type it will need, coordinate hit and run actions, etc.)

Of course, you can have some success modularizing the AI. You can have an entire subsystem dedicated to positioning heroes, but it will need to ask the battle AI to determine what can fight what, the town AI to determine what reinforcements it can get, etc.

This is how I imagine the builder AI could work:

1)The builder AI finds all possible build orders, and ranks them.
2)The AI looks at the map, and tries to formulate a plan to obtain the resources for each build, going down the list until it finds one it thinks it can obtain. The adventure AI will take into account mines needed, garbage resources needed (including campfires and other random ones - perhaps cheating will help here), heroes needed to capture, resources needed to capture, creatures needed to capture, when those creatures will be available, resources needed to buy those creatures, etc.
2.5)Resource generating buildings, and gold desired at start of the week to buy creatures should also be considered. For example, if the adventure map AI realizes that it'll need a little more gold for its plan, it may then jump to several similar builds involving the statue, and then try to work with those.
3)Build the first thing on the best feasible build order.
4)Assuming step 2 runs in a reasonable time, repeat 1-4 each turn to take into account new information.

Of course, the above is useless if you don't have an inkling how the overall AI will work. Even if one programs the bricks first, the overall AI should be top down, like the king who tells his general to invade a country and lets him figure out the details, and then tells some other official to acquire 10000 swords and lets him figure out the details.

Here's a hypothetical "big picture down to details" goal based system deciding to build a Statue this turn.

1)Top level goal: I want to defeat the Blue, who currently holds a Warlock castle and seems to be putting his troops and skills into a Warlock hero.
2)First subgoal: I want to get an affordable army that can defeat Blue. It's a long way to his castle, so this will be a long game. Therefore, I'll be looking at less defense at the moment, and will be facing a strong hero and army. I should thus place less of an emphasis on trolls, as there'll be less turrets and they'll be decimated by spells, and more of an emphasis on Ogre Lords and the magic to keep mind spells off them.
3)Next subgoal: My goal army is somewhat cheap, but I'll need to maximize their production, and build the dwelling quickly. I'll need to acquire Wood and Ore,
4)Next subgoal: Those two sawmills and that ore pit look it to be easily acquirable. The first is guarded by some Rangers. It is in reinforcing distance of my castle, so I'll need to optimize to fight them. Wolves should do the trick.
5)In order to get the wolves withing two days, I'll need more gold. I'll need a few extra days to get the Orc Chieftains to defeat the Zombies guarding the gold mine. There are no nearby chests. The junk gold is guarded by the zombie. I must therefore build a Statue today.

User avatar
UndeadHalfOrc
Cyber Zombie
Cyber Zombie
Posts: 1362
Joined: 13 Mar 2007

Unread postby UndeadHalfOrc » 20 Feb 2008, 23:11

This is all fascinating, but pointless if we don't even say WHICH Heroes game we're dissecting here. From the comments, it seems to be Heroes 2 or Heroes 3. Both games have different town layouts. Which one is it?

User avatar
Darmani
Blood Fury
Blood Fury
Posts: 479
Joined: 06 Jan 2006
Location: Cambridge, MA

Unread postby Darmani » 21 Feb 2008, 01:32

UndeadHalfOrc wrote:This is all fascinating, but pointless if we don't even say WHICH Heroes game we're dissecting here. From the comments, it seems to be Heroes 2 or Heroes 3. Both games have different town layouts. Which one is it?
All of them, really. I personally used Heroes II in my example, as that's what I'm most familiar with. But, changing the details, most of the same things could be said about any of the others.

After all, the question is "How does the computer choose what to build," not "How does the computer choose what to build if the options are six dwellings, some of which have upgrades; a mage guild; a thieves guild; a tavern..."

User avatar
UndeadHalfOrc
Cyber Zombie
Cyber Zombie
Posts: 1362
Joined: 13 Mar 2007

Unread postby UndeadHalfOrc » 21 Feb 2008, 02:08

Heroes 2 only has 1 money related building: the statue (and dungeon for warlock)

Heroes 3 towns have two separate trees to build: monster dwellings, and capitol.

User avatar
Kristo
Round Table Knight
Round Table Knight
Posts: 1548
Joined: 23 Nov 2005
Location: Chicago, IL

Unread postby Kristo » 21 Feb 2008, 04:23

Darmani wrote:First, we need to get a few things out of the way. To what extent will this AI be allowed to cheat? If this works right, it shouldn't need extra resources, but what about exact creature numbers, or a fully revealed adventure map?
I think we'd have to allow full knowledge of fixed objects in order to make pathfinding reasonable. It'd be like playing the game with the map editor open. The computer agent is definitely not allowed to see exact numbers or current movements within the shroud.
Darmani wrote:
Assume constant income for the rest of the week at current rates.
I think this is an absolutely unreasonable assumption. The AI will be picking up mines and treasure chests at vastly different rates throughout the week.
Why is that unreasonable? The builder AI runs at the end of every turn, so it has new information each time. It's like a chess AI. A chess AI is supposedly trying to win, but in reality it only wants to make the best next move given the current game state.
Darmani wrote:Here's a hypothetical "big picture down to details" goal based system deciding to build a Statue this turn.
I like it. I've snipped it for brevity, but I'm picturing a "conversation" going on here between the AIs. A similar example to see if I understand:

General AI: Builder, show me your best build plan so far.
Builder: I can get you to Ogres by day 7.
Adventure: If you let me have 10 Orcs I can defeat the guardians of an ore mine.
General: Builder, what can you do with 1400 fewer gold but +2 ore per day?
Builder: I can get you to Trolls by day 7.
General: Do it. (Yes I know that's the hard part :D)

The General has to know the big picture but the Adventure and Builder AIs get to be somewhat stupid. I think "playing dumb" is key. I write fault-tolerant software for a living. Every time we try to be smart and consider every possible edge case, we either miss one or wind up with unmaintainable spaghetti code.
Peace. Love. Penguin.

User avatar
Jolly Joker
Round Table Hero
Round Table Hero
Posts: 3316
Joined: 06 Jan 2006

Unread postby Jolly Joker » 21 Feb 2008, 06:46

Well.
I think it is wrong to go at this from a human point of view. There are too many different map layouts possible, and what we don't want is a helpless AI, stumbling aimlessly around. We don't want the AI to be fixed on a specific build order when the map is set to have a difficult resource situation. Playing the AI like a human means, that everything is dependant on each other: you cannot build without resources, you have to fight to get them, but you have to build and buy to be able to fight successfully. For a human, the trick of the game is - on high difficulty - to get all of it right. The AI can't do that. Period. Or, specifically, it is impossible to make an AI so flexible that it will be able to do the right thing on every kind of map. So what we want is - separately for each difficulty level - something like a general ability to do something for the AI NO MATTER the map situation, but that the map situation would be REFLECTED in some way. Which means, that it is necessary to find the right combination of bonusses (or cheats) and regular play.

Therefore, I'd say, the way to go is, setting difficulty levels first. How many are there? What are the differences? What is the AI supposed to do on each diff level? After that, you'll have the boundaries in which th AI is supposed to operate.

So, first you have to determine the difficulty level (and the level of play) the AI is supposed to play at its best. This is obviously NOT the case on Heroic or Impossible level, because here the AI us SUPPOSED to get "unfair" advantages. Even if it's only the starting amount of stuff, this allows a completely different style of play.
The AI isn't supposed to be tough when you play easy, so this leaves something like a "hard" level that would feature an AI playing at its fullest, but with a decent starting cache.
I think that this setup will ALWAYS allow a fixed build order, no matter what which means: NO specific building AI, at least none the way you imagine one, Kristo. It's just not necessary.
ZZZzzzz....

User avatar
ThunderTitan
Perpetual Poster
Perpetual Poster
Posts: 23270
Joined: 06 Jan 2006
Location: Now/here
Contact:

Unread postby ThunderTitan » 21 Feb 2008, 08:16

Darmani wrote: First, we need to get a few things out of the way. To what extent will this AI be allowed to cheat? If this works right, it shouldn't need extra resources, but what about exact creature numbers, or a fully revealed adventure map?

As i said many times before, the AI should be able to play the game without defeating itself if it doesn't use any cheats...
Disclaimer: May contain sarcasm!
I have never faked a sarcasm in my entire life. - ???
"With ABC deleting dynamite gags from cartoons, do you find that your children are using explosives less frequently?" — Mark LoPresti

Alt-0128: €

Image

User avatar
Darmani
Blood Fury
Blood Fury
Posts: 479
Joined: 06 Jan 2006
Location: Cambridge, MA

Unread postby Darmani » 21 Feb 2008, 13:21

UndeadHalfOrc wrote:Heroes 2 only has 1 money related building: the statue (and dungeon for warlock)

Heroes 3 towns have two separate trees to build: monster dwellings, and capitol.
That's just details. If you write a good AI, it should be able to work if a statue gives 250 gold per day at 1250 gold and 5 ore, or if you mod it to be 1000 gold per day at a cost of 10000 gold. Likewise, if you find a good approach to writing an AI, you should be able to use it for any Heroes game, but with some of the specifics changed. You just can't optimize it too much for a specific Heroes game - then you may cloud your thinking with too much specific to said game.
Why is that unreasonable? The builder AI runs at the end of every turn, so it has new information each time. It's like a chess AI. A chess AI is supposedly trying to win, but in reality it only wants to make the best next move given the current game state.
Chess has a few properties that can guarantee any calculations you make ahead will be valid: determinism and full knowledge. It also helps that the only things that change what moves to make are what move the opponent makes. For Heroes, it's unfortunately a little more complex.

Imagine we have modified the mage guild level 1 in H2 to require two of each secondary resource. It is Day 6. The castle started with a Habitat and Well; so far the AI has built a Statue, Boar Pen, Foundry, Roc Nest, and Upgraded Foundry. On day 6, one hero used the Steel Golems from the upgraded Foundry to defeat the guardian of 5 chests, and finds 8k gold total inside them, while another hero captured a Gem Mine and 15 garbage gems with it. The AI assumes that it will also get 15 gems and 8k gold, and thus upgrades its goal to Cloud Castle. It then builds a Mage Guild. The next day, no such resources come. It then would like to build the Ivory Tower, but can't - due to its expenditures on the Mage Guild, it only has 1 Sulfur, 1 Mercury, and 1 Crystal.

I admit that's a somewhat contrived example, but it's just demonstrating how this assumption can lead to bad decisions. More likely, I can see it getting a bunch of resources on Day 1, and deciding it won't need a Statue, causing it not to build a statue until the next day (or even the day after).


In most cases, you are 100% correct that the AI will play decently (probably not optimally) with this assumption if it runs at the end of every turn. However, that's just because most of the things on the way to the goal are good too. If you create a building that has little use other than as the prerequisite for another building is where you'll start to really see the AI playing somewhat poorly.
General AI: Builder, show me your best build plan so far.
Builder: I can get you to Ogres by day 7.
Adventure: If you let me have 10 Orcs I can defeat the guardians of an ore mine.
General: Builder, what can you do with 1400 fewer gold but +2 ore per day?
Builder: I can get you to Trolls by day 7.
General: Do it.
Nice!

However, it looks like it has the built-in goal of saying "I need to get as high up the tier list as possible. That'd make the AI simpler to grasp in the head by quite a bit, although, once again, could lead to some bad decisions, as this is just the means to the goal of winning. For example, it could be very well possible that there's an enemy castle nearby, potentially capturable in week 1, against which Steel Golems and Ogre Lords would help more than their unupgraded counterparts combined with Magi and Trolls.

User avatar
Kristo
Round Table Knight
Round Table Knight
Posts: 1548
Joined: 23 Nov 2005
Location: Chicago, IL

Unread postby Kristo » 21 Feb 2008, 15:59

Jolly Joker wrote:Therefore, I'd say, the way to go is, setting difficulty levels first. How many are there? What are the differences? What is the AI supposed to do on each diff level? After that, you'll have the boundaries in which th AI is supposed to operate.
I think the target should be to have the AI play as well as it can within the same rules as the human player. This would be "Normal" difficulty. We can make the game harder or easier on the AI simply by denying/giving it extra income. Success in a game like Heroes is directly related to how well you manage your money. If an AI's income is skewed I think it will naturally play better or worse accordingly.
Jolly Joker wrote:I think that this setup will ALWAYS allow a fixed build order, no matter what which means: NO specific building AI, at least none the way you imagine one, Kristo. It's just not necessary.
I was trying to avoid that actually. I'd like an AI to be able to adapt whenever the rules change, and they will quite often during active modding or new Heroes game development. If you script the build order, you have to modify it every time something changes.
Darmani wrote:On day 6, one hero used the Steel Golems from the upgraded Foundry to defeat the guardian of 5 chests, and finds 8k gold total inside them, while another hero captured a Gem Mine and 15 garbage gems with it. The AI assumes that it will also get 15 gems and 8k gold, and thus upgrades its goal to Cloud Castle.
I see where I confused you now. I wasn't counting those one-time gains as income. I defined income as the money your castle produced and any mines you had, and that's it. One-time bonuses are just that.
Darmani wrote:However, it looks like it has the built-in goal of saying "I need to get as high up the tier list as possible. That'd make the AI simpler to grasp in the head by quite a bit, although, once again, could lead to some bad decisions, as this is just the means to the goal of winning. For example, it could be very well possible that there's an enemy castle nearby, potentially capturable in week 1, against which Steel Golems and Ogre Lords would help more than their unupgraded counterparts combined with Magi and Trolls.
The General would have to set the Builder's goal. We could probably come up with a few goals that would be appropriate for various situations. Then the General can evaluate the game state and assign the goal that scores the best. It definitely won't be optimal, but it'll at least be maintainable and debuggable.
Peace. Love. Penguin.

User avatar
Darmani
Blood Fury
Blood Fury
Posts: 479
Joined: 06 Jan 2006
Location: Cambridge, MA

Unread postby Darmani » 21 Feb 2008, 19:22

Kristo wrote:I see where I confused you now. I wasn't counting those one-time gains as income. I defined income as the money your castle produced and any mines you had, and that's it. One-time bonuses are just that.
Okay, that could work. On the vast majority of maps it is very reasonable to assume that any captured mines will not be captured back within the first week.

But...

The AI will capture mines and find garbage resources during the week, and it needs to predict this. It still needs to look at the adventure map. :(

User avatar
Alamar
Golem
Golem
Posts: 605
Joined: 06 Jan 2006

Unread postby Alamar » 22 Feb 2008, 00:54

As far as the assumption of $ && resources go I don't think that it should assume a constant daily income.

I think what it should do is to try to do a rough guesstimate of how many resources it will have on various days and then based on that data try to figure out a proper build order. With most heroes games you need to guess at least from day 1 to day 7 of the current week.

Once you have the rough guesstimate then you're going to be in good shape to determine what you can build on various days to get the most bang-for-your-buck.

As other posters have indicated a "top notch" building AI has to work hand-in-hand with the adventure AI so you will have better guesstimates of resources available for building.

***********************************************************

Because writing an AI is a very difficult issue I think that it would be a good idea for map makers to be able to give the AI "hints" as to what sort of game it will be.

For example map size could dramatically effect build orders but if the map maker gave estimates for things like time to first contact, personality for the faction [does it concentrate on large armies or economic structurs], etc. This will hopefully give a nudge to the AI.

Once a nudge is given maybe we could fall back to a set of building scripts for each faction and then have the AI pick the best script and then it could play with minor mods to build order given the current best script and go from there.

User avatar
Kristo
Round Table Knight
Round Table Knight
Posts: 1548
Joined: 23 Nov 2005
Location: Chicago, IL

Unread postby Kristo » 22 Feb 2008, 13:24

Ok let's run with that. How do you estimate how many resources you're going to pick up in any given week? For the first week, the map file itself can have information about what surrounds your starting castle. Simpler yet, just have a total sum of the average value of loose resources and the total number of mines within, say, 2 days' march of the home castle.

But here's the hard part. How do you do that for any other week? Your heroes could theoretically be anywhere.
Peace. Love. Penguin.

User avatar
Darmani
Blood Fury
Blood Fury
Posts: 479
Joined: 06 Jan 2006
Location: Cambridge, MA

Unread postby Darmani » 22 Feb 2008, 16:20

Rather than using poor heuristics for the first week, use a more general approach that will work better for both the first week and other: actually construct a plan of where it will move its heroes in the coming days.

After all, knowing the resources within two days of the castle is useless: you may get some of them too late to use, you may not get some of them, you may get quite a bit beyond the two-day radius.

The AI could do something like this:

Builder: I see substantial benefit in building a Black Tower by the end of the week
Adventure: I have a scout within striking range of a well-defended sulfur mine and two piles of sulfur.
Builder: That won't be enough. Okay, I see substantial benefit in getting a Red Tower by the end of the week.
Adventure: ....(same thing. An optimization could realize that it could use much of the same calculations for the previous to skip this step.)
Builder: That won't be enough. Okay, I see substantial benefit in getting a Green Tower by the end of the week.
Adventure: I have a scout within striking range of a well-defended sulfur mine and two piles of sulfur.
Builder: What would it take to get it?
Adventure: There are several options. I could pull my main over -- naah, that would take too long, and I need him and almost all his troops elsewhere. There are several paths to reinforce that scout. The most effective is to pull the spare troops from the starting Warlock castle, and use spare heroes purchased from each of the four castles on the way to help caravan them along. However, I could reduce the number of spares needed by pulling that one guy off getting those gems.
Builder: I don't need the gems much, and I could still afford the Green Tower without that gold. What else could be done with this gold?
Adventure: Well, the main is near the recently-upgraded Barbarian castle and near striking distance of Green's castle. I'd like to capture it on Day 1 of the next week. It'll take only two secondary heroes to reinforce the main with the troops on Day 1.
Builder: I'd be able to get you to Ogres there with that.
Battle AI: That should be enough to defeat the garrison
General: I prefer taking Green's castle to getting Green Dragons. Let's do that!

User avatar
Alamar
Golem
Golem
Posts: 605
Joined: 06 Jan 2006

Unread postby Alamar » 23 Feb 2008, 00:58

Kristo wrote:Ok let's run with that. How do you estimate how many resources you're going to pick up in any given week? For the first week, the map file itself can have information about what surrounds your starting castle. Simpler yet, just have a total sum of the average value of loose resources and the total number of mines within, say, 2 days' march of the home castle.

But here's the hard part. How do you do that for any other week? Your heroes could theoretically be anywhere.

The "where is your hero" part isn't really the hardest part per-se. I would basically have the build-order AI giving goals to the adventure map AI so it could direct the heroes to go to the right sorts of places at approparite times to gather the resources that you need to continue building properly. The adventure map AI [of course] would have other goals too so both AIs would go back & forth until they came up with a plan for the next week or so. So this is the way that we can come up with a decent guesstimate of what resources will be available when.

Now based on this then you can order and plan your builds fairly well [hopefully at least as well as a HoMM newb could] ....

As far as what to build now that we know the resources available would depend on factors like map size, how agressive we should be and how early, hints from the map maker, "personalities" assinged by map maker, etc.

In the end I think having the AI choose from one of a set of scripts and then allowing minor reordering of the script would work reasonably well ...

***********************************************

Possibly off topic:

Before the thread goes too far I think that it's important to decide on what sorts of things make up a good AI. Is strictly giving the player a challenge sufficient? Does the AI need to break as few rules as possible or not care at all how much the AI "cheats"? Does the AI need to give the appearance that both of you are playing by the same rules? Does the AI need to mimic a human player exactly???

Once we have a good grasp on goals then I think some of our questions will answer themselves.

For example to prevent giving humans too much of an edge on maps they've played before I would suggest that you give the AI "perfect knowledge" of all static map objects ... things like where is the Dragon Utopia, where is the sulfer mine that I can't see but I know is likely somewhere in my starting territory, etc. This way the AI has all the information that it needs to figure out where it should send its heroes to gather whatever materials are important.

I think the above example of cheating is one of the more subtle cheats that [at least for me] doesn't offend my personal sensibilities. On the other hand giving the AI 5K gold and 10 of all resources daily as gifts would tend to offend my sensibilities because then the AI isn't even close to playing the same game that I am.

User avatar
Darmani
Blood Fury
Blood Fury
Posts: 479
Joined: 06 Jan 2006
Location: Cambridge, MA

Unread postby Darmani » 23 Feb 2008, 01:59

The "where is your hero" part isn't really the hardest part per-se. I would basically have the build-order AI giving goals to the adventure map AI so it could direct the heroes to go to the right sorts of places at approparite times to gather the resources that you need to continue building properly. The adventure map AI [of course] would have other goals too so both AIs would go back & forth until they came up with a plan for the next week or so. So this is the way that we can come up with a decent guesstimate of what resources will be available when.
That's pretty much what I tried to say in my post, except you did a better job explaining it. Thank you!

Kristo already said that the AI should be like a player playing with the map open in the map editor.

My thought is that the AI should play like a human - it should try to win. Of course, if the player has a strong advantage, the AI might be able to do nothing better than try to hang on for dear life and go all out defensive.

User avatar
Kristo
Round Table Knight
Round Table Knight
Posts: 1548
Joined: 23 Nov 2005
Location: Chicago, IL

Unread postby Kristo » 24 Feb 2008, 00:14

Darmani wrote:My thought is that the AI should play like a human - it should try to win. Of course, if the player has a strong advantage, the AI might be able to do nothing better than try to hang on for dear life and go all out defensive.
I've always maintained that it's the AI's job to provide an entertaining opponent but ultimately it should lose the game most of the time. I've had the most fun when the computer opponents appear to keep up with me, right up to the point where I squash them. :D A good AI should seek parity with the human player. In a Heroes game that means grabbing towns at the same rate and keeping army strength at a similar level. A four-player game (1 human and 3 AIs) should become 1v1 at midgame, with each player owning approximately half the towns. We might consider allowing perfect Thieves Guild information for this purpose. I'm not sure if that would manifest itself as blatant cheating or not.

As for the Builder-Adventure interaction, it sounds great it theory but I think we might be getting too complex too quickly. We seemed to agree that it was a good idea to have a few possible Builder goals for the General to choose from. So let's take a step back and answer this question. "If you had infinite resources, what are the different ways you'd build up a castle?" My initial stab at it is this:

1. All creature generators in tier order.
2. Highest tier dwelling by day 7.
3. Highest income.

How are these defined algorithmically? When is the computer agent allowed to build the extra stuff, e.g., Mage Guilds, Tavern (if it's not a prerequisite), defenses, etc.?
Peace. Love. Penguin.

User avatar
Jolly Joker
Round Table Hero
Round Table Hero
Posts: 3316
Joined: 06 Jan 2006

Unread postby Jolly Joker » 26 Feb 2008, 08:04

For several reasons I could list, if someone wishes so I think that letting the AI simply cope human behaviour is impractical.

I think that the way to build the best AI possible would be a way akin to the way a Random Map generator works. Modules or Templates of AI behaviour should be written, that could be combined. For example, there might be different AI modules or "modifier" for different behaviour depending on
a) map size
b) number of human/computer players
c) Objective (kill all, find Asha's Tear/Artifact, TaKe Object and so on)
d) race
e) difficulty level (starting resources)

On top of that there might be something like a personality modifier (variations in acceptable battle odds, for example, making one AI more careful than others).

Furthermore, something like "failsafes" might be interesting. Just for the heck of it I'd like to see a feature telling the human player while he is waiting for the AI to finish its turn:
"Reloading... AI lost main hero in a miscalculated fight..." :)
ZZZzzzz....


Return to “Heroes I-IV”

Who is online

Users browsing this forum: No registered users and 18 guests