Skip to content
This repository has been archived by the owner on Apr 24, 2019. It is now read-only.

Commit

Permalink
Replace winning_player with winning_row
Browse files Browse the repository at this point in the history
  • Loading branch information
edgenard committed Apr 3, 2018
1 parent 64d02e5 commit dc8849e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tic-tac-toe/tic_tac_toe.rb
Expand Up @@ -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.

Copy link
@medwards1771

medwards1771 Apr 3, 2018

Contributor

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)
Expand Down

0 comments on commit dc8849e

Please sign in to comment.