本文整理汇总了Python中ai.AI.think方法的典型用法代码示例。如果您正苦于以下问题:Python AI.think方法的具体用法?Python AI.think怎么用?Python AI.think使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ai.AI
的用法示例。
在下文中一共展示了AI.think方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Client
# 需要导入模块: from ai import AI [as 别名]
# 或者: from ai.AI import think [as 别名]
class Client(object):
def __init__(self):
self.conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
def connect(self, host, port):
self.conn.connect((host, port))
info = self.conn.recv(1024)
row, col, player = info.split(" ")
print "-------------Status------------"
print "WORLD_ROWS : %s" %(row)
print "WORLD_COLS : %s" %(col)
print "PLAYER : %s" %(player)
print "-------------------------------\n\n"
print "Connected. Waiting..."
if int(player) == 1: print "You are RED."
else: print "You are BLUE."
self.ai = AI(int(row), int(col), int(player))
self.conn.send(self.ai.name+"\n")
data = self.conn.recv(1024)
print "Teamname:", self.ai.name
print "Opponent:", data.strip()
def play(self, viewflag=False) :
if viewflag == True:
gamescene = Gamescene(self.ai)
while True:
recvdata = self.conn.recv(4096)
if recvdata in ["WIN\n", "DRAW\n", "LOSE\n"]:
print "Result:", recvdata
break
recvdata = recvdata.strip().split(" ")
self.ai.update(recvdata[1])
print "*" * 20
print "ai.map update : "
print self.ai.map
print "*" * 20
response = self.ai.think()
self.conn.send(response)
if viewflag:
gamescene.update()
gc.collect()
def close(self):
self.conn.close()