def computer_plays():
global d, table, computer_hand
target_val=table[-1].value
target_sym=table[-1].symbol
#i use this to see what the computer plays and be able to see if his AI works well
HHS2=[str(x) for x in computer_hand]
print HHS2
#//////////////
for c in computer_hand:
if c.value==target_val or c.symbol==target_sym or c.value=='A':
print "the bot plays",c
computer_hand.remove(c)
table.append(c)
if len(computer_hand)<1: return "computer wins"
elif c.value=='K' :
print ' The bot played King so it plays again !'
return computer_plays()
elif c.value=='Q':
for i in range(2) :
human_hand.append(d.draw())
print ' the bot played Queen so you have to draw two cards'
return "continue"
else: return "continue"
new_card=d.draw()
if new_card=="empty": return "count"
else:
print "the bot draws a card"
computer_hand.append(new_card)
return computer_plays()
This is just the part of the code that involves how the computer thinks and plays and there are several things used here that are defined to the rest of program
Any idea or guideline of how can i make this work will be apreciated

New Topic/Question
Reply



MultiQuote





|