如何为游戏创建良好的评估功能? [英] How to create a good evaluation function for a game?

本文介绍了如何为游戏创建良好的评估功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有时会编写程序来玩棋盘游戏.基本策略是标准的alpha-beta修剪或类似搜索,有时会通过通常的残局或开局方法来增强.我主要玩过国际象棋变体,因此当需要选择评估功能时,我将使用基本的国际象棋评估功能.

但是,现在我正在编写一个程序来玩一个全新的棋盘游戏.我该如何选择良好甚至不错的评估功能?

主要挑战是相同的棋子总是在棋盘上,因此通常的材质功能不会根据位置而改变,并且游戏已进行了不到一千次左右,因此人类不一定发挥得还不错,以提供见识. (PS.我考虑过采用MoGo方法,但是随机游戏不太可能终止.)

游戏详细信息:游戏以10 x 10的局面进行,每边固定6块.这些棋子有一定的移动规则,并且以某些方式相互作用,但从未捕获到任何棋子.游戏的目标是在棋盘上的某些特殊方块中放置足够的棋子.该计算机程序的目标是提供一个与目前的人类玩家竞争或更强的玩家.

解决方案

为您的评估功能找到一些候选者,例如移动性(可能的动作数)减去对手的移动性,然后尝试为每个指标找到最佳权重.遗传算法似乎可以很好地优化评估函数中的权重.

创建一个具有随机权重的种群,以有限的深度和转弯相互对抗,用获胜者的随机组合替换失败者,随机播放并重复,在每一代之后打印出种群平均数.让它运行直到您对结果满意为止,或者直到您发现有必要调整某些指标的范围并再试一次(如果一个指标的最佳值可能超出了您的初始范围).

最新编辑:一种我当时不知道的,被接受,研究和理解的方法,叫做差异进化".后代是由3个父代而不是2个父代创建的,这样可以避免过早收敛到平均数的问题.

I write programs to play board game variants sometimes. The basic strategy is standard alpha-beta pruning or similar searches, sometimes augmented by the usual approaches to endgames or openings. I've mostly played around with chess variants, so when it comes time to pick my evaluation function, I use a basic chess evaluation function.

However, now I am writing a program to play a completely new board game. How do I choose a good or even decent evaluation function?

The main challenges are that the same pieces are always on the board, so a usual material function won't change based on position, and the game has been played less than a thousand times or so, so humans don't necessarily play it enough well yet to give insight. (PS. I considered a MoGo approach, but random games aren't likely to terminate.)

Game details: The game is played on a 10-by-10 board with a fixed six pieces per side. The pieces have certain movement rules, and interact in certain ways, but no piece is ever captured. The goal of the game is to have enough of your pieces in certain special squares on the board. The goal of the computer program is to provide a player which is competitive with or better than current human players.

解决方案

Find a few candidates for your evaluation function, like mobility (# of possible moves) minus opponent's mobility, then try to find the optimal weight for each metric. Genetic algorithms seem to work pretty well for optimizing weights in an evaluation function.

Create a population with random weights, fight them against each other with a limited depth and turns, replace the losers with random combinations from the winners, shuffle, and repeat, printing out the population average after every generation. Let it run until you're satisfied with the result, or until you see a need to adjust the range for some of the metrics and try again, if it appears that the optimal value for one metric might be outside your initial range.

Late edit: A more accepted, studied, understood approach that I didn't know at the time is something called "Differential Evolution". Offspring are created from 3 parents instead of 2, in such a way that avoids the problem of premature convergence towards the average.

这篇关于如何为游戏创建良好的评估功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆