Mercurial > hg > python
comparison nono.py @ 37:6543fcbb8abd actOnZero
stop some/most cross-checks, but x out a 0-counted cell in step processing
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Wed, 25 Mar 2020 21:44:13 +0000 |
parents | 6c9e371b0325 |
children |
comparison
equal
deleted
inserted
replaced
17:6c9e371b0325 | 37:6543fcbb8abd |
---|---|
70 for v in range(i,bound): | 70 for v in range(i,bound): |
71 for sub in self.seedList(1,j+1,pos0+v+r,posN,runLen-(r+1)): | 71 for sub in self.seedList(1,j+1,pos0+v+r,posN,runLen-(r+1)): |
72 yield [-v,r]+sub | 72 yield [-v,r]+sub |
73 | 73 |
74 def step(self,pos): | 74 def step(self,pos): |
75 changed=0 | |
75 if self.runs==[]: | 76 if self.runs==[]: |
76 return 0 | 77 for i in range(self.n): |
78 if self[i].val is None: | |
79 changed+=1 | |
80 self.newX(i) | |
81 return changed | |
77 scratch=[0 if c.val is None else c.val for c in self] | 82 scratch=[0 if c.val is None else c.val for c in self] |
78 wins=0 | 83 wins=0 |
79 changed=0 | |
80 for k,runs in enumerate(self.allRuns): | 84 for k,runs in enumerate(self.allRuns): |
81 if (self.m.loop,self.cLet,pos,k)==(1,'R',7,5): | |
82 print(self.m) | |
83 dprint('=====pass %s.%s.%s.%s======'%(self.m.loop,self.cLet,pos,k)) | 85 dprint('=====pass %s.%s.%s.%s======'%(self.m.loop,self.cLet,pos,k)) |
84 if self.onepass(self.margin0,self.marginN+1,scratch,runs.copy()): | 86 if self.onepass(self.margin0,self.marginN+1,scratch,runs.copy()): |
85 wins+=1 | 87 wins+=1 |
86 dprint(wins, scratch) | 88 dprint(wins, scratch) |
87 maybeSeq=None | 89 maybeSeq=None |
88 inSeq=None | 90 inSeq=None |
89 j=None | 91 j=None |
90 for i in range(self.n): | 92 for i in range(self.n): |
93 if scratch[i]==0: | |
94 # Never blobbed, if not x already x it | |
95 if self[i].val is None: | |
96 self.newX(i) | |
91 if scratch[i]>=wins: | 97 if scratch[i]>=wins: |
92 # If blobby in _every_ pass, then must be a blob | 98 # If blobby in _every_ pass, then must be a blob |
93 if inSeq is None: | 99 if inSeq is None: |
94 inSeq=i if maybeSeq is None else maybeSeq | 100 inSeq=i if maybeSeq is None else maybeSeq |
95 dprint('s1',inSeq) | 101 dprint('s1',inSeq) |
192 scratch[k]+=maybe[k] | 198 scratch[k]+=maybe[k] |
193 return True | 199 return True |
194 eprint("Shouldn't happen? - fell through",stack,i,iBound,err=102) | 200 eprint("Shouldn't happen? - fell through",stack,i,iBound,err=102) |
195 | 201 |
196 def checkX(self,pos,crosspos): | 202 def checkX(self,pos,crosspos): |
203 return | |
197 # New x at pos, are there others that can be xed out now? | 204 # New x at pos, are there others that can be xed out now? |
198 # Overkill as is? | 205 # Overkill as is? |
199 dprint('cx',self.cLet+str(crosspos),pos) | 206 dprint('cx',self.cLet+str(crosspos),pos) |
200 if self.runs: | 207 if self.runs: |
201 start0=self.margin0 # 0 if self.margin0==0 else self.margin0+1 | 208 start0=self.margin0 # 0 if self.margin0==0 else self.margin0+1 |