예제 #1
0
 def run(self):
     # [] Stop any false command from breaking the program
     try:
         # * Pause the system, waiting for a mouse click
         # self.testRun2()
         # * wait until it was tell (by other thread) to quit
         while self.quiting == False:
             # self.win.getMouse()
             self.drawString( self.inputBuffer.readNew() )
             self.win.update()
             time.sleep(.1) # give up thread
             self.isRunning = True
         # * quit after
         self.isRunning = False
         self.close()
     except Exception:
         SystemPlus.consolePrintL(traceback.format_exc())
         SystemPlus.consolePrintL( "You can still continue with the terminal:")
         SystemPlus.consolePrintL( "///////////////////////////////////////////////")
예제 #2
0
 def run(self, seed):
     cList = []
     self.seed = seed
     self.config = AutoConfig.generate( self.seed )
     # * Initialize limits
     timeCount = 1000
     cCount = 1000
     cMax = 10000
     scaleSize = 100
     currentYear = 0
     # * Generate cs
     i = 0
     while i < cCount:
         newc = Creature.createFromGen([
             RandomEx.r.randomInt(0, scaleSize), RandomEx.r.randomInt(0, scaleSize),
             RandomEx.r.randomInt(0, scaleSize), RandomEx.r.randomInt(0, scaleSize),
             RandomEx.r.randomInt(0, scaleSize), RandomEx.r.randomInt(0, scaleSize),
             RandomEx.r.randomInt(0, scaleSize), RandomEx.r.randomInt(0, scaleSize) ], self.config)
         cList += [ newc ]
         i += 1
     # * Run simulation
     for i in range(0, timeCount):
         # {} Loop through cs
         for c in cList:
             # ? Check whether the unit is still alive
             if c.isAlive == False:
                 continue
             # * Chance for an event!
             dice20 = RandomEx.r.randomInt( 1, 20 )
             # ? Chance for event or wandering
             if dice20 >= self.config.chance_of_0_19_event:
                 # * Get a random c B
                 B = cList[ RandomEx.r.randomInt( 0, len(cList) - 1) ]
                 # ? Chance for encounter or reproduce
                 if RandomEx.r.randomInt( 1, 20 ) > self.config.chance_of_0_19_encounter: # 50%
                     Creature.encounter(self.config, c, B)
                 else:
                     Creature.reproduce(self.config, c, B)
             else:
                 Creature.wandering(self.config, c)
             # * Time pass!
             Creature.timePass(self.config, c)
         # * Remove dead cs
         cList = [c for c in cList if c.isAlive == True ]
         # [] Debug outputs
         SystemPlus.consoleClear()
         SystemPlus.consolePrintL(str(i) + "|" + str(len(cList)))
         SystemPlus.consolePrintL(str(i) + "|" + str(len(cList)))
         SystemPlus.consolePrintL(str(i) + "|" + str(len(cList)))
         currentYear = i
         # [] Time to stop debugging
         if len(cList) < 10 or len(cList) > cMax:
             break
     # * A list of cs that still remain on the battle field.
     self.rlt_remainList = {}
     # [] Time to stop debugging
     SystemPlus.consoleClear()
     SystemPlus.consolePrintL("")
     SystemPlus.consolePrintL("")
     SystemPlus.consolePrintL("")
     SystemPlus.consolePrintL("")
     SystemPlus.consolePrintL("")
     # * Set up the result set
     # {} Loop through remained ced
     for c in cList:
         # [] Output remained c's name and energy.
         SystemPlus.consolePrintL(c.name + "|" + str( c.energy ) + ", ")
         # ? Check if it's the same type of c.
         if c.name in self.rlt_remainList:
             # * Add them together, if it is.
             self.rlt_remainList[c.name].Add += c
         else:
             # * Create a new list if it's not
             self.rlt_remainList[c.name] = [ c ]
     # * Set up general result information
     self.rlt_endYear = currentYear
     self.rlt_creatureCount = len(cList)
     # [] Print the end year and total c count
     SystemPlus.consolePrintL("")
     SystemPlus.consolePrintL("")
     SystemPlus.consolePrintL("Year: " + str(self.rlt_endYear))
     SystemPlus.consolePrintL("Alive: " + str(self.rlt_creatureCount))
     # [] Print general creature types and counts.
     for key, value in self.rlt_remainList.items():
         SystemPlus.consolePrintL( str( key ) + "|" + str(len( value )) + ", " )
예제 #3
0
 def consolePrintL(self, content):
     self.outputBuffer.add( content + "\n" )
     SystemPlus.consolePrintL( content )