我想要创造一些算法,使计算机赢得比它在一个改进的黑板游戏中失去的更多。
红牌将为负数,黑卡为正数。
我会用伪代码来写它,我想知道让计算机赢得更多游戏的概率部分(最后一行)。
以下是我的尝试:
//Hand out 2 random cards for each person selection of 2,3,4,5,6,7,8,9,J,Q,K,A.
//Store these in an array with their equivalent value.
Card =[2,3,4,5,6,7,8,9,J,Q,K,A]
Also, colour of card is random red or black.
Value_AI=0
Value_Human=0
Bust_Human=0
Bust_ AI=0
All of the below is in a big loop that loops each time a player is bust
Do this for both players, until Value_AI or Value_Human>21
If colour==red then
Value=value – card
Else
Value=value+card
If Value_AI >21 then
Bust_ AI+=1
Print “Computer has bust”
Break
If Value_Human >21
Bust_ human+=1
Print “You have bust”
Break
Else
Hand out another card for both
If Bust_ AI> Bust_ human then
**//Increase the probability of getting an ace and a card with a value of 10 for the computer**
发布于 2014-01-25 02:36:23
现在,您的伪代码似乎没有包括一个选项,任何一个球员选择停止接收卡,这是中心的选择,在Blackjack。在最新的卡收到后,你需要让AI做出一个选择,它是否想要另一个。这可能是算法中将实际智能构建到人工智能中的最佳点,因此您可以增加其获胜的概率,而不需要像您在伪代码中所建议的那样进行硬编码。最简单的选择是让你的人工智能计算下一张卡将其价值超过21的概率。下面是一些伪代码(它看起来不像是在画完牌后从甲板上移除卡片,所以我没有考虑到这一点):
highest_safe = 21 - value_AI
n_safe_cards = highest_safe - 1 + 13 //the second 13 is for all of the red cards and the - 1 is because 1 is not a card
prob_safe = n_safe_cards/26 //since there are 28 possible cards (I'm assuming you didn't mean to leave 10 off your list)
if prob_safe < .5:
stop taking cards
这应该会导致你的AI赢得更多的机会,因为它将导致它发挥最佳。如果你想让它更容易被打败,你可以在它决定停止使用卡片的阈值上加入一些噪音。
发布于 2014-01-22 23:49:16
你可以让人类走在电脑前面。然后,当他们都会崩溃,这将是一个默认的计算机胜利,因为计算机将不需要去。这应该会把一个公平的游戏变成一个偏爱电脑的游戏。
https://stackoverflow.com/questions/21295295
复制相似问题