def _setStone(self, c, pos, tokill = None): """ set stone, and potentially kill stones. """ if tokill == None: tokill = self._killsWhich(c, pos) GomokuGame._setStone(self, c, pos) for p in tokill: self.b[p] = self.EMPTY self.pairsTaken[c] += len(tokill)/2
def _setStone(self, c, pos, tokill=None): """ set stone, and potentially kill stones. """ if tokill == None: tokill = self._killsWhich(c, pos) GomokuGame._setStone(self, c, pos) for p in tokill: self.b[p] = self.EMPTY self.pairsTaken[c] += len(tokill) / 2
def getKilling(self, c): """ return all legal positions for a color that immediately kill the opponent. """ res = GomokuGame.getKilling(self, c) for p in self.getLegals(c): k = self._killsWhich(c, p) if self.pairsTaken[c] + len(k) / 2 >= 5: res.append(p) return res
def getKilling(self, c): """ return all legal positions for a color that immediately kill the opponent. """ res = GomokuGame.getKilling(self, c) for p in self.getLegals(c): k = self._killsWhich(c, p) if self.pairsTaken[c] + len(k)/2 >= 5: res.append(p) return res
def __str__(self): s = GomokuGame.__str__(self) s += 'Black captured:' + str( self.pairsTaken[self.BLACK]) + ', white captured:' + str( self.pairsTaken[self.WHITE]) + '.' return s
def reset(self): GomokuGame.reset(self) self.pairsTaken = {self.BLACK: 0, self.WHITE: 0} center = (self.size[0] / 2, self.size[1] / 2) self._setStone(-self.startcolor, center) self.movesDone += 1
def __str__(self): s = GomokuGame.__str__(self) s += 'Black captured:'+str(self.pairsTaken[self.BLACK])+', white captured:'+str(self.pairsTaken[self.WHITE])+'.' return s
def reset(self): GomokuGame.reset(self) self.pairsTaken = {self.BLACK: 0, self.WHITE: 0} center = (self.size[0]/2, self.size[1]/2) self._setStone(-self.startcolor, center) self.movesDone += 1