def StepUpdate(self): for ep in self.energyPoints: ep.StepUpdate(self.getNodesAround(ep, Global.ELGravityRange)) for node in self.nodes: node.StepUpdate( self.getNodesAround(node, Global.ELAntigravityRange)) for node in self.nodes: node.StepUpdateMove() if Global.CreatePlaces: placesToDelete = [] for place in self.places: place.CalculateAG() if place.slowAGamount < Global.PlacesAGMin * (place.level - 1): placesToDelete.append(place) continue if place.AGamount > Global.PlacesAGNeeded * (2**(place.level) - 1): self.createPlaces(place) if place.parent != None: place.UpdateLocation() place.CalculateRange() place.SaveStatus() for place in placesToDelete: place.Delete() for node in self.nodes: p = self.GetPlaceForNode(node) if p != node.place: node.place.nodes.remove(node) node.place = p p.nodes.append(node) for ep in self.energyPointsToDelete: self.energyPoints.remove(ep) self.energyPointsToDelete = [] self.forgetEnergy = self.forgetEnergy + Global.ELForgetNodeRate cost = self.GetNodeDeleteCost() chanceForget = 100 * float(self.forgetEnergy - cost) / cost diceRoll = Global.DiceRoll() if diceRoll < chanceForget and len(self.nodes) > 0: node = Global.Choice(self.nodes) self.forgetEnergy = self.forgetEnergy - ( cost * log(max(2, node.usage), 2)) self.DeleteNode(node) Global.LogData("nc", self.Status())
def StepUpdate(self, nodesAround): cost = self.layer.GetNodeCreateCost() chanceNew = 100 * float(self.energy - cost) / cost diceRoll = Global.DiceRoll() if diceRoll < chanceNew: self.layer.CreateNode(self, self.memObject) self.energy = self.energy - cost effect = self.energy / Global.EPCreateEnergy for node in nodesAround: node.Train(self, effect) self.intenseMemObjToNodes(effect) self.energy = self.energy * Global.EPFadeCoef if self.energy < Global.EPFadeLimit: self.layer.DeleteEnergyPoint(self)