Exemple #1
0
 def makeGood(self):
     nICBs=self.m*(self.n-1)+self.n*(self.m-1)
     connect=DisjSets(nICBs)
     seed(a=2014)
     chosen=set()
     up=nICBs
     # choose random ICB, if they do not equal, connect them until every cell is connected
     while up>0:
         i=randrange(0,nICBs)
         if i not in chosen:
             if connect(self.side1[i])!=connect(self.side2[i]):
                 self.wallUp[i]=False
                 connect.union(connect(self.side1[i]),connect(self.side2[i]))
             set.add(chosen,i)
             up=up-1
     return True
Exemple #2
0
 def isGood(self):
     nICBs=self.m*(self.n-1)+self.n*(self.m-1)
     up=nICBs
     connect=DisjSets(nICBs) #connect the boundaries
     # if the wallUp is False, reduce the number of nCIBs. When the loop finishes,
     # the number of boundaries should be (m-1)*(n-1) and all connect(i) is equal
     for i in range(nICBs):
         if self.wallUp[i]==False:
             up=up-1
             connect.union(connect(self.side1[i]),connect(self.side2[i]))
     for i in range(nICBs):
         if connect(i)!=connect(i+1):
             return False
         else:
             if up==(self.m-1)*(self.n-1):
                 return True