问题
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.
回答1:
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:
- 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.
- 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 - 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.
来源:https://stackoverflow.com/questions/13237837/min-max-evaluation-function-for-a-game