本文整理汇总了Python中Network.toString方法的典型用法代码示例。如果您正苦于以下问题:Python Network.toString方法的具体用法?Python Network.toString怎么用?Python Network.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network.toString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: manageOrder
# 需要导入模块: import Network [as 别名]
# 或者: from Network import toString [as 别名]
def manageOrder(socket, order, game):
orderStr = Network.toString(order)
print("Received order %s" % orderStr)
if orderStr == "SET":
n = Network.toInt(socket.recv(1))
m = Network.toInt(socket.recv(1))
game.init(n, m)
elif orderStr == "HUM":
# Passing: legacy rule
# Only reading data from socket
n = Network.toInt(socket.recv(1))
for k in range(n):
x = Network.toInt(socket.recv(1))
y = Network.toInt(socket.recv(1))
elif orderStr == "HME":
x = Network.toInt(socket.recv(1))
y = Network.toInt(socket.recv(1))
game.initHome(x, y)
elif orderStr == "MAP" or orderStr == "UPD":
n = Network.toInt(socket.recv(1))
for k in range(n):
x = Network.toInt(socket.recv(1))
y = Network.toInt(socket.recv(1))
h = Network.toInt(socket.recv(1))
v = Network.toInt(socket.recv(1))
w = Network.toInt(socket.recv(1))
game.setHuman(x, y, h)
game.setVampire(x, y, v)
game.setWerewolf(x, y, w)
print(game)
print("================")
human = game.getHuman()
creatures = game.getCreatures()
for creature in creatures:
agent = IA.Agent()
agent.i = creature["coord"][0]
agent.j = creature["coord"][1]
agent.count = creature["count"]
print("Agent: %s" % str(creature["coord"]))
for h in human:
print("Human: %s. %f" % (str(h["coord"]), agent.cost(h["count"], h["coord"][0], h["coord"][1], game.n)))
elif orderStr == "END":
pass
#ici on met fin à la partie en cours
#Réinitialisez votre modèle
elif orderStr == "BYE":
raise ByeException()