def validate_handicap(handicap, handicap_style, board_size): """Check whether a handicap is allowed. handicap -- int or None handicap_style -- 'free' or 'fixed' board_size -- int Raises ControlFileError with a description if it isn't. """ if handicap is None: return True if handicap < 2: raise ControlFileError("handicap too small") if handicap_style == 'fixed': limit = handicap_layout.max_fixed_handicap_for_board_size(board_size) else: limit = handicap_layout.max_free_handicap_for_board_size(board_size) if handicap > limit: raise ControlFileError("%s handicap out of range for board size %d" % (handicap_style, board_size))
def validate_handicap(handicap, handicap_style, board_size): """Check whether a handicap is allowed. handicap -- int or None handicap_style -- 'free' or 'fixed' board_size -- int Raises ControlFileError with a description if it isn't. """ if handicap is None: return True if handicap < 2: raise ControlFileError("handicap too small") if handicap_style == 'fixed': limit = handicap_layout.max_fixed_handicap_for_board_size(board_size) else: limit = handicap_layout.max_free_handicap_for_board_size(board_size) if handicap > limit: raise ControlFileError( "%s handicap out of range for board size %d" % (handicap_style, board_size))
def _choose_free_handicap_moves(self, number_of_stones): i = min(number_of_stones, handicap_layout.max_fixed_handicap_for_board_size( self.board_size)) return handicap_layout.handicap_points(i, self.board_size)