Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- This will hopefully animate the replicating probes
- '''
- import matplotlib.pyplot as plt
- from ReplicatingProbe import initializeprobe , initializestars
- width = 101
- height = 101
- def replicatinganimationloop(probability, N_steps):
- probelist = initializeprobe()
- starlist = initializestars(probability)
- count = 0
- while count<=N_steps:
- xvalues = []
- yvalues = []
- for k in probelist:
- k.move()
- xvalues.append(k.location[0])
- yvalues.append(k.location[1])
- xcoordinate = k.location[0]
- ycoordinate = k.location[1]
- if starlist[xcoordinate + width][ycoordinate + height].useful:
- k.replicate(probelist)
- starlist[xcoordinate + width][ycoordinate + height].visited()
- #update the number of times the star the probe traveled to has been visited, and consume resources
- count+=1
- points.set_data(xvalues,yvalues)
- plt.pause(1)
- if __name__ == '__main__':
- xlist = []
- ylist = []
- for j in range(0,10):
- xlist.append(0)
- ylist.append(0)
- figure , axes = plt.subplots()
- axes.set_xlim(-101, 101)
- axes.set_ylim(-101, 101)
- plt.grid(True)
- points, = axes.plot(xlist, ylist, marker='o', linestyle='None')
- replicatinganimationloop(.05,10000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement