当前位置: 首页>>代码示例>>Python>>正文


Python NeuralNetwork.update方法代码示例

本文整理汇总了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 = ""
开发者ID:Nyrii,项目名称:-EPITECH-Zappy,代码行数:104,代码来源:AI.py


注:本文中的NeuralNetwork.NeuralNetwork.update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。