Exemplo n.º 1
0
 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
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
 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
Exemplo n.º 4
0
 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    
Exemplo n.º 5
0
 def __str__(self):
     s = GomokuGame.__str__(self)
     s += 'Black captured:' + str(
         self.pairsTaken[self.BLACK]) + ', white captured:' + str(
             self.pairsTaken[self.WHITE]) + '.'
     return s
Exemplo n.º 6
0
 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
Exemplo n.º 7
0
 def __str__(self):
     s = GomokuGame.__str__(self)
     s += 'Black captured:'+str(self.pairsTaken[self.BLACK])+', white captured:'+str(self.pairsTaken[self.WHITE])+'.'
     return s
Exemplo n.º 8
0
 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