Jump to content
  • Advertisement
Sign in to follow this  
n0b

Different attempts at creating a smart playing AI

This topic is 4526 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. I want to discuss different attempts at creating a smart playing AI for a game called "snakes" (not SNAKE). I don't know if you know this game, so i ll give a short review; -> the game is round-based -> each match is played one on one -> there exist 5(M) snakes -> each player owns one hole(Goal), where he has to lure the snakes to -> the player with the most snakes lured into his hole wins -> in order to lure the snakes, each player can place 10 meatballs -> the snakes can move one field per round -> the snakes always try to reach the meatball / hole which is closest to them (the distance is calculated using euklid) -> each snakes consists of 5 segments The playing field is a 20*21 units large 2D-Grid; However, the first three rows are blocked, so the playing field is only 17*21 units large. So the AI can place a total of 10 meatballs; the question is : where can they be placed to reach the highest output? How to maximize it ? I'll present you my first idea and my the idea i'm working on right now; #1 At first i thought it would be enough to lure (M/2)+1 snakes, which are needed in order to win the game. Its obvious that this is much easier to solve if i concentrated on those snakes which are closest to my goal. So i took the midpoint (referred to as P from now on) of them and used A* to calculate a path from my goal to P. I modified A* so that the output path would be bend. That would ensure that each snake crawling that way would increase the distance between itself and the enemy goal while coming closer to my own goal. Fig.1 : #1 = own goal; ++ A* path; P = midpoint of S1-S3 [---][---][#1][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][#2][---][---] [---][---][++][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---] [---][---][++][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---] [---][---][++][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---] [---][++][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---] [---][++][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---] [---][++][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---] [---][++][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---] [---][---][++][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---] [---][---][---][++][++][++][++][---][---][---][---][---][---][---][---][---][---][---][---][---][---] [---][---][---][---][---][---][---][++][---][---][---][---][---][---][---][---][---][---][---][---][---] [---][---][---][---][---][S1][---]

[---][S3][---][S4][---][S5][---][---][---][---][---][---][---] [---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---] [---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---] [---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---] [---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---][---] Each round that path would be recalculated in order to be up-to-date; if the AI has to place a meatball is determined by the influence the closest enemy meatball has, and if non exists, the influence of the enemy goal. A meatball will always be placed on the unit of the A* path which is exactly one unit closer to the snakes than the enemy. However, that idea did not really work out, so i thought it all over and crushed this old idea. #2 Now i'm using a different base; i evaluate each board position in order to find the most fitting position. I discussed the issue of finding a good evaluation-function in the maths-and-physics section (http://www.gamedev.net/community/forums/topic.asp?topic_id=366826 ). This method holds several advantages : using a limes the AI gets more flexible cause there are more moves available; i can judge positions based on future moves (using a specific depth for evaluation). its easier to determine wether the AI has to use a meatball or to wait and save them for later times. This method can also be improved by grouping snakes : if the distance between two snakes is less than „l“ (user defined) and both snakes want to reach the same point, they ll be judged as a group. Using this grouping method the fitness of units can be changed upon the basis „do they influence another group which wants to reach one of my meatballs / goals negativ?“. It would be possible to make the AI precisily lure the snakes which are going for the enemy's goal. The already placed meatballs could also be integrated into calculating the fitness of a unit – cause a meatball itselfs lures the snakes, points around it would have a higher fitness. Also the AI could use a „meatball-queues“ which hold the rough tactic for the whole match - each round a fitting move is dequeue, if one exists; the other moves get checked each turn for their fitness – if better exist, they ll be changed. If this queue gets saved at the end of a match, together with the enemies contra-moves the ai could evaluate even better based on those informations, which could be read in each game. So it would be kind of self-learning, wouldnt it ? I haven't implemented the whole stuff further than the grouping, which is by now quite simple. So the really bashing stuff is still missing. Any ideas what could improved / how it could be improved ?? Oh, well. Happy new year :d (its already 2006 over here^^) n0b

Share this post


Link to post
Share on other sites
Advertisement
Try playing some multiplayer games and get a feel for what stategys you come up with for winning. Once you get a feel for what works and what doesn't you can try to duplicate that in your AI. Becasue you have the best understanding of whats going on in your game you are the most quailified for writing the AI.(Unless somebody else made this exact same game)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!