3

我几乎没有正式的离散数学培训,并且遇到了一点问题。我正在尝试编写一个代理,它读取人类玩家的(任意)分数并经常得分。智能体需要时不时地“落后”和“追赶”,以便人类玩家相信存在一些竞争。然后,代理必须赢或输(取决于条件)与人类对抗。

我尝试了一些不同的技术,包括一个不稳定的概率循环(失败得很惨)。我在想这个问题需要像发射隐马尔可夫模型(HMM)这样的东西,但我不确定如何实现它(甚至这是否是最好的方法)。

我有一个要点,但同样,它很糟糕。

我希望该__main__功能提供一些关于此代理目标的见解。它将在 pygame 中调用。

4

2 回答 2

2

我想你可能想多了。您可以使用简单的概率来估计计算机的分数应该“赶上”的频率和程度。此外,您可以计算计算机得分与人类得分之间的差异,然后将其输入到类似 sigmoid 的函数中,以得出计算机得分增加的程度。

说明性 Python:

#!/usr/bin/python
import random, math
human_score = 0
computer_score = 0
trials = 100
computer_ahead_factor = 5 # maximum amount of points the computer can be ahead by
computer_catchup_prob = 0.33 # probability of computer catching up
computer_ahead_prob = 0.5 # probability of computer being ahead of human
computer_advantage_count = 0
for i in xrange(trials):
    # Simulate player score increase.
    human_score += random.randint(0,5) # add an arbitrary random amount
    # Simulate computer lagging behind human, by calculating the probability of
    # computer jumping ahead based on proximity to the human's score.
    score_diff = human_score - computer_score
    p = (math.atan(score_diff)/(math.pi/2.) + 1)/2.
    if random.random() < computer_ahead_prob:
        computer_score = human_score + random.randint(0,computer_ahead_factor)
    elif random.random() < computer_catchup_prob:
        computer_score += int(abs(score_diff)*p)
    # Display scores.
    print 'Human score:',human_score
    print 'Computer score:',computer_score
    computer_advantage_count += computer_score > human_score
print 'Effective computer advantage ratio: %.6f' % (computer_advantage_count/float(trials),)
于 2010-06-27T03:11:59.997 回答
0

我假设人类看不到计算机代理在玩游戏。如果是这种情况,这是您可以尝试的一个想法。

创建可以为任何给定移动计分的所有可能点组合的列表。对于每一步,找到一个你希望代理在当前回合后结束的分数范围。将一组可能的移动值减少到仅将代理结束在该特定范围内的值并随机选择一个。随着您希望代理人落后或领先多远的条件发生变化,只需适当地滑动您的范围即可。

如果您正在寻找具有某种内置和研究过的人类心理影响的东西,我无法为您提供帮助。如果您想要比这更具体的内容,您将需要为我们定义更多规则。

于 2010-06-25T18:30:06.337 回答