def main(): # total number of interactions between 1 and infinity validInter = False # flag for a valid user input while validInter == False: try: totalInter = int(input("Enter total number of interactions (greater than or equal to 1): ")) except ValueError: print("Do not enter non-numeric values.") else: if (totalInter >= 1): validInter = True else: validInteractions = False print("Input is out of range.") # Set the target's probability of X or Y validProb = False # flag for a valid user input while validProb == False: try: probX = int(input("Probability of X-type Interactions for the target (1-100): ")) except ValueError: print("Do not enter non-numeric values.") else: if (1 <= probX <= 100): validProb = True else: validProb = False print("Input is out of range.") probY = 100 - probX # probabilty of Y interactions #DEBUG DEBUG.dprint("total # interactions: %r" % totalInter) DEBUG.dprint("probability of X: %r" % probX) # Pursuer class takes the two probabilities aPursuer = Pursuer(totalInter) aTarget = Target(probX, probY) # Main Loop i = 0 # flag while i < totalInter: # create an interaction for the pursuer and the target interP = aPursuer.createInteraction() interT = aTarget.createInteraction() # DEBUG DEBUG.dprint("aPursuer Interaction: %r" % interP) DEBUG.dprint("aTarget Interaction: %r" % interT) DEBUG.dprint("i: %r" % i) # record and display the result result = aPursuer.reportInteraction(interP, interT) print(result) i += 1 # update flag if i >= 2: aPursuer.adaptBehaviour(interP, interT) targetX, targetY = aTarget.reportEnd() aPursuer.reportEnd(targetX, targetY)