def results(self): lines = [ln for ln in board_lines(self.board, 3, 3) if len(ln) == 3] result_xs = len([ln for ln in lines if ln == 'XXX']) - len( [ln for ln in lines if ln == 'OOO']) if not result_xs and [ln for ln in lines if '.' in ln]: result_xs = None return game_result('Xs', self.players, result_xs)
def results(self): # There is no draw in this game enabled_player = self.players[self.enabled] if not self.enabled: # Toads turn moves = 'T_' in self.board or 'TF_' in self.board else: # Frogs turn moves = '_F' in self.board or '_TF' in self.board if not moves: return game_result(enabled_player, self.players, -1) return None
def results(self): hp_1 = 0 hp_2 = 0 for token in self.board: if token.team == 1: hp_1+=token.health if token.team == 2: hp_2+=token.health if hp_1 <=0 or hp_2 <=0: return game_result('Good', self.players, (hp_1 - hp_2)/abs((hp_1 - hp_2))) else: return None
def results(self): if not self.moves(): result_xs = sum( len(ln) - 2 if ln == 'X' * len(ln) else 1 for ln in board_lines(self.board, 4, 4) if len(ln) > 2 and (ln == 'X' * len(ln) or 'XXX' in ln)) result_os = sum( len(ln) - 2 if ln == 'O' * len(ln) else 1 for ln in board_lines(self.board, 4, 4) if len(ln) > 2 and (ln == 'O' * len(ln) or 'OOO' in ln)) # print (list(board_lines(self.board, 4, 4))) # print (result_xs, result_os) return game_result('Xs', self.players, result_xs - result_os) else: return None