Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.34 KB | None | 0 0
  1. '''
  2. This will hopefully animate the replicating probes
  3. '''
  4. import matplotlib.pyplot as plt
  5. from ReplicatingProbe import initializeprobe , initializestars
  6. width = 101
  7. height = 101
  8. def replicatinganimationloop(probability, N_steps):
  9.     probelist = initializeprobe()
  10.     starlist = initializestars(probability)
  11.     count = 0
  12.     while count<=N_steps:
  13.         xvalues = []
  14.         yvalues = []
  15.         for k in probelist:
  16.             k.move()
  17.             xvalues.append(k.location[0])
  18.             yvalues.append(k.location[1])
  19.             xcoordinate = k.location[0]
  20.             ycoordinate = k.location[1]
  21.             if starlist[xcoordinate + width][ycoordinate + height].useful:
  22.                 k.replicate(probelist)
  23.             starlist[xcoordinate + width][ycoordinate + height].visited()
  24.             #update the number of times the star the probe traveled to has been visited, and consume resources
  25.         count+=1
  26.         points.set_data(xvalues,yvalues)
  27.         plt.pause(1)
  28.  
  29. if __name__ == '__main__':
  30.     xlist = []
  31.     ylist = []
  32.     for j in range(0,10):
  33.         xlist.append(0)
  34.         ylist.append(0)
  35.     figure , axes = plt.subplots()
  36.     axes.set_xlim(-101, 101)
  37.     axes.set_ylim(-101, 101)
  38.     plt.grid(True)
  39.     points, = axes.plot(xlist, ylist, marker='o', linestyle='None')
  40.     replicatinganimationloop(.05,10000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement