Changeset 161
- Timestamp:
- 09/15/04 21:39:06 (4 years ago)
- Location:
- 06/devel
- Files:
-
- 4 modified
-
abstractBoardPY.py (modified) (3 diffs)
-
board.py (modified) (3 diffs)
-
kombilo.py (modified) (11 diffs)
-
searchPY.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
06/devel/abstractBoardPY.py
r152 r161 26 26 from copy import deepcopy 27 27 28 29 28 class abstractBoard: 30 29 """ This class administrates a go board. … … 47 46 self.undostack = [] 48 47 self.boardsize = boardsize 49 50 48 51 49 def getStatus(self, x, y): … … 62 60 ab.undostack = deepcopy(ab.undostack) 63 61 return ab 62 63 def restore(self, data): 64 self.boardsize = ab.boardsize 65 self.status = ab.status 66 self.undostack = ab.undostack 64 67 65 68 def len_cap_last(self): -
06/devel/board.py
r152 r161 32 32 try: 33 33 from abstractBoard import * 34 print 'OK' 34 35 except ImportError: 36 print 'oops' # FIXME 35 37 from abstractBoardPY import * 36 38 … … 176 178 177 179 178 def resize(self, event = None ):180 def resize(self, event = None, force = 0): 179 181 """ This is called when the window containing the board is resized. """ 180 182 181 if not self.resizable : return183 if not self.resizable and not force: return 182 184 183 185 self.noChanges = 1 … … 209 211 self.noChanges = 0 210 212 213 214 def snapshot(self): 215 handle = abstractBoard.snapshot(self) 216 self.snapshots[handle].extend([self.currentColor, deepcopy(self.stones), deepcopy(self.marks), deepcopy(self.labels)]) 217 return handle 218 219 def restore(self, handle): 220 abstractBoard.restore(self, handle) 221 self.currentColor = self.snapshots[handle][2] 222 self.stones = self.snapshots[handle][3] 223 self.marks = self.snapshots[handle][4] 224 self.labels = self.snapshots[handle][5] 225 self.resize(None, 1) 211 226 212 227 def play(self, pos, color=None): -
06/devel/kombilo.py
r160 r161 92 92 """ 93 93 Board with support for wildcards and selection 94 of search-relevant region. Furthermore, snapshot returns a dictionary which 95 describes the current board position. It can then be restored with restore. 94 of search-relevant region. 96 95 """ 97 96 … … 115 114 116 115 117 def resize(self, event = None ):116 def resize(self, event = None, force=0): 118 117 """ Resize the board. Take care of wildcards and selection here. """ 119 118 120 Board.resize(self, event )119 Board.resize(self, event, force) 121 120 for x,y in self.wildcards.keys(): 122 121 x1, x2, y1, y2 = self.getPixelCoord((x,y),1) … … 291 290 292 291 def snapshot(self): 293 """ Return a dictionary which contains the data of all the objects 294 currently displayed on the board, which are not stored in the SGF file. 295 This means, at the moment: wildcards, and selection. """ 296 297 data = {} 298 data['wildcards'] = copy(self.wildcards) 299 data['selection'] = self.selection 300 return data 301 302 303 def restore(self, d): 304 """ Restore the data from a 'snapshot' dictionary. """ 305 306 for pos in d['wildcards'].keys(): 307 color = d['wildcards'][pos][1] 308 x1, x2, y1, y2 = self.getPixelCoord(pos,1) 309 self.wildcards[pos] = (self.create_oval(x1+4, x2+4, y1-4, y2-4, fill = color, 310 tags=('wildcard','non-bg')), color) 311 312 if d['selection'] != ((0,0), (self.boardsize-1, self.boardsize-1)) and d['selection'][1] != (-1,-1): 313 self.setSelection(d['selection'][0], d['selection'][1]) 292 handle = Board.snapshot(self) 293 self.snapshots[handle].extend([copy(self.wildcards), self.selection]) 294 return handle 295 296 def restore(self, handle): 297 self.wildcards = self.snapshots[handle][6] 298 self.selection = self.snapshots[handle][7] 299 Board.restore(self, handle) # This does a self.resize(), which takes care of wildcards and selection in our case 314 300 315 301 # --------------------------------------------------------------------------------------- … … 977 963 978 964 979 def append(self, s, data = None): 980 981 if not data: return 982 965 def append(self, s): 983 966 if self.mster.options.maxLengthSearchesStack.get() and\ 984 967 len(self.data) >= self.mster.options.maxLengthSearchesStack.get(): … … 999 982 b.unbind('<Shift-1>', b.bounds1) 1000 983 1001 for key in data[0].keys():1002 print data[0][key]1003 p = b.getPixelCoord(key)1004 b.status[key] = data[0][key]1005 b.stones[key] = b.create_oval(p, fill=data[0][key], tags='non-bg')1006 for key in data[1].keys():1007 print key,1008 color = data[1][key][1]1009 print color1010 x1, x2, y1, y2 = b.getPixelCoord(key,1)1011 b.wildcards[key] = (b.create_oval(x1, x2, y1, y2, fill = color,1012 outline='', tags=('wildcard','non-bg')), color)1013 print b.wildcards[key]1014 if data[2] != ((0,0), (self.mster.boardsize-1, self.mster.boardsize-1)) and data[2][1] != (-1,-1):1015 b.setSelection(data[2][0], data[2][1])984 # for key in data[0].keys(): 985 # print data[0][key] 986 # p = b.getPixelCoord(key) 987 # b.status[key] = data[0][key] 988 # b.stones[key] = b.create_oval(p, fill=data[0][key], tags='non-bg') 989 # for key in data[1].keys(): 990 # print key, 991 # color = data[1][key][1] 992 # print color 993 # x1, x2, y1, y2 = b.getPixelCoord(key,1) 994 # b.wildcards[key] = (b.create_oval(x1, x2, y1, y2, fill = color, 995 # outline='', tags=('wildcard','non-bg')), color) 996 # print b.wildcards[key] 997 # if data[2] != ((0,0), (self.mster.boardsize-1, self.mster.boardsize-1)) and data[2][1] != (-1,-1): 998 # b.setSelection(data[2][0], data[2][1]) 1016 999 1017 1000 b.tkraise('non-bg') … … 1020 1003 self.prevSF.reposition() 1021 1004 self.data.append([s, b, 0]) 1022 if data:self.select(len(self.data)-1)1005 self.select(len(self.data)-1) 1023 1006 1024 1007 … … 1841 1824 1842 1825 boardData = self.board.snapshot() 1843 boardData2 = (None, None, None) # FIXME, was (copy(self.board.status), copy(self.board.wildcards), self.board.selection)1844 1826 1845 1827 self.progBar.clear() … … 1940 1922 games = [l.current for l in self.gamelist.DBlist[`self.boardsize`]] 1941 1923 # This should really be copy (resp. deepcopy), 1942 # but that would be too slow 1924 # but that would be too slow (FIXME: test this again; also test join/split?!) 1943 1925 # and it should work this way too. 1944 # results = [join(l.results, '|%')for l in self.gamelist.DBlist[`self.boardsize`]]1945 # FIXME results (is now list of Hit's)1946 # cursorSn = [self.cursor, self.cursor.currentGame, self.cursor.currentN.pathToNode()] 1947 # see FIXME above (boardData = ...)1948 #self.prevSearches.append([boardData, games, results, copy(self.continuations),1949 #self.noMatches, self.noSwitched, self.Bwins, self.Wwins,1950 #self.modeVar.get(), self.fixedColorVar.get(), self.fixedAnchorVar.get(),1951 # self.moveLimit.get(), self.nextMoveVar.get(), cursorSn], boardData2)1926 results = [l.results for l in self.gamelist.DBlist[`self.boardsize`]] 1927 # FIXME not sure whether this works 1928 1929 cursorSn = [self.cursor, self.cursor.currentGame, self.cursor.currentN.pathToNode()] 1930 self.prevSearches.append([boardData, games, results, copy(self.continuations), 1931 self.noMatches, self.noSwitched, self.Bwins, self.Wwins, 1932 self.modeVar.get(), self.fixedColorVar.get(), self.fixedAnchorVar.get(), 1933 self.moveLimit.get(), self.nextMoveVar.get(), cursorSn]) 1952 1934 1953 1935 self.configButtons(NORMAL) … … 2238 2220 2239 2221 try: 2240 d, g, r, c, nm, ns, bw, ww, mv, fc, fa, ml, nextM, cu = prev2222 handle, g, r, c, nm, ns, bw, ww, mv, fc, fa, ml, nextM, cu = prev 2241 2223 except: 2242 2224 self.reset() … … 2256 2238 self.Wwins = 0 2257 2239 2258 if d:2240 if not handle is None: 2259 2241 if cu: 2260 2242 found = 0 … … 2278 2260 self.cursor.seeCurrent() 2279 2261 2280 self.board.restore( d)2262 self.board.restore(handle) 2281 2263 2282 2264 self.sel = self.board.selection # used in self.showCont() 2283 self.capVar.set('Cap - B: ' + str(self.capB) + ', W: ' + str(self.capW)) 2265 self.capVar.set('Cap - B: ' + str(self.capB) + ', W: ' + str(self.capW)) # FIXME wo kommen die her? ist das so ok? 2284 2266 else: 2285 2267 showwarning('Error', 'SGF File not found') -
06/devel/searchPY.py
r160 r161 367 367 elif self.branchpoints: 368 368 for algo in algolist: algo.endOfVariation_process() 369 print 'eov process'369 # print 'eov process' 370 370 cursor.currentN, b, whichVar = self.branchpoints.pop() 371 371 if whichVar+2 < cursor.noChildren():
