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


Python Target.reportEnd方法代码示例

本文整理汇总了Python中target.Target.reportEnd方法的典型用法代码示例。如果您正苦于以下问题:Python Target.reportEnd方法的具体用法?Python Target.reportEnd怎么用?Python Target.reportEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在target.Target的用法示例。


在下文中一共展示了Target.reportEnd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from target import Target [as 别名]
# 或者: from target.Target import reportEnd [as 别名]
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)
开发者ID:lkhedlund,项目名称:python-practice,代码行数:54,代码来源:manager.py


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