コード例 #1
0
 def infectCount(self,MyCity):
     infectList = []
     for studentID in self.StudentList:
         student = person.locate(studentID,MyCity)
         if student.status != 0:
             infectList.append(student.status)
     return infectList
コード例 #2
0
 def infectCount(self,MyCity):
     infectList = []
     for workerID in self.WorkerList:
         worker = person.locate(workerID,MyCity)
         if worker.status != 0:
             infectList.append(worker.status)
     return infectList
コード例 #3
0
 def printWorkerList(self,MyCity,num=1000):
     i=0
     for workerID in self.WorkerList:
         worker = person.locate(workerID,MyCity)
         print(worker.name,end=',')
         i+=1
         if i >= num:
             print('\n')
             break
コード例 #4
0
 def infectRefresh(self,randomSeed,time,MyCity):
     INFECT_RATE = 5000
     infectList = self.infectCount(MyCity)
     if len(infectList) != 0:
         for studentID in self.StudentList:
             student = person.locate(studentID,MyCity)
             if student.status == 0:
                 random.seed(a=randomSeed*10000+student.ID*100+time)
                 for source in infectList:
                     if person.locate(studentID,MyCity).status == 0 and random.randint(1,INFECT_RATE) == 1:
                         person.locate(studentID,MyCity).status = source+1
                     else:
                         pass
             else:
                 pass
     else:
         pass
     return 0
コード例 #5
0
 def printStudentList(self,MyCity,num=100):
     i=0
     for studentID in self.StudentList:
         student = person.locate(studentID,MyCity)
         print(student.name,end=',')
         i+=1
         if i >= num: 
             print('\n')
             break
コード例 #6
0
 def infectRefresh(self,randomSeed,time,MyCity):
     INFECT_RATE = 10000    # The rate is 1/this number
     infectList = self.infectCount(MyCity)
     if len(infectList) != 0:
         for workerID in self.WorkerList:
             worker = person.locate(workerID,MyCity)
             if worker.status == 0:
                 random.seed(a=randomSeed*10000+worker.ID*100+time)
                 for source in infectList:
                     if worker.status == 0 and random.randint(1,INFECT_RATE) == 1:
                         person.locate(workerID,MyCity).status = source+1
                     else:
                         pass
             else:
                 pass
     else:
         pass
     return 0
コード例 #7
0
def main():
    # Random seed initialize
    randomSeed = input('Random seed, press ENTER to pass:'******'':
        randomSeed = int(randomSeed)
    else:
        randomSeed = 20200229
    random.seed(a=randomSeed)

    # Player name
    playerName = input('Your Character Name:')
    if playerName == '':
        playerName = nameGenerator.nameGenerate()
        print('Your name is %s!' % playerName)

    # City initiate
    cityName = 'unnamed city'
    cityName = input('Your City Name:')
    if cityName == '':
        cityName = nameGenerator.nameGenerate()
    MyCity = city.cityInit(cityName, randomSeed)

    # Myself initialize
    '''
    mSelfID = bladerunner.bladerunnerInit(randomSeed+1)
    mSelf = person.locate(mSelfID,MyCity)
    mSelf.name = playerName
    '''
    storyteller.bgTeller(playerName, 143289)

    # Time and person list initialize
    personIDList = person.personIDList()
    time = 100

    # Main loop
    while time != None:
        time = operation.dayBreak(time, MyCity, randomSeed)
        time = operation.breakfast(time, MyCity, randomSeed)
        time = operation.work(time, MyCity, randomSeed)
        time = operation.lunch(time, MyCity, randomSeed)
        time = operation.work(time, MyCity, randomSeed)
        time = operation.dinner(time, MyCity, randomSeed)
        time = operation.investigate(time, MyCity, randomSeed)
        if time != None:
            time = operation.dayEnd(time, MyCity, randomSeed)

    # Main loop end
    bladerunner.findBladerunner(MyCity.bRunnerID)

    # test block
    print('Bladerunner ID is: %d' % MyCity.bRunnerID)
    bRunner = person.locate(MyCity.bRunnerID, MyCity)
    print('Bladerunner Job is :', bRunner.jobName(), ', work in ',
          bRunner.workplace)
    storyteller.endGame(playerName)
コード例 #8
0
def visit(placeNum, MyCity):
    Dist = MyCity.DistrictList[placeNum]
    print(
        'What do you want to learn here?\n1-number of infected people here\n2-random ask one people here\nenter-skip'
    )
    choice1 = makeChoice(3)
    if choice1 == 1:
        if placeNum in range(15, 25):
            Dist.printWorkerList(MyCity)
            print("There are %d infected people here." %
                  len(Dist.infectCount(MyCity)))
        elif placeNum in range(25, 30):
            Dist.printStudentList(MyCity)
            print("There are %d infected people here." %
                  len(Dist.infectCount(MyCity)))
        else:
            Dist.printHouseholdList()
            print("There are %d infected people here." %
                  len(Dist.infectCount()))

    elif choice1 == 2:
        askedNum = input('ID of who you want to ask:')
        if askedNum == '':
            personList = person.personIDList()
            askedNum = personList[random.randint(0, 29999)]
        else:
            askedNum = int(askedNum)
        AskedPerson = person.locate(askedNum, MyCity)
        print('You asked %s.' % AskedPerson.name)
        print('His job is %s.' % AskedPerson.jobName())
        print('He works at %d.' % AskedPerson.workplace)
        AskedPerson.getStatus()
        input('Press Enter to pass......')
    elif choice1 == 3:
        askedNum = int(input('ID of who you want to ask:'))
        if placeNum in range(25, 30):
            if Dist.findStudent(askedNum) == True:
                print('Yes he/she is here!')
        elif placeNum in range(20, 25):
            if Dist.findWorker(askedNum) == True:
                print('Yes he/she is here!')
    else:
        pass
コード例 #9
0
def cityInit(cityName,randomSeed):
    MyCity = City(cityName,[])
    print('Welcome to city '+cityName+'!')
    print('Loading......')
    
    # Living place and all people
    for i in range(15):
        MyDistrict = districtInit0(i,randomSeed)
        MyCity.DistrictList.append(MyDistrict)

    # Factory
    for i in range(15,25):
        MyDistrict = districtInit1(i,randomSeed)
        MyCity.DistrictList.append(MyDistrict)

    # School
    for i in range(25,30):
        MyDistrict = districtInit2(i,randomSeed)
        MyCity.DistrictList.append(MyDistrict)

    # Bladerunner initialize
    bRunnerID = bladerunner.bladerunnerInit(randomSeed)
    bladerunner.bladerunnerLocate(bRunnerID,MyCity)
    MyCity.bRunnerInit(bRunnerID)

    # Align their work
    personIDList = person.personIDList()
    for ID in personIDList:
        citizen = person.locate(ID,MyCity)
        if citizen.job == 2:
            MyCity.DistrictList[citizen.workplace].addWorker(ID)
        elif citizen.job == 4:
            MyCity.DistrictList[citizen.workplace].addStudent(ID)
        else:
            pass
    return MyCity