daily pastebin goal
15%
SHARE
TWEET

Untitled

a guest Jun 19th, 2017 39 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from random import random
  2. from sys import stdout
  3. from time import sleep
  4. import os
  5. class A:
  6.     def __init__(self):
  7.         self.pos=int(round(random()*50))
  8.         self.richtung=int(round(random()*20-10))
  9.         self.char=str(int(round(random()*9)))
  10.     def move(self):
  11.         self.richtung+=int((round(random()*5-2.5)))
  12.         if self.richtung > 20: self.richtung = 20
  13.         elif self.richtung < -20: self.richtung = -20
  14.         self.pos+=self.hardlim(self.richtung)
  15.         if self.pos==-1: self.pos=49
  16.         elif self.pos==50: self.pos=0
  17.     def hardlim(self,n):
  18.         if n<0:return -1
  19.         elif n>0:return 1
  20.         else: return 0
  21. aas=[]
  22. for i in range(5):
  23.     aas.append(A())
  24. #while 1:
  25. stdout.write("\b"*60)
  26. tmp=["/"]+["-"]*48+["\\"]+[' ']*10
  27. tmps=""
  28. for a in aas:
  29.     if a.pos!=0 and a.pos!= 49:
  30.         tmp[a.pos]=a.char
  31.     a.move()
  32. for i in range(len(tmp)):
  33.     tmps+=tmp[i]
  34. #stdout.write("\x1b]2;"+tmps+"\x07")
  35. stdout.write(tmps)
  36. stdout.flush()
  37. #os.system('echo "'+tmps+'" > a.txt')
  38. #sleep(0.5)
RAW Paste Data
Top