Jump to content

  • Log In with Google      Sign In   
  • Create Account

Turn Based Strategy AI


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

#21 checkmarkgames   Members   -  Reputation: 165

Like
0Likes
Like

Posted 23 May 2012 - 10:06 PM

An excellent amount of information and insight Platinum_Dragon, thank you so much for taking the time to leave this comment. I was not aware of the tendancy of multiplayer Advance Wars games to tend towards large amounts of infantry and artillery. I hope to make all units useful with this game, and it looks like a lot of testing and tweaking is in my future.

Sponsor:

#22 checkmarkgames   Members   -  Reputation: 165

Like
0Likes
Like

Posted 06 June 2012 - 09:30 PM

Part 8 is finally finished. This time I used a Genetic Algorithm to try to evolve a better AI player. Check out the results here:

http://www.checkmarkgames.com/2012/06/turn-based-strategy-game-ai-part-8.html

#23 Seongjun Kim   Members   -  Reputation: 227

Like
0Likes
Like

Posted 07 June 2012 - 08:20 PM

I'm actually developing a turn-based strategy myself, and I've been having trouble with AI. Your blog posts have made me realize many points that I can incorporate for my game! Thank you so much :)

#24 Platinum_Dragon   Members   -  Reputation: 162

Like
1Likes
Like

Posted 07 June 2012 - 08:51 PM

Here's a good link: http://warswiki.warscentral.com/Score

It's about how Advance Wars determine the player's performance. If you instead use a similar method of adding the value from multiple goals, and ultimately try to maximize the overall value, then your AI may be more dynamic. Have multiple goals that are calculated independently.
  • (SPEED) Try to win as fast as possible, create a time limit for perfect score and a decay formula.
  • (POWER / ATTACK EFFICIENCY) Try to cause as much damage as possible, with killing enemy units worth a whole lot.
  • (TECHNIQUE / ATTRITION) Try to build a whole lot of units. Measure the percent of remaining forces.

In 1 & 2, set you have set points for destroying enemy units.
In 3, you have points earn for gaining gold, but it should be modify so that the AI gain points for building units.

You need to make the building of high tier unit worth points using a multiplier so that high tier units are worth more than their cost by a significant amount. This will cause the AI to try to build as many high tier units first, and using the remaining gold to build units. The AI needs to maximize the amount of units it has, but needing a priority in having high tier units. Losing a unit should be worth the amount of points gain for building the unit plus the amount of points gain for gaining the gold. With this in effect, the AI will try to preserve its units.

A simple formula for earning points for unit is (Points Earn = Unit Tier * Unit Cost). This will allow the AI to maximize with the strongest possible units it can build. Of course, this is not the best strategy since high tier units need support from low tier units. I believe the attrition objective will counter the effect of purely building high tier units. Two opposing objective will mean that your AI should find a range of equilibrium, not a fix position.

Summary:
  • You want to have multiple independant goals that will sum up together.
  • Maximizing the overall total score is what you want your AI to do.
Other Notes:
  • You AI will never be as powerful as strong players, but average players may find them a challenge.
  • Remember that a larger percentage of player population are more casual than the 20th Century gamers.

I use QueryPerformanceFrequency(), and the result averages to 8 nanoseconds or about 13 cpu cycles (1.66GHz CPU). Is that reasonable?
I though that the assembly equivalent to accessing unaligned data would be something similar to this order:
  • move
  • mask
  • shift
  • move
  • mask
  • shift
  • or
So it seems reasonable to say that it takes 14 cycles for unaligned data since we'll have to do the series of instructions once to access and once to assign?

#25 checkmarkgames   Members   -  Reputation: 165

Like
0Likes
Like

Posted 07 June 2012 - 09:02 PM

@jsj795 Glad it has been of use to you, please let me know if you discover anything of interest while developing your own AI

@Platinum_Dragon Once again a great bit of information! I am currently using various unit ratios to determine what the AI should build. So that it tries to build the unit type that is furthest away from its current ideal ratio. That seems to be working good so far, but it is good to know of the alternate you suggest.

#26 willh   Members   -  Reputation: 160

Like
0Likes
Like

Posted 08 June 2012 - 07:23 AM

Fantastic!! I'm so glad you ran in to the problem of determing a decent fitness function, and then solved it. Very educational. I think the important take away is that you found success when your fitness function was the sum of many different factors. It is critical that small tiny changes in fitness are easy and possible.

You illustrated perfectly why machine learning can be a cumbersome tool, but your results also demonstrated how fruitful the results can be. :). The next step, and I do hope you take it, would be to allow Henry to play against Henry. :)

Also interesting that you were able to use the GA to identify weaknesses in the game mechanics.

Well done, and thank you for sharing your progress!

#27 Infinisearch   Members   -  Reputation: 311

Like
0Likes
Like

Posted 19 July 2012 - 09:18 PM

I was enjoying following along with your progress. Are you done with the AI or is there more to come?
-potential energy is easily made kinetic-

#28 checkmarkgames   Members   -  Reputation: 165

Like
0Likes
Like

Posted 06 August 2012 - 11:27 PM

I originally intended for at least one other installment. I was going to add in some Fuzzy logic, but after some research I found that my idea of Fuzzy Logic was incorrect, I just wanted to add a little variance to the AI. I have become very happy with the current state of the AI. To get further progress, I need to finalize the game rules completely (should water spaces be uncrossable? should enemy units prevent collection of resources?) as well as add in the additional Undead faction which plays quite differently. Basically, I think I got about as far as I could with the state the game was currently in.

I then became engaged with improving the visual presentation and flow of the game. As a one man developer, I found a very useful way to stay motivated enough to finish a project is to follow my current passions and interests.

The short answer, is that I am done for now, but I would like to at least present a final summary at some point, and I think there is some opportunity to clean things up as well.




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