Skip to content

Commit

Permalink
modified the init function
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemo Biswas authored and Nemo Biswas committed May 9, 2016
1 parent 677907e commit 3476b8a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions datk/core/distalgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,17 @@ def __init__(self, n, index_to_UID = None):
with random distinct UIDs, or as specified by
the index_to_UID function
"""
self.algs=[]
self.canvas = None
self.algs = []
if index_to_UID is None:
self.processes = [Process(i) for i in range(n)]
shuffle(self.processes)
proc_ids = range(n)
shuffle(proc_ids)
process2uid = dict(zip(range(n),proc_ids))
self.processes = [Process(process2uid[i]) for i in range(n)]
self.uid2process = dict(zip(proc_ids,range(n)))
# shuffle(self.processes)
else:
self.processes = [Process(index_to_UID(i)) for i in range(n)]
self.uid2process = dict(zip(range(n),[index_to_UID(i) for i in range(n)]))
for process in self:
process.state['n'] = n

Expand Down

0 comments on commit 3476b8a

Please sign in to comment.