2048年Expectimax算法不能达到预期目标?
我使用在排名最高的SO帖子“Optimisation AI for 2048”中提到的启发式方法编写了2048年的Expectimax求解器。
然而,我的expectimax算法正确地执行了最大化,但是当它达到预期循环时,它应该模拟一个移动的所有可能的tile产生(90%2,10%4) - 它似乎没有像预期的那样工作。
game2048.prototype.ai = function (theState, depth, playerOne, alpha) {
var state = this.clone(theState);
var moves = this.validMoves(state);
if (moves.length == 0) { // avoid game losing states
return Number.MIN_VALUE;
}
if (depth == 0) { // base case.
return this.utility(state);
}
if (playerOne) {
for (var i = 0; i < moves.length; i++) {
state.move(moves[i]); // check child state
var temp = this.ai(state, depth - 1, false, alpha); // find the maximum utility for depth given
if (alpha > temp) {
break; // prune the children that we won't choose.
}
alpha = Math.max(temp, alpha);
state.reset();
}
return alpha;
} else { // perform expectation
var avg = 0;
for (var i = 0; i < moves.length; i++) {
state.addRandomTile();
state.move(moves[i]);
avg += this.ai(state, depth - 1, true, alpha);
state.reset();
} return avg / moves.length;
}
}
关于如何将期望不正确地纳入此算法的任何想法?
它应该以某种方式计算所有可能的瓦产生和返回平均所有模拟产卵的得分。
链接地址: http://www.djcxy.com/p/40193.html上一篇: Expectimax Algorithm for 2048 Not Performing Expectation as Intended?