def __init__(self, id, name=None, nextCapacityStationBufferId=None,**kw): Exit.__init__(self, id, name) self.isLocked=True self.nextCapacityStationBufferId=nextCapacityStationBufferId # the id of the next station. If it is None it # means it is the end of the system. self.nextCapacityStationBuffer=None # the next buffer. If it is None it from Globals import G G.CapacityStationExitList.append(self)
def initialize(self): Exit.initialize(self) self.isLocked=True # list that contains the entities that are just obtained so that they can be # moved to the next buffer self.currentlyObtainedEntities=[] # find the next buffer if self.nextCapacityStationBufferId: from Globals import G # find the project that the capacity entity is part of for capacityStationBuffer in G.CapacityStationBufferList: if capacityStationBuffer.id==self.nextCapacityStationBufferId: self.nextCapacityStationBuffer=capacityStationBuffer break
def InstantiateRooms(): global roomDictionary global currentRoom #Assign the dictionary of rooms its rooms' info. roomDictionary["room1"] = Room( "This is our first test room", [Exit("n", "room2"), Exit("e", "room3")]) roomDictionary["room2"] = Room("You have made it to the second room.", [Exit("s", "room1")]) roomDictionary["room3"] = Room("Third room lads lads lads lads", [Exit("w", "room1")]) #Assign the starting room to be the current room currentRoom = roomDictionary['room1']
def getEntity(self): activeEntity=Exit.getEntity(self) alreadyWorkedDict=activeEntity.capacityProject.alreadyWorkedDict stationId=self.giver.id alreadyWorkedDict[stationId]+=activeEntity.requiredCapacity
def main(argv=[], input_data=None): argv = argv or sys.argv[1:] #create an empty list to store all the objects in G.ObjList = [] S = BatchSource('S1', 'Source', interArrivalTime={'Fixed': { 'mean': 0.5 }}, item=Batch, batchNumberOfUnits=100) E = Exit('E1', 'Exit') G.ObjList.append(S) G.ObjList.append(E) # G.RouterList=[] if input_data is None: # user passes the topology filename as first argument to the program filename = argv[0] try: # try to open the file with the inputs G.CMSDFile = open( filename, "r") # global variable holding the file to be opened except IOError, IndexError: print "%s could not be open" % filename return "ERROR" G.InputData = G.CMSDFile.read( ) # pass the contents of the input file to the global var InputData
def __init__(self, maze_filename): """Initialize the game manager object. Arguments: maze_filename - name of human readable/writable text file containing the maze definition for use in single player mode """ gs = GameState.singleton() self.gs = gs gs.nickname = input( "For multiplayer game, enter your nickname (default is single player):" ) if gs.nickname: gs.multiplayer = True # TODO - should be assigned by MazeServer while True: new_color_text = input( f"Choose a color code ({', '. join(list(gs.colors()))}) (default is w):" ) if not new_color_text: break if new_color_text in gs.colors(): gs.color = gs.colors()[new_color_text] break print( f"Unknown color code: '{new_color_text}''. Please try again." ) print(f"Selected {gs.color}.") gs.connection = MazeClient('127.0.0.1', 8089) gs.connection.Loop() # server will send the maze data while not gs.maze: gs.connection.Loop() else: gs.maze = Maze(maze_filename) # loop through maze file and instanciate the specified objects for i in range(0, gs.maze.height): for j in range(0, gs.maze.width): ch = gs.maze.file_rows[i][j] if ch == 'P': gs.player = Player((i, j)) elif ch == 'N' and not gs.multiplayer: Npc((i, j)) elif ch == 'E' and not gs.multiplayer: Exit(gs.maze, (i, j)) # boiler plate pygame initialization (screen just black after this) gs.camera = Camera()
def getEntity(self): activeEntity = Exit.getEntity(self) #run the default method from Globals import G # for all the entities in the EntityList for entity in G.EntityList: requiredParts=entity.getRequiredParts() if requiredParts: # if the activeEntity is in the requierdParts of the entity if activeEntity in requiredParts: # if the entity that requires the activeEntity can proceed then signal the currentStation of the entity if entity.checkIfRequiredPartsReady() and entity.currentStation.expectedSignals['canDispose']: self.sendSignal(receiver=entity.currentStation, signal=entity.currentStation.canDispose) return activeEntity
def getEntity(self): activeEntity = Exit.getEntity(self) #run the default method from Globals import G # for all the entities in the EntityList for entity in G.EntityList: requiredParts = entity.getRequiredParts() if requiredParts: # if the activeEntity is in the requierdParts of the entity if activeEntity in requiredParts: # if the entity that requires the activeEntity can proceed then signal the currentStation of the entity if entity.checkIfRequiredPartsReady( ) and entity.currentStation.expectedSignals['canDispose']: self.sendSignal( receiver=entity.currentStation, signal=entity.currentStation.canDispose) return activeEntity
def example_simulation(): size_scene = (100,100)#size_scene[0]==horizontal and size_scene[1]==vertical obstacles = [Obstacle((70,40),10,60),Obstacle((20,50),50,10),Obstacle((30,10),10,40)] exits = [Exit((85,99),10,2)] # warning, the size must be chosen as an integer, agent.size*precision must preferably be an integer to improve speed agents = [Agent((10,90),1),Agent((10,80),1),Agent((10,70),1),Agent((10,60),2),Agent((10,50),2),Agent((10,40),2) ,Agent((10,30),2),Agent((10,20),2),Agent((10,10),2),Agent((14,90),2),Agent((14,80),2),Agent((14,70),2) ,Agent((14,60),2),Agent((14,50),2),Agent((14,40),2),Agent((14,30),2),Agent((14,20),2),Agent((14,10),4) ] time_simulation = 40 #in seconds dt = .1 # in seconds launch_simulation(size_scene,obstacles,exits,agents,time_simulation,dt)
def create_exit_objects(): ''' This function will create exit objects from a read file and return a nested list ''' # Declare Variables exit_list = [] # Reading files and combining lists contents = read_file('Exit Table1.csv') contents2 = read_file('Exit Table2.csv') contents3 = read_file('Exit Table3.csv') contents.extend(contents2) contents.extend(contents3) # Create Client Objects for x in range(0, len(contents)): exit_list.append( Exit(contents[x][0], contents[x][1], contents[x][2], contents[x][3], contents[x][4], contents[x][5], contents[x][6])) return exit_list
agents.append(agent1) agents.append(agent2) obstacles = [] obstacle1 = Obstacle((-2, 2), 4, 1) obstacle2 = Obstacle((4, 0), 1, 4) obstacle3 = Obstacle((-4, -3), 3, 1) obstacle4 = Obstacle((-2, 4), 1, 2) #obstacles.append(obstacle1) #obstacles.append(obstacle2) #obstacles.append(obstacle3) #obstacles.append(obstacle2) exits = [] exit1 = Exit((4, 4), 2, 2) #exits.append(exit1) agent1.update_position(agents, obstacles, exits, 1, (10, 10)) agent2.update_position(agents, obstacles, exits, 1, (10, 10)) for obstacle in obstacles: ax1.add_patch( patches.Rectangle(obstacle.position, obstacle.width, obstacle.height)) for exit in exits: ax1.add_patch(patches.Rectangle(exit.position, exit.width, exit.height)) for agent in agents: print agent colour = agent.get_color_agent()
import variables, graphics, enemies from enemies import enemyforspecialbattle from conversations import getconversation from mapsvars import * from graphics import snowland from Exit import Exit from Rock import Rock from pygame import Rect # snowentrance########################################################################### snowentrance = Map(snowland(650, 500, True), []) snowentrance.populate_with("snowpinetree", randint(4, 10)) snowentrance.exitareas = [ Exit("right", False, "jeremyhome", "left", "same"), Exit("left", False, "snowarea1", "right", "same") ] snowentrance.enemies = enemies.snowenemies snowentrance.lvrange = [6] # snowarea1############################################################################## snowarea1 = Map(snowland(700, 500), []) snowarea1.populate_with("snowpinetree", randint(10, 15)) snowarea1.lvrange = [6, 7] snowarea1.enemies = enemies.snowenemies snowarea1.exitareas = [ Exit("right", False, "snowentrance", "left", "same"), Exit("left", False, "hoppingtreearea", "right", "same")
def initialize(self): from Globals import G self.previous = G.ObjList Exit.initialize(self) #run default behaviour
def canAccept(self, callerObject=None): if self.isLocked: return False return Exit.canAccept(self)
], shadowsp=False) eatfromstash = Conversation("eatfromstash", [], speaksafter=[[], [], [], [], [], [], [], [], [getconversation("hungryspeak")]], switchtheserocks="stash") eatfromstashoffset = 10 eatfromstash.area = [ 131 + eatfromstashoffset, 61, GR["stash00"]["w"] - 2 * eatfromstashoffset, GR["stash00"]["h"] ] doorexit = Exit([35 + honeyw / 2, 165, 37 - honeyw, extraarea], True, 'outside1', GR["honeyhouseoutside"]["w"] * 0.3 + houserock.x, GR["honeyhouseoutside"]["h"] - honeyh + honeyfeetheight - 20 * p) doorexit.eventrequirements = [EventRequirement("letter")] blockexit = getconversation("hungry") blockexit.area = doorexit.area blockexit.eventrequirements = [EventRequirement("letter", -1, 1)] honeyhome.conversations = [eatfromstash, blockexit] honeyhome.startpoint = [28, 39] letterexit = Exit([67, 100, 20, 30], True, 'letter', GR["paper"]['w'] * (3 / 10), 0) letterexit.storyevent = "letter"
def readResources(): G.SourceList = [] G.MachineList = [] G.ExitList = [] G.QueueList = [] G.RepairmanList = [] G.AssemblyList = [] G.DismantleList = [] G.ConveyerList = [] resource = (G.CMSDData.getElementsByTagName('Resource')) #this loop will search in all the objects for repairmen and create them. #repairmen have to be created first since they may be used in the creation of the other objects for i in range(len(resource)): #get the class try: resourceClass = resource[i].getElementsByTagName( 'ResourceClassIdentifier') resourceClass = resourceClass[0].toxml().replace( '<ResourceClassIdentifier>', '').replace('</ResourceClassIdentifier>', '') except IndexError: continue if resourceClass == 'Repairman': id = resource[i].getElementsByTagName('Identifier') id = id[0].toxml().replace('<Identifier>', '').replace('</Identifier>', '') name = resource[i].getElementsByTagName('Name') name = name[0].toxml().replace('<Name>', '').replace('</Name>', '') property = resource[i].getElementsByTagName('Property') for j in range(len(property)): propertyName = property[j].getElementsByTagName('Name') propertyName = propertyName[0].toxml().replace( '<Name>', '').replace('</Name>', '') if propertyName == 'capacity': capacity = property[j].getElementsByTagName('Value') capacity = int(capacity[0].toxml().replace( '<Value>', '').replace('</Value>', '')) R = Repairman(id, name, capacity) G.RepairmanList.append(R) for i in range(len(resource)): #get the class try: resourceClass = resource[i].getElementsByTagName( 'ResourceClassIdentifier') resourceClass = resourceClass[0].toxml().replace( '<ResourceClassIdentifier>', '').replace('</ResourceClassIdentifier>', '') except IndexError: continue if resourceClass == 'Source': id = resource[i].getElementsByTagName('Identifier') id = id[0].toxml().replace('<Identifier>', '').replace('</Identifier>', '') name = resource[i].getElementsByTagName('Name') name = name[0].toxml().replace('<Name>', '').replace('</Name>', '') property = resource[i].getElementsByTagName('Property') for j in range(len(property)): propertyName = property[j].getElementsByTagName('Name') propertyName = propertyName[0].toxml().replace( '<Name>', '').replace('</Name>', '') if propertyName == 'partType': partType = property[j].getElementsByTagName('Value') partType = (partType[0].toxml().replace( '<Value>', '').replace('</Value>', '')) entity = str_to_class(partType) elif propertyName == 'interarrivalTime': unit = property[j].getElementsByTagName('Unit') unit = unit[0].toxml().replace('<Unit>', '').replace('</Unit>', '') distribution = property[j].getElementsByTagName( 'Distribution') distributionType = distribution[0].getElementsByTagName( 'Name') distributionType = distributionType[0].toxml().replace( '<Name>', '').replace('</Name>', '') distributionParameter = distribution[ 0].getElementsByTagName('DistributionParameter') distributionParameterName = distributionParameter[ 0].getElementsByTagName('Name') distributionParameterName = distributionParameterName[ 0].toxml().replace('<Name>', '').replace('</Name>', '') mean = distributionParameter[0].getElementsByTagName( 'Value') mean = float(mean[0].toxml().replace('<Value>', '').replace( '</Value>', '')) S = Source(id, name, distributionType, mean, entity) G.SourceList.append(S) G.ObjList.append(S) elif resourceClass == 'Machine': id = resource[i].getElementsByTagName('Identifier') id = id[0].toxml().replace('<Identifier>', '').replace('</Identifier>', '') name = resource[i].getElementsByTagName('Name') name = name[0].toxml().replace('<Name>', '').replace('</Name>', '') property = resource[i].getElementsByTagName('Property') for j in range(len(property)): propertyName = property[j].getElementsByTagName('Name') propertyName = propertyName[0].toxml().replace( '<Name>', '').replace('</Name>', '') if propertyName == 'ProcessTime': unit = property[j].getElementsByTagName('Unit') unit = unit[0].toxml().replace('<Unit>', '').replace('</Unit>', '') distribution = property[j].getElementsByTagName( 'Distribution') distributionType = distribution[0].getElementsByTagName( 'Name') distributionType = distributionType[0].toxml().replace( '<Name>', '').replace('</Name>', '') distributionParameter = distribution[ 0].getElementsByTagName('DistributionParameter') mean = 0 stdev = 0 min = 0 max = 0 availability = 0 failureDistribution = None for k in range(len(distributionParameter)): distributionParameterName = distributionParameter[ 0].getElementsByTagName('Name') distributionParameterName = distributionParameterName[ 0].toxml().replace('<Name>', '').replace('</Name>', '') if distributionParameterName == 'mean': mean = distributionParameter[ 0].getElementsByTagName('Value') mean = float(mean[0].toxml().replace( '<Value>', '').replace('</Value>', '')) elif distributionParameterName == 'stdev': stdev = distributionParameter[ 0].getElementsByTagName('Value') stdev = float(stdev[0].toxml().replace( '<Value>', '').replace('</Value>', '')) elif distributionParameterName == 'min': min = distributionParameter[ 0].getElementsByTagName('Value') min = float(mean[0].toxml().replace( '<Value>', '').replace('</Value>', '')) elif distributionParameterName == 'max': max = distributionParameter[ 0].getElementsByTagName('Value') max = float(mean[0].toxml().replace( '<Value>', '').replace('</Value>', '')) elif propertyName == 'MeanTimeToFailure': unit = property[j].getElementsByTagName('Unit') unit = unit[0].toxml().replace('<Unit>', '').replace('</Unit>', '') distribution = property[j].getElementsByTagName( 'Distribution') failureDistribution = distribution[0].getElementsByTagName( 'Name') failureDistribution = failureDistribution[0].toxml( ).replace('<Name>', '').replace('</Name>', '') distributionParameter = distribution[ 0].getElementsByTagName('DistributionParameter') for k in range(len(distributionParameter)): distributionParameterName = distributionParameter[ 0].getElementsByTagName('Name') distributionParameterName = distributionParameterName[ 0].toxml().replace('<Name>', '').replace('</Name>', '') if distributionParameterName == 'mean': MTTF = distributionParameter[ 0].getElementsByTagName('Value') MTTF = float(MTTF[0].toxml().replace( '<Value>', '').replace('</Value>', '')) elif distributionParameterName == 'availability': availability = distributionParameter[ 0].getElementsByTagName('Value') availability = (availability[0].toxml().replace( '<Value>', '').replace('</Value>', '')) elif propertyName == 'MeanTimeToRepair': unit = property[j].getElementsByTagName('Unit') unit = unit[0].toxml().replace('<Unit>', '').replace('</Unit>', '') distribution = property[j].getElementsByTagName( 'Distribution') failureDistribution = distribution[0].getElementsByTagName( 'Name') failureDistribution = failureDistribution[0].toxml( ).replace('<Name>', '').replace('</Name>', '') distributionParameter = distribution[ 0].getElementsByTagName('DistributionParameter') for k in range(len(distributionParameter)): distributionParameterName = distributionParameter[ 0].getElementsByTagName('Name') distributionParameterName = distributionParameterName[ 0].toxml().replace('<Name>', '').replace('</Name>', '') if distributionParameterName == 'mean': MTTR = distributionParameter[ 0].getElementsByTagName('Value') MTTR = float(MTTR[0].toxml().replace( '<Value>', '').replace('</Value>', '')) elif distributionParameterName == 'availability': availability = distributionParameter[ 0].getElementsByTagName('Value') availability = (availability[0].toxml().replace( '<Value>', '').replace('</Value>', '')) elif propertyName == 'RepairmanRequired': repairmanID = property[j].getElementsByTagName( 'ResourceIdentifier') repairmanID = (repairmanID[0].toxml().replace( '<ResourceIdentifier>', '').replace('</ResourceIdentifier>', '')) if repairmanID == 'None': repairman = repairmanID else: for j in range(len(G.RepairmanList)): if (G.RepairmanList[j].id == repairmanID): repairman = G.RepairmanList[j] M = Machine(id, name, 1, distribution=distributionType, failureDistribution=failureDistribution, MTTF=MTTF, MTTR=MTTR, availability=availability, repairman=repairman, mean=mean, stdev=stdev, min=min, max=max) G.MachineList.append(M) G.ObjList.append(M) elif resourceClass == 'Queue': id = resource[i].getElementsByTagName('Identifier') id = id[0].toxml().replace('<Identifier>', '').replace('</Identifier>', '') name = resource[i].getElementsByTagName('Name') name = name[0].toxml().replace('<Name>', '').replace('</Name>', '') property = resource[i].getElementsByTagName('Property') isDummy = 0 capacity = 2 for j in range(len(property)): propertyName = property[j].getElementsByTagName('Name') propertyName = propertyName[0].toxml().replace( '<Name>', '').replace('</Name>', '') if propertyName == 'capacity': capacity = property[j].getElementsByTagName('Value') capacity = int(capacity[0].toxml().replace( '<Value>', '').replace('</Value>', '')) if propertyName == 'isDummy': capacity = property[j].getElementsByTagName('Value') capacity = int(capacity[0].toxml().replace( '<Value>', '').replace('</Value>', '')) Q = Queue(id, name, capacity, isDummy) G.QueueList.append(Q) G.ObjList.append(Q) elif resourceClass == 'Exit': id = resource[i].getElementsByTagName('Identifier') id = id[0].toxml().replace('<Identifier>', '').replace('</Identifier>', '') name = resource[i].getElementsByTagName('Name') name = name[0].toxml().replace('<Name>', '').replace('</Name>', '') E = Exit(id, name) G.ExitList.append(E) G.ObjList.append(E)
def initialize(self): from Globals import G self.previous=G.ObjList Exit.initialize(self) #run default behaviour
table, littleletter, Rock(stashlist, 131, 55, [0, 0.9, 1, 0.1], name="stash")], shadowsp = False) eatfromstash = Conversation("eatfromstash", [], speaksafter = [[],[],[],[],[],[],[],[], [getconversation("hungryspeak")]], switchtheserocks="stash") eatfromstashoffset = 10 eatfromstash.area = [131+eatfromstashoffset, 61, GR["stash00"]["w"]-2*eatfromstashoffset, GR["stash00"]["h"]] doorexit = Exit([35 + honeyw / 2, 165, 37 - honeyw, extraarea], True, 'outside1', GR["honeyhouseoutside"]["w"] * 0.3 + houserock.x, GR["honeyhouseoutside"]["h"] - honeyh + honeyfeetheight-20*p) doorexit.eventrequirements = [EventRequirement("letter")] blockexit = getconversation("hungry") blockexit.area = doorexit.area blockexit.eventrequirements = [EventRequirement("letter", -1, 1)] honeyhome.conversations = [eatfromstash, blockexit] honeyhome.startpoint = [28, 39] letterexit = Exit([67, 100, 20, 30], True, 'letter', GR["paper"]['w']*(3/10), 0) letterexit.storyevent = "letter"
from Source import Source from Exit import Exit from Part import Part from Queue import Queue from Globals import G import ExcelHandler import Globals G.trace = "Yes" S = Source('S1', 'Source', mean=1, item=Part) M1 = Machine('M1', 'Machine1', mean=0.75) Q1 = Queue('Q1', 'Queue1', capacity=infinity) M2 = Machine('M2', 'Machine2', mean=0.75) Q2 = Queue('Q2', 'Queue2', capacity=infinity) E = Exit('E1', 'Exit') #define predecessors and successors for the objects S.defineRouting([M1]) M1.defineRouting([S], [Q1]) Q1.defineRouting([M1], [M2]) M2.defineRouting([Q1], [Q2]) Q2.defineRouting([M2]) argumentDict = {'from': 'Q2', 'to': 'E1', 'safetyStock': 70, 'consumption': 20} EG = EventGenerator(id="EV", name="ExcessEntitiesMover", start=60, interval=60, method=Globals.moveExcess, argumentDict=argumentDict)
def outputResultsJSON(self): # output results only for the last exit if not self.nextCapacityStationBuffer: Exit.outputResultsJSON(self)
from Location import Location from Exit import Exit from Player import Player import random room1 = Location(["cheese", "tree", "monkey"], ["north"], "room 1") room2 = Location(["plant", "painting"], ["south"], "room 2") exit1 = Exit() room1.printAttributes() room2.printAttributes() player1 = Player() player1.printAttributes() while player1.room == room1: print "game loop active" player1.playerReply() player1.printAttributes() room1.printAttributes()
def main(simulation): controller = Controller(168) machine_transitions = calculate_machine_probs() waste_probs = calculate_waste_probs() entry = Entry("Recibidor", exponential, [5.108333], gamma, [0.913, 2380]) reception = Queue("Recepcion") machine = MachineStation("Maquina", fixed, [0], machine_transitions) machine_waste = Exit("Descarte maquina") band_12 = Queue("Banda 12") band_14 = Queue("Banda 14") band_16 = Queue("Banda 16") band_18 = Queue("Banda 18") band_20 = Queue("Banda 20") band_22 = Queue("Banda 22") band_24 = Queue("Banda 24") band_26 = Queue("Banda 26") band_28 = Queue("Banda 28") band_30 = Queue("Banda 30") band_32 = Queue("Banda 32") cali_12 = Station("Calibre 12", fixed, [0.002318], [waste_probs[12], 1 - waste_probs[12]]) cali_14 = Station("Calibre 14", fixed, [0.002318], [waste_probs[14], 1 - waste_probs[14]]) cali_16 = Station("Calibre 16", fixed, [0.002318], [waste_probs[16], 1 - waste_probs[16]]) cali_18 = Station("Calibre 18", fixed, [0.002318], [waste_probs[18], 1 - waste_probs[18]]) cali_20 = Station("Calibre 20", fixed, [0.002031], [waste_probs[20], 1 - waste_probs[20]]) cali_22 = Station("Calibre 22", fixed, [0.000924], [waste_probs[22], 1 - waste_probs[22]]) cali_24 = Station("Calibre 24", fixed, [0.004010], [waste_probs[24], 1 - waste_probs[24]]) cali_26 = Station("Calibre 26", fixed, [0.001590], [waste_probs[26], 1 - waste_probs[26]]) cali_28 = Station("Calibre 28", fixed, [0.002643], [waste_probs[28], 1 - waste_probs[28]]) cali_30 = Station("Calibre 30", fixed, [0.006250], [waste_probs[30], 1 - waste_probs[30]]) cali_32 = Station("Calibre 32", fixed, [0.016444], [waste_probs[32], 1 - waste_probs[32]]) descarte_12 = Exit("Descarte 12") descarte_14 = Exit("Descarte 14") descarte_16 = Exit("Descarte 16") descarte_18 = Exit("Descarte 18") descarte_20 = Exit("Descarte 20") descarte_22 = Exit("Descarte 22") descarte_24 = Exit("Descarte 24") descarte_26 = Exit("Descarte 26") descarte_28 = Exit("Descarte 28") descarte_30 = Exit("Descarte 30") descarte_32 = Exit("Descarte 32") wait_small_p = Queue("Espera palet pequeño") wait_big_p = Queue("Espera palet grande") palet_peque = PaletStation("Palet pequeño", fixed, [0], 980) palet_grande = PaletStation("Palet grande", fixed, [0], 1180) cold_room = Queue("Cuarto frio") dispacher = Station("Despachador", exponential, [92.52], [1]) exit = Exit("Salida") entry.connect_with(reception) reception.connect_with(machine) machine.connect_with(band_12) machine.connect_with(band_14) machine.connect_with(band_16) machine.connect_with(band_18) machine.connect_with(band_20) machine.connect_with(band_22) machine.connect_with(band_24) machine.connect_with(band_26) machine.connect_with(band_28) machine.connect_with(band_30) machine.connect_with(band_32) machine.connect_with(machine_waste) band_12.connect_with(cali_12) band_14.connect_with(cali_14) band_16.connect_with(cali_16) band_18.connect_with(cali_18) band_20.connect_with(cali_20) band_22.connect_with(cali_22) band_24.connect_with(cali_24) band_26.connect_with(cali_26) band_28.connect_with(cali_28) band_30.connect_with(cali_30) band_32.connect_with(cali_32) cali_12.connect_with(descarte_12) cali_14.connect_with(descarte_14) cali_16.connect_with(descarte_16) cali_18.connect_with(descarte_18) cali_20.connect_with(descarte_20) cali_22.connect_with(descarte_22) cali_24.connect_with(descarte_24) cali_26.connect_with(descarte_26) cali_28.connect_with(descarte_28) cali_30.connect_with(descarte_30) cali_32.connect_with(descarte_32) cali_12.connect_with(wait_big_p) cali_14.connect_with(wait_big_p) cali_16.connect_with(wait_big_p) cali_18.connect_with(wait_big_p) cali_20.connect_with(wait_big_p) cali_22.connect_with(wait_big_p) cali_24.connect_with(wait_small_p) cali_26.connect_with(wait_small_p) cali_28.connect_with(wait_small_p) cali_30.connect_with(wait_small_p) cali_32.connect_with(wait_small_p) wait_small_p.connect_with(palet_peque) wait_big_p.connect_with(palet_grande) palet_peque.connect_with(cold_room) palet_grande.connect_with(cold_room) cold_room.connect_with(dispacher) dispacher.connect_with(exit) entry.execute(None) controller.start_simulation() print("simulation %d finished" % simulation) queues = [ band_12, band_14, band_16, band_18, band_20, band_22, band_24, band_26, band_28, band_30, band_32 ] exits = [ machine_waste, descarte_12, descarte_14, descarte_16, descarte_18, descarte_20, descarte_22, descarte_24, descarte_26, descarte_28, descarte_30, descarte_32, exit ] stations = [ palet_peque, palet_grande, cali_12, cali_14, cali_16, cali_18, cali_20, cali_22, cali_24, cali_26, cali_28, cali_30, cali_32 ] data_queue = [] for queue in queues: name, items, lenght, max_wait, min_wait, avg_wait = queue.get_info() data_queue.append([simulation, name, max_wait, avg_wait]) data_exit = [] for exit in exits: name, kg = exit.get_info() data_exit.append([simulation, name, kg]) data_station = [] for station in stations: name, kg = station.get_info() data_station.append([simulation, name, kg]) return data_queue, data_exit, data_station
b * 5 - GR["rabbithole"]["h"], [0, 3 / 4, 1, 1 / 4]) jmyman.background_range = hole.background_range.copy() dancelionanim = Animation(["dancelion0", "dancelion1"], (60000 / 130) * 2) dancelion = Rock(dancelionanim, b / 2, b * 4, [0, 3 / 4, 1, 1 / 4]) dancelion.updatealways = True jeremyhome = Map(rgrassland, [hole, jmyman, dancelion]) dontputrockslist = [dancelion.getrect(), jmyman.getrect()] jeremyhome.populate_with("greyrock", randint(0, 2), dontputrockslist) jeremyhome.populate_with("pinetree", randint(3, 8), dontputrockslist) jeremyhome.populate_with("flower", randint(15, 25), dontputrockslist) jeremyhome.exitareas = [ Exit("right", False, 'outside1', "left", "same"), Exit("left", False, 'snowentrance', "right", "same") ] jeremy = getconversation("jeremy") jeremy.area = [ b * 5 + GR["rabbithole"]["w"] - (honeyw / 2), b * 5 - GR["rabbithole"]["h"], GR["rabbithole"]["w"] - (honeyw / 2), GR["rabbithole"]["h"] ] jeremy.eventrequirements = [EventRequirement("beatsteve", -1, 1)] jeremyaftersteve = getconversation("jeremyaftersteve") jeremyaftersteve.area = jeremy.area.copy() jeremyaftersteve.eventrequirements = [EventRequirement("beatsteve")] dancelionpass = getconversation("dancelionpass")
def __init__(self, roomJson): import threading from Exit import Exit import Engine.RoomEngine from Inventory.RoomInventory import RoomInventory from SpawnTemplate import SpawnTemplate EventReceiver.__init__(self) attributes = { 'playerSemaphore' : threading.BoundedSemaphore(1), 'roomID' : '', 'name' : '', 'description' : [], 'exits' : [], 'players' : [], 'npcs' : [], 'spawnableNPCs' : [], 'inventory' : None, 'spawnTemplates' : [] } out_adjusters = [] inventory = None spawnTemplates = None for key in attributes.keys(): self.attributes[key] = attributes[key] for key in roomJson.keys(): if key == 'exits': for exitJson in roomJson[key]: exit = Exit() for field in exitJson.keys(): exit.attributes[field] = exitJson[field] self.attributes[key].append(exit) elif key == 'eventHandlers': for element in roomJson[key]: adjusters = (lambda dictionary: dictionary.has_key('adjusters') and dictionary['adjusters'] or None)(element) self.addEventHandlerByNameWithAdjusters(element['name'], adjusters) elif key == 'inventory': inventory = roomJson[key] elif key == 'spawnTemplates': spawnTemplates = roomJson[key] elif key == 'out_adjusters': out_adjusters = roomJson[key] else: self.attributes[key] = roomJson[key] self.addEventHandlerByNameWithAdjusters('Environment.EventHandlers.Room.ActorAttemptedMovementEventHandler', None) self.addEventHandlerByNameWithAdjusters('Environment.EventHandlers.Room.ActorMovedFromRoomEventHandler', None) self.addEventHandlerByNameWithAdjusters('Environment.EventHandlers.Room.ActorAddedToRoomEventHandler', None) self.addEventHandlerByNameWithAdjusters('Environment.EventHandlers.Room.ActorObservedHandler', None) self.addEventHandlerByNameWithAdjusters('Environment.EventHandlers.Room.WasObservedHandler', None) self.addEventHandlerByNameWithAdjusters('Environment.EventHandlers.Room.ActorEmotedHandler', None) self.addEventHandlerByNameWithAdjusters('Environment.EventHandlers.Room.PlayerLogoutHandler', None) self.addEventHandlerByNameWithAdjusters('Environment.EventHandlers.Room.SpellCastAttempted', None) self.addEventHandlerByNameWithAdjusters('Environment.EventHandlers.Room.ActorAttemptedItemGrabHandler', None) self.addEventHandlerByNameWithAdjusters('Environment.EventHandlers.Room.ActorGrabbedItemHandler', None) self.addEventHandlerByNameWithAdjusters('Environment.EventHandlers.Room.ItemDroppedHandler', None) Engine.RoomEngine.addEventSubscriber(self) EventEmitter.__init__(self, out_adjusters) if inventory != None: self.attributes['inventory'] = RoomInventory(inventory, self) else: self.attributes['inventory'] = RoomInventory(None, self) if spawnTemplates != None: for template in spawnTemplates: spawnTemplate = SpawnTemplate(template, self) self.attributes['spawnTemplates'].append(spawnTemplate)
honeyh = GR["honeyside0"]["h"] extraarea = 50 print(variables.width) # outside2############################################################################################################## b = GR["leftturn"]["w"] outsideheight = GR["leftturn"]["h"] outside2 = Map(GR["leftturn"], [Rock(GR["talltree"], 4*b, 5*b, True), Rock(GR["talltree"], 5.5*b, 4.5*b, True), Rock(GR["talltree"], 2*b, 4.7*b, True), Rock(GR["talltree"], 6.7*b, 2*b, True), Rock(GR["rock"], 5*b, 4*b, False), Rock(GR["talltree"], 1.7*b, 0.3*b, True), Rock(GR["rock"], 6*b, 2*b, True)]) outside2.exitareas = [Exit([-extraarea, 0, extraarea, outsideheight], False, 'outside1', GR["horizontal"]["w"] - honeyw, "same")] outside2.enemies = [Enemy(GR["sheep0"], 0.5, "sheep"), Enemy(GR["meangreen0"], 0.3, "greenie"), Enemy(GR["purpleperp0"], 0.2, "purpur")] outside2.lvrange = [1] # jeremyhome############################################################################################################ b = GR["halfpath"]["w"] / 10 jeremyhome = Map(GR["horizontal"], [Rock(GR["rabbithole"], b * 5 + GR["rabbithole"]["w"], b * 5 - GR["rabbithole"]["h"], True), Rock(GR["jeremy0"], b * 5 + GR["rabbithole"]["w"], b * 5 - GR["rabbithole"]["h"], True)]) jeremyhome.exitareas = [Exit([b * 10, 0, extraarea, GR["halfpath"]["h"]], False, 'outside1', 0, "same")] conversations.jeremy.area = [b * 5 + GR["rabbithole"]["w"]-(honeyw/2), b * 5 - GR["rabbithole"]["h"], GR["rabbithole"]["w"]-(honeyw/2), GR["rabbithole"]["h"]] jeremyhome.conversations = [conversations.jeremy] # outside1##############################################################################################################