0

I'm developing a game(Tank Game 2D),(eg - link ) AI player. My player will be one of 5 other players(AI also) who playing for obtaining maximum coins appears randomly somewhere in the grid.(take a look at the picture given above). Also players can shoot each another. And health packs are also appear somewhere in the grid randomly.

So in order to use min max tree and find out the most clever next move I have to build a evaluation function. The problem arises here, I have no previous experience with such evaluation function.Is there any guidelines should I follow or is there a common way to do it I mean I have something in my mind and I'm not sure if it gonna do the work. Can you suggest me which area should study on. I googled it and found out many things but there is no proper tutorial or something like that. thank you.

Ben
  • 51,770
  • 36
  • 127
  • 149
Sudheera
  • 1,727
  • 1
  • 12
  • 28
  • 1
    So, the question is, how do you write an evaluation function? There are many examples of this, but they are obviously specialized to their domain. A chess board evaluation function won't help you too much here. Tell us what you have in mind. – A. Webb Nov 05 '12 at 18:19
  • Yeah the chess evaluation function is not gonna help. I thought something like this. I have to prioritize players needs. maximum priority is player should not be killed, so if some other player shoots at me I should immediately get out from the track of the bullet. Collecting coins comes next. like wise I can prioritize the needs and assign each one a constant value. the evaluation happens like this, it will returns the sum of product of each need with corresponding constant value. maximum prioritized need will get a higher valued constant. – Sudheera Nov 05 '12 at 18:29
  • 1
    Sounds like a decent start. Seems like your priorities should be different based on your health. If you are at perfect health, pursuing a health pack should be very low priority. But, if you are at death's door, then pursuing health pack can be more valuable than a coin. – A. Webb Nov 05 '12 at 18:33
  • What you can do is experiment with different evaluation functions by having the AI play itself many, many times. The most successful agents should have their evaluation functions promoted. You can have the AI train itself by perturbing successful evaluation functions and pitting them against the originals. If the new functions beat the old, promote the new and demote the old. – A. Webb Nov 05 '12 at 18:36

1 Answers1

5

Basically, the best thing to do to get an evaluation of the game is:

  • Play the game - try to see what situations you try to avoid and which are good. Try to formulate these situations into a general evaluation.
  • Research - someone might have already studied this or a similar problem, if so - maybe there is some article or other material suggesting some heuristic functions.

What I'd do is as follows:

  1. Create a set of heuristic functions, each describing one aspect of the game (distance from nearest enemy, line of fire on enemy, my health bar, ...). I'd play the game to expand this list as much as possible, and of course look on-line for ideas others might have found for this/similar games.
  2. From step one, we actually got a set of functions: h_1(board),h_2(board),...,h_n(board) - but we still do not know what is our heuristic function
  3. I'd try to find some parameters a_1,a_2,...,a_n, and create my heuristic function:
    h(board) = a_1 * h_1(board) + a_2 * h_2(board) + ... + a_n * h_n(board
    The question is now - how to get these parameters. Note that now we have an optimization problem.
    One solution for this specific problem is Monte-Carlo learning.

Monte-Carlo Learning:

The idea of Monte-Carlo learning is to create a list of agents (AIs), each initialized with some random values for a_1,...,a_n - and have a tournament between them.
After the tournament is done, change the values of a_1,...,a_n for each agent, based on the agents that preformed the best, and re-run the tournament. (one way to do it is similar to the "generation" step in Genetic Algorithms - cross overs and mutations, but there are other ways as well).

At the end - the Monte-Carlo learning process should give you good values for a_1,...,a_n - which will give you a good heuristic function for the board.

amit
  • 175,853
  • 27
  • 231
  • 333
  • Similar to "Monte-Carlo Learning", training of neural nets e.g. through [temporal differences](http://www.research.ibm.com/massive/tdl.html) can be very successful in certain domains. In backgammon, starting from a blank slate actually produced a surprisingly better AI player. – A. Webb Nov 05 '12 at 18:43
  • Well, I really appreciate what you mentioned above, thank you. – Sudheera Nov 05 '12 at 18:44