Changeset 166
- Timestamp:
- 09/30/04 19:47:51 (4 years ago)
- Files:
-
- 06/devel/abstractBoardPY.py (modified) (1 diff)
- 06/devel/algosPY.py (modified) (12 diffs)
- 06/devel/kombilo.py (modified) (1 diff)
- 06/devel/patternPY.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
06/devel/abstractBoardPY.py
r165 r166 69 69 """ Return number of captured stones in last move. """ 70 70 71 if not self.undostack:72 print 'no undostack'73 return 074 elif len(self.undostack[-1]) < 3: print self.undostack[-1]75 71 return len(self.undostack[-1][2]) 76 72 06/devel/algosPY.py
r160 r166 222 222 def search(self, patternList, options, db, progBar, progStart, progEnd): 223 223 224 print 'algo-finalpos start' 224 225 ctr = 0 225 226 … … 319 320 index = db.next() 320 321 321 print numOfMatches, numOfOccurrences322 print 'algo-finalpos:', numOfMatches, numOfOccurrences 322 323 323 324 # in x-coord: … … 548 549 index = db.start() 549 550 gameCounter = 0 550 551 551 552 while not index is None: 552 553 … … 579 580 dNO = 0 580 581 p = patternList.get(m[0]) 582 p.printPattern() 581 583 for i in range(p.sizeX): 582 584 for j in range(p.sizeY): … … 607 609 # then going forward n2 times, then choosing the m2-th variation, 608 610 # etc. 609 # we have counter == sum_j nj 611 # we have counter == sum_j nj // FIXME this cannot be correct (maybe i + sum_j nj) 610 612 611 613 while movelistIndex < endMovelist and (counter <= self.movelimit or self.branchpoints): … … 691 693 692 694 elif dicts[m].has_key('foundInitial'): 693 695 print contList[m], contListIndex[m] 694 696 if (x, y, co) == contList[m][contListIndex[m]]: 695 697 contListIndex[m] += 1 … … 751 753 752 754 # look for captures in the contList 753 # (which may be in the wrong order) 755 # (which may be in the wrong order) FIXME: probably would make sense to sort them ... 754 756 755 757 ii = contListIndex[m] … … 761 763 help = contList[m][ii] 762 764 contList[m][ii] = contList[m][contListIndex[m]] 763 cont list[contListIndex[m]] = help765 contList[contListIndex[m]] = help 764 766 765 767 contListIndex[m] += 1 768 print 'X', contListIndex[m] 766 769 767 770 else: … … 783 786 if endOfNode: 784 787 for m in dicts.keys(): 785 if dictsNO[m] == 0 and not dicts[m].has_key('found') \ 786 and not dicts[m].has_key('foundInitial'): 787 if contListIndex[m] == len(contList[m]): 788 dicts[m]['found'] = counter 789 dicts[m]['whereAreWe'] = copy(whereAreWe) 790 # print 'found1', counter, whereAreWe 791 else: dicts[m]['foundInitial'] = counter 788 if dicts[m].has_key('found'): continue 789 if (dictsNO[m] == 0 and not contList[m]) \ 790 or (dicts[m].has_key('foundInitial') and contListIndex[m] == len(contList[m])): 791 dicts[m]['found'] = counter 792 dicts[m]['whereAreWe'] = copy(whereAreWe) 793 print 'found1', counter, whereAreWe 794 elif dictsNO[m] == 0 and not dicts[m].has_key('foundInitial'): 795 dicts[m]['foundInitial'] = counter 796 print 'foundInitial', counter 792 797 793 798 counter += 1 … … 840 845 841 846 def __init__(self, boardsize, poslist, filename): 842 self.poslist = [[0,0] +p for p in poslist] # store num of stones and current847 self.poslist = [[0,0]+p for p in poslist] # store num of stones and current 843 848 # hashcode in first two entries 844 849 self.filename = filename … … 981 986 """ 982 987 988 print 'algo.hash.search start' 983 989 for i in range(patternList.size()): 984 990 pattern = patternList.get(i) … … 1069 1075 l[2] += 2 1070 1076 matchList.append((N, (a0, a1))) 1077 # print [ll[0] for ll in pattern.hashkeys[(a0,a1)]], matchPossible 1071 1078 1072 1079 if matchList: db.makeCurrentCandidate(matchList) 06/devel/kombilo.py
r165 r166 2360 2360 if self.moveSequenceVar.get(): 2361 2361 self.currentContList.append((pos[0], pos[1], color)) 2362 for c in self.board.undostack[-1][2]: 2363 self.currentContList.append((c[0], c[1], '-')) 2362 2364 self.board.placeMSLabel(pos, 'LB', `len(self.currentContList)`) 2363 2364 # FIXME: put captures into currentContList! 2365 2365 2366 2366 if self.oneClick.get() and (self.board.selection[1] == (-1,-1) or \ 2367 2367 (self.board.selection[0][0] <= pos[0] <= self.board.selection[1][0] \ 06/devel/patternPY.py
r164 r166 71 71 d.append('\n') 72 72 print join(d, '') 73 print 'anchors', self.anchors 73 print 74 d = [] 75 for j in range(self.sizeY): 76 for i in range(self.sizeX): 77 d.append(self.finalPos[i+j*self.sizeX]) 78 d.append('\n') 79 print join(d, '') 80 print self.contList 74 81 75 82 … … 101 108 102 109 for t in contList.split('/'): 103 if t and t[2] in ['B', 'W']: 104 # print ord(t[0]), ord(t[1]), t[2] 105 helpFinalPos[ord(t[0]) + sizeX*ord(t[1])] = self.BW2XO(t[2]) # FIXME: deal with captures 106 110 if t: 111 if t[2] in ['B', 'W']: 112 # print ord(t[0]), ord(t[1]), t[2] 113 helpFinalPos[ord(t[0]) + sizeX*ord(t[1])] = self.BW2XO(t[2]) 114 else: 115 helpFinalPos[ord(t[0]) + sizeX*ord(t[1])] = '.' 107 116 self.finalPos = join(helpFinalPos, '') 108 117 … … 174 183 def invertColor(self,co): 175 184 try: 176 return {'X': 'O', 'x': 'o', 'O': 'X', 'o': 'x', '.': '.', '*': '*', 'B':'W', 'W':'B' }[co]185 return {'X': 'O', 'x': 'o', 'O': 'X', 'o': 'x', '.': '.', '*': '*', 'B':'W', 'W':'B', '-':'-'}[co] 177 186 except: 178 187 print 'oops invertColor', co # FIXME
