/[gnugo]/gnugo/interface/gtp_examples/twogtp.py
ViewVC logotype

Diff of /gnugo/interface/gtp_examples/twogtp.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by gf, Sat Mar 15 21:41:32 2003 UTC revision 1.5 by gf, Sat Mar 15 22:01:57 2003 UTC
# Line 308  class GTP_game: Line 308  class GTP_game:
308      def swap_players(self):      def swap_players(self):
309          temp = self.whiteplayer          temp = self.whiteplayer
310          self.whiteplayer = self.blackplayer          self.whiteplayer = self.blackplayer
311          self.blackplayer = self.whiteplayer          self.blackplayer = temp
312    
313      def play(self, sgffile):      def play(self, sgffile):
314          "Play a game"          "Play a game"
# Line 508  class GTP_match: Line 508  class GTP_match:
508    
509              if result[0][0] == last_color:              if result[0][0] == last_color:
510                  last_streak += 1                  last_streak += 1
511                  if last_streak == self.streak_length:              elif result[0][0] != "0":
                     if last_color == "W":  
                         self.handicap += 1  
                         if self.handicap == 1:  
                             self.handicap = 2  
                         print "White wins too often. Increasing handicap to %d" \  
                               % (self.handicap)  
                     else:    
                         if self.handicap > 0:  
                             self.handicap -= 1  
                             if self.handicap == 1:  
                                 self.handicap = 0  
                             print "Black wins too often. Decreasing handicap to %d" \  
                                   % (self.handicap)  
                         else:  
                             self.handicap = 2  
                             game.swap_players()  
                             print "Black looks stronger than white. Swapping colors and setting handicap to 2"  
                     game.set_handicap(self.handicap)  
                     last_color = ""  
                     last_streak = 0  
             else:  
512                  last_color = result[0][0]                  last_color = result[0][0]
513                  last_streak = 1                  last_streak = 1
514    
515                if last_streak == self.streak_length:
516                    if last_color == "W":
517                        self.handicap += 1
518                        if self.handicap == 1:
519                            self.handicap = 2
520                        print "White wins too often. Increasing handicap to %d" \
521                              % (self.handicap)
522                    else:  
523                        if self.handicap > 0:
524                            self.handicap -= 1
525                            if self.handicap == 1:
526                                self.handicap = 0
527                            print "Black wins too often. Decreasing handicap to %d" \
528                                  % (self.handicap)
529                        else:
530                            self.handicap = 2
531                            game.swap_players()
532                            print "Black looks stronger than white. Swapping colors and setting handicap to 2"
533                    game.set_handicap(self.handicap)
534                    last_color = ""
535                    last_streak = 0
536              results.append(result)              results.append(result)
537          game.quit()          game.quit()
538          return results          return results

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26