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" |
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 |