Permalink
Browse files

Replace winning_player with winning_row

  • Loading branch information...
edgenard committed Apr 3, 2018
1 parent 64d02e5 commit dc8849e28855a4938ddfae131305eb954a36b600
Showing with 2 additions and 2 deletions.
  1. +2 −2 tic-tac-toe/tic_tac_toe.rb
@@ -27,11 +27,11 @@ def winning_move?(square, player)

def winner
first_position_in_rows = [0, 3, 6]
first_position_in_rows.each { |position| return mark_at(position) if winning_player(position) }
first_position_in_rows.each { |position| return mark_at(position) if winning_row(position) }
return '-'
end

def winning_player(position)
def winning_row(position)

This comment has been minimized.

@medwards1771

medwards1771 Apr 3, 2018

Collaborator

That's nice. I like this change because it replaces the concept of a winning PERSON (player) with a winning COMBINATION (row of Xs or Os)

position_occupied?(position) &&
mark_at(position) == mark_at(position.next) &&
mark_at(position.next) == mark_at(position.next.next)

0 comments on commit dc8849e

Please sign in to comment.