本文整理汇总了Python中NeuralNetwork.NeuralNetwork.update方法的典型用法代码示例。如果您正苦于以下问题:Python NeuralNetwork.update方法的具体用法?Python NeuralNetwork.update怎么用?Python NeuralNetwork.update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NeuralNetwork.NeuralNetwork
的用法示例。
在下文中一共展示了NeuralNetwork.update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AI
# 需要导入模块: from NeuralNetwork import NeuralNetwork [as 别名]
# 或者: from NeuralNetwork.NeuralNetwork import update [as 别名]
#.........这里部分代码省略.........
self.lastCommand = "voir"
def funcPrend(self):
case = self.cases[0]
if len(case) > 0:
self.socket.sendData("prend " + case[0])
case.remove(case[0])
else:
eprint("Impossible to execute 'prend' ")
self.lastCommand = "prend"
def funcExpulse(self):
print ("Expulse ?")
self.lastCommand = "prend"
def funcIncantation(self):
self.putResOnCase()
self.socket.sendData("incantation")
self.lastCommand = "incantation"
def funcFork(self):
print ("fork")
self.lastCommand = "fork"
def chooseAnAction(self):
inputs = []
inputs.append(self.life)
inputs.append(self.level)
inputs.append(self.freePlace)
inputs.append(self.getCaseLevel(0))
inputs.append(self.getCaseLevel(1))
inputs.append(self.getCaseLevel(2))
inputs.append(self.getCaseLevel(3))
inputs.append(self.getCaseFood(0))
inputs.append(self.getCaseFood(1))
inputs.append(self.getCaseFood(2))
inputs.append(self.getCaseFood(3))
inputs.append(self.isLevelComplete())
inputs.append(self.canIncant())
print ("INPUTS:", inputs)
actionValue = self.neuralNetwork.update(inputs)[0]
actionChoosen = self.getRangeAction(actionValue)
if actionChoosen == "":
eprint("Error in value of the neuralNetwork:", actionValue)
print (actionValue, "--->", actionChoosen)
command = input("Command:")
if command == "quit":
self.neuralNetwork.save()
sys.exit()
elif command == "learn":
pass #learn it
Macro.CommandRef[actionChoosen](self)
def updateInfo(self):
message = ""
self.socket.sendData("inventaire")
while message == "":
message = self.socket.selectData()
self.life = int(message.replace("{", "").replace("}", "").split(",")[0].split(" ")[1])
def initData(self, message):
# TODO receive "{xx,xx,,,,}\n9\r\n with voir + connect_nbr CHANGE PARSING
message = message.split("\n")
self.getCase(message[0])
self.freePlace = int(message[1])
return False
def receiveMessage(self, message):
if self.firstReceive is True:
self.firstReceive = self.initData(message)
elif message == "mort":
return
if self.lastCommand != "":
if self.lastCommand == "voir" and message[0] == "{":
self.getCase(message)
self.lastCommand = ""
print (time.strftime("%H:%M:%S"), ":", message)
def run(self):
self.createNeuralNetwork(False)
while True:
message = self.socket.selectData()
if message:
self.receiveMessage(message)
if self.firstAction is True:
self.socket.sendData("voir")
self.socket.sendData("connect_nbr")
self.firstAction = False
if self.lastCommand == "" and self.firstReceive is False:
self.updateInfo()
self.chooseAnAction()
message = ""